file
stringlengths
18
26
data
stringlengths
4
1.03M
the_stack_data/54825044.c
#include <stdio.h> #define LEN 10 int sum_two_dimensional_array(int a[][LEN], int n){ int i, j, sum = 0; for (i = 0; i < n; i++) for (j = 0; j < LEN; j++) sum += a[i][j]; return sum; } int main(){ int numbers[2][LEN] = {{1,2,3,4,5,6,7,8,9,10}, {2,3,4,5,6,7,8,9,10,11}}; printf("The sum of all elements of the array is: %d\n", sum_two_dimensional_array(numbers, 2)); return 0; }
the_stack_data/193892310.c
#include <stdio.h> #include <stdlib.h> static void swap_xor(int *a, int *b) { (*a) ^= (*b); (*b) ^= (*a); (*a) ^= (*b); } int main(void) { int a = 1; int b = 2; printf("a = %d, b = %d\n", a, b); swap_xor(&a, &b); printf("a = %d, b = %d\n", a, b); return 0; }
the_stack_data/153325.c
#ifdef MODPLUG_MUSIC #include "music_modplug.h" static int current_output_channels=0; static int music_swap8=0; static int music_swap16=0; static ModPlug_Settings settings; int modplug_init(SDL_AudioSpec *spec) { ModPlug_GetSettings(&settings); settings.mFlags=MODPLUG_ENABLE_OVERSAMPLING; current_output_channels=spec->channels; settings.mChannels=spec->channels>1?2:1; settings.mBits=spec->format&0xFF; music_swap8 = 0; music_swap16 = 0; switch(spec->format) { case AUDIO_U8: case AUDIO_S8: { if ( spec->format == AUDIO_S8 ) { music_swap8 = 1; } settings.mBits=8; } break; case AUDIO_S16LSB: case AUDIO_S16MSB: { /* See if we need to correct MikMod mixing */ #if SDL_BYTEORDER == SDL_LIL_ENDIAN if ( spec->format == AUDIO_S16MSB ) { #else if ( spec->format == AUDIO_S16LSB ) { #endif music_swap16 = 1; } settings.mBits=16; } break; default: { Mix_SetError("Unknown hardware audio format"); return -1; } } settings.mFrequency=spec->freq; /*TODO: limit to 11025, 22050, or 44100 ? */ settings.mResamplingMode=MODPLUG_RESAMPLE_FIR; settings.mReverbDepth=0; settings.mReverbDelay=100; settings.mBassAmount=0; settings.mBassRange=50; settings.mSurroundDepth=0; settings.mSurroundDelay=10; settings.mLoopCount=-1; ModPlug_SetSettings(&settings); return 0; } /* Uninitialize the music players */ void modplug_exit() { } /* Set the volume for a modplug stream */ void modplug_setvolume(modplug_data *music, int volume) { ModPlug_SetMasterVolume(music->file, volume*4); } /* Load a modplug stream from an SDL_RWops object */ modplug_data *modplug_new_RW(SDL_RWops *rw, int freerw) { modplug_data *music=NULL; long offset,sz; char *buf=NULL; offset = SDL_RWtell(rw); SDL_RWseek(rw, 0, RW_SEEK_END); sz = SDL_RWtell(rw)-offset; SDL_RWseek(rw, offset, RW_SEEK_SET); buf=(char*)SDL_malloc(sz); if(buf) { if(SDL_RWread(rw, buf, sz, 1)==1) { music=(modplug_data*)SDL_malloc(sizeof(modplug_data)); if (music) { music->playing=0; music->file=ModPlug_Load(buf,sz); if(!music->file) { SDL_free(music); music=NULL; } else { music->duration_ms = ModPlug_GetLength(music->file); } } else { SDL_OutOfMemory(); } } SDL_free(buf); } else { SDL_OutOfMemory(); } if (freerw) { SDL_RWclose(rw); } return music; } /* Start playback of a given modplug stream */ void modplug_play(modplug_data *music) { ModPlug_Seek(music->file,0); music->playing=1; } /* Return non-zero if a stream is currently playing */ int modplug_playing(modplug_data *music) { return music && music->playing; } /* Play some of a stream previously started with modplug_play() */ int modplug_playAudio(modplug_data *music, Uint8 *stream, int len) { if (current_output_channels > 2) { int small_len = 2 * len / current_output_channels; int i; Uint8 *src, *dst; i=ModPlug_Read(music->file, stream, small_len); if(i<small_len) { music->playing=0; } /* and extend to len by copying channels */ src = stream + small_len; dst = stream + len; switch (settings.mBits) { case 8: for ( i=small_len/2; i; --i ) { src -= 2; dst -= current_output_channels; dst[0] = src[0]; dst[1] = src[1]; dst[2] = src[0]; dst[3] = src[1]; if (current_output_channels == 6) { dst[4] = src[0]; dst[5] = src[1]; } } break; case 16: for ( i=small_len/4; i; --i ) { src -= 4; dst -= 2 * current_output_channels; dst[0] = src[0]; dst[1] = src[1]; dst[2] = src[2]; dst[3] = src[3]; dst[4] = src[0]; dst[5] = src[1]; dst[6] = src[2]; dst[7] = src[3]; if (current_output_channels == 6) { dst[8] = src[0]; dst[9] = src[1]; dst[10] = src[2]; dst[11] = src[3]; } } break; } } else { int i=ModPlug_Read(music->file, stream, len); if(i<len) { music->playing=0; } } if ( music_swap8 ) { Uint8 *dst; int i; dst = stream; for ( i=len; i; --i ) { *dst++ ^= 0x80; } } else if ( music_swap16 ) { Uint8 *dst, tmp; int i; dst = stream; for ( i=(len/2); i; --i ) { tmp = dst[0]; dst[0] = dst[1]; dst[1] = tmp; dst += 2; } } return 0; } /* Stop playback of a stream previously started with modplug_play() */ void modplug_stop(modplug_data *music) { music->playing=0; } /* Close the given modplug stream */ void modplug_delete(modplug_data *music) { ModPlug_Unload(music->file); SDL_free(music); } /* Jump (seek) to a given position (time is in seconds) */ void modplug_jump_to_time(modplug_data *music, double time) { ModPlug_Seek(music->file,(int)(time*1000)); } #endif
the_stack_data/15818.c
#include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.h> void free_binary_data(unsigned char *data); size_t binary_data_len(unsigned char *data); void * alloc_binary_data_memory(size_t size); static unsigned char encoding_table[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; static unsigned char decoding_table[256] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; unsigned char *hex_encode(const unsigned char *data, size_t input_length, size_t *output_length) { int i = 0, j = 0; *output_length = 2 * input_length; unsigned char *encoded_data = malloc(*output_length + 1); if (encoded_data == NULL) return NULL; memset(encoded_data, 0, (*output_length + 1)); for (i = 0, j = 0; i < input_length; i++) { encoded_data[j++] = encoding_table[((data[i] & 0xF0)>>4)]; encoded_data[j++] = encoding_table[(data[i] & 0x0F)]; } return encoded_data; } unsigned char *hex_decode(const unsigned char *data, size_t input_length, size_t *output_length) { int i = 0, j = 0; if (input_length % 2) { return NULL; } // There must be even number of bytes in a hex string *output_length = input_length / 2; unsigned char * decoded_data = alloc_binary_data_memory(*output_length); if (decoded_data == NULL) { return NULL; } unsigned char one = 0; unsigned char two = 0; for (i = 0, j = 0; i < *output_length; i++) { one = data[j++]; two = data[j++]; if (decoding_table[one] == 0xFF || decoding_table[two] == 0xFF) { free_binary_data(decoded_data); return NULL; } decoded_data[i] = (decoding_table[one] << 4) | (decoding_table[two]); } return (decoded_data); }
the_stack_data/3793.c
int main(void) { int a; &a+2; return 0; }
the_stack_data/705813.c
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #define doisNumeros typedef enum { erro, somar, subtrair, multiplicar, dividir } oper; int consisteNumero(char*); void executaOperacao(float*, int, oper, float*); int main(int argc, char *argv[]) { oper op = erro, i; char opers[][15] = { "somar", "subtrair", "multiplicar", "dividir" }; float *numeros, *p, resultado; #ifdef doisNumeros if (argc != 4) { printf("Metodo de uso: matematica.exe <Operacao> <Numero 1> <Numero 2>\nAs operacoes sao: somar, subtrair, multiplicar, dividir.\n"); return -2; } #else if (argc < 4) { printf("Metodo de uso: matematica.exe <Operacao> <Numero 1> <Numero 2> ... <Numero N>\nAs operacoes sao: somar, subtrair, multiplicar, dividir.\n"); return -2; } #endif for (i = 0; i < sizeof(opers) / sizeof(opers[i]); i++) { if (!strcmp(opers[i], argv[1])) { op = i + 1; break; } } if (!op) { printf("As operacoes disponiveis sao: somar, subtrair, multiplicar, dividir.\n"); return -2; } numeros = (float*) malloc((argc - 2) * sizeof(float)); if (!numeros) { printf("Erro de alocacao de memoria.\n"); return -1; } for (i = 2, p = numeros; i < argc; i++, p++) { if (!consisteNumero(argv[i])) { printf("O argumento %d precisa ser um numero.\n", i); return -2; } *p = atof(argv[i]); if (i > 2 && !*p && op == dividir) { printf("Impossivel dividir por zero.\n"); return 0; } } executaOperacao(numeros, argc - 2, op, &resultado); printf("%.5f\n", resultado); return 0; } int consisteNumero(char *numero) { int i; short int contaPonto = 0; char *p; for (i = 0, p = numero; i < strlen(numero); i++, p++) { if (!isdigit(*p) && *p != '-' && *p != '.') { return 0; } if (i == 0 && *p == '-' && *(p+1) == '\0') { return 0; } if (i > 1 && *p == '-') { return 0; } if (*p == '.' && contaPonto++) { return 0; } if (i == 0 || i == strlen(numero) - 1) { if (*p == '.') { return 0; } } else { if (*p == '.' && !isdigit(*(p-1)) && !isdigit(*(p+1))) { return 0; } } } return 1; } void executaOperacao(float *numeros, int tam, oper op, float *resultado) { int i; float *p; *resultado = *numeros; for (i = 1, p = numeros + 1; i < tam; i++, p++) { switch (op) { case somar: *resultado += *p; break; case subtrair: *resultado -= *p; break; case multiplicar: *resultado *= *p; break; case dividir: *resultado /= *p; break; default: break; } } return; }
the_stack_data/107953629.c
#include <stdio.h> #include <stdlib.h> /* TODAY WE ARE GOING TO TALK ABOUT ONE OF THE MOST IMPORATNT AND POWERFUL TOOL , 'WHILE LOOP'. WHILE LOOP IS USED FOR EXECUTING SAME CODE OVER AND OVER AGAIN , UNTIL CONDITION IN WHILE LOOP IS FALSE. SYNTAX WHILE(TEST){ STATEMENT ( EX , INCREMENTAL CONDITIONS ) } lets tack a look */ int main() { int a=0; while(a<5) { printf("A = %d\n",a); ++a; } // lets see if we can do some complex problems // suppose we making our money double every dAY AND WE WANT TO KNOW amount of money in certain period. int day =1; float money =5; // in rupees while(day<=30) { printf("On Day %d you may have %f /- Rupees\n",day,money); day++; money *= 2; // you may seen this sign in previous modules , if not it means that initial value its taken , multiply buy two // and generated new value } // if you don't know how to use while loop , you may have to write this statement 30 times , :) return 0; }
the_stack_data/45450.c
/* * Copyright (C) 2011 Florian Rathgeber, [email protected] * * This code is licensed under the MIT License. See the FindCUDA.cmake script * for the text of the license. * * Based on code by Christopher Bruns published on Stack Overflow (CC-BY): * http://stackoverflow.com/questions/2285185 */ #include <stdio.h> #include <cuda_runtime.h> int main() { int deviceCount, device, major = 9999, minor = 9999; int gpuDeviceCount = 0; struct cudaDeviceProp properties; if (cudaGetDeviceCount(&deviceCount) != cudaSuccess) { printf("Couldn't get device count: %s\n", cudaGetErrorString(cudaGetLastError())); return 1; } /* machines with no GPUs can still report one emulation device */ for (device = 0; device < deviceCount; ++device) { cudaGetDeviceProperties(&properties, device); if (properties.major != 9999) {/* 9999 means emulation only */ ++gpuDeviceCount; /* get minimum compute capability of all devices */ if (major > properties.major) { major = properties.major; minor = properties.minor; } else if ((major == properties.major) && (minor > properties.minor)) { minor = properties.minor; } } } /* don't just return the number of gpus, because other runtime cuda errors can also yield non-zero return values */ if (gpuDeviceCount > 0) { if ((major == 2 && minor == 1)) { // There is no --arch compute_21 flag for nvcc, so force minor to 0 minor = 0; } /* this output will be parsed by FindCUDA.cmake */ printf("%d%d", major, minor); return 0; /* success */ } return 1; /* failure */ }
the_stack_data/62316.c
/* APPLE LOCAL file */ /* Radar 4317709 */ /* { dg-do compile { target powerpc-*-darwin* } } */ /* { dg-options "-w" } */ #pragma reverse_bitfields on #pragma ms_struct on #pragma pack(1) typedef struct _bee { unsigned short cA : 8; unsigned short fB : 1; unsigned short fC : 1; unsigned short wVal : 9; } BEE; extern const BEE rgbee[100]; int LaLaFunction() { int foo = 1; int bar = 3; switch (foo) { case 200 : { if (rgbee[bar].wVal == 2) goto LNeverChange; break; } default: LNeverChange: bar = 0x23; break; } return 1; }
the_stack_data/122016652.c
#include <string.h> #include <stdint.h> void *memmove(void *dest, const void *src, size_t n) { uint8_t const* byte_src = (uint8_t const*)src; uint8_t* byte_dest = (uint8_t*)dest; if(dest < src) { while(n--) *byte_dest++ = *byte_src++; } else { byte_src += n; byte_dest += n; while(n--) *--byte_dest = *--byte_src; } return dest; }
the_stack_data/115765270.c
#include <stdio.h> main() { int c, nl = 0; while ((c = getchar()) != EOF) { if (c == '\n') ++nl; } printf("%d\n", nl); }
the_stack_data/92326849.c
#include <stdio.h> void substring(char [], char[], int, int); int main() { char string[1000], sub[1000]; int position, length, c = 0; printf("Input a string\n"); gets(string); printf("Enter the position and length of substring\n"); scanf("%d%d", &position, &length); substring(string, sub, position, length); printf("Required substring is \"%s\"\n", sub); return 0; } // C substring function definition void substring(char s[], char sub[], int p, int l) { int c = 0; while (c < l) { sub[c] = s[p+c-1]; c++; } sub[c] = '\0'; }
the_stack_data/82650.c
// // atoi.c // #include "stdlib.h" /// /// Converts a string of decimal digits into the corresponding /// integer value. /// /// No side effects. /// /// @see strtol() /// int atoi(const char *c) { int value = (int)strtol(c, NULL, 0); return(value); }
the_stack_data/762247.c
#include <stdio.h> #include <stdlib.h> void test() { void *p = malloc(7); printf("%p\n", p); } int main() { test(); return 0; }
the_stack_data/225142549.c
/* * Copyright (C) 2010 Gil Mendes * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /** * @file * @brief POSIX sleep function. */ #include <errno.h> #include <time.h> #include <unistd.h> /** Sleep for a certain interval. * @param secs Number of seconds to sleep for. * @return 0, or number of seconds remaining if interrupted. */ unsigned int sleep(unsigned int secs) { struct timespec ts; ts.tv_sec = secs; ts.tv_nsec = 0; if(nanosleep(&ts, &ts) == -1 && errno == EINTR) { return ts.tv_sec; } return 0; }
the_stack_data/1035253.c
/****************************************************************************** * * * License Agreement * * * * Copyright (c) 2004 Altera Corporation, San Jose, California, USA. * * All rights reserved. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the "Software"), * * to deal in the Software without restriction, including without limitation * * the rights to use, copy, modify, merge, publish, distribute, sublicense, * * and/or sell copies of the Software, and to permit persons to whom the * * Software is furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included in * * all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * * DEALINGS IN THE SOFTWARE. * * * * This agreement shall be governed in all respects by the laws of the State * * of California and by the laws of the United States of America. * * * * Altera does not recommend, suggest or require that this reference design * * file be used in conjunction or combination with any other product. * ******************************************************************************/ /****************************************************************************** * * * THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT IT DIRECTLY. * * * * Overriding HAL Functions * * * * To provide your own implementation of a HAL function, include the file in * * your Nios II IDE application project. When building the executable, the * * Nios II IDE finds your function first, and uses it in place of the HAL * * version. * * * ******************************************************************************/ /* * */ typedef void (*constructor) (void); extern constructor __CTOR_LIST__[]; extern constructor __CTOR_END__[]; /* * Run the C++ static constructors. */ void _do_ctors(void) { constructor* ctor; for (ctor = &__CTOR_END__[-1]; ctor >= __CTOR_LIST__; ctor--) (*ctor) (); }
the_stack_data/181393908.c
// RUN: %clang_cc1 -E -verify %s // expected-no-diagnostics #if 0 // Shouldn't get warnings here. ??( ??) // Should not get an error here. ` ` ` ` #endif
the_stack_data/164539.c
#include <stdio.h> #ifndef DEBUG #define Z(x) #define NDEBUG #else #define Z(x) printf x #endif #include <assert.h> #define MOD (998244353LL) struct { struct { long long add, mul, sum; int l, r; } N[10000009]; int n; int Nc; int ans; int vis[200009]; } S; int s_alc(void) { S.N[S.Nc].add = 0; S.N[S.Nc].mul = 1; S.N[S.Nc].sum = 0; S.N[S.Nc].l = 0; S.N[S.Nc].r = 0; return S.Nc++; } void s_ini(int n) { int i; S.Nc = 0; s_alc(); S.n = n; S.ans = s_alc(); for (i = 1; i <= n; ++i) S.vis[i] = s_alc(); } void s_pd(int rt, int l, int r) { if (l < r) { int m = l + (r - l) / 2; if (S.N[rt].l == 0) S.N[rt].l = s_alc(); if (S.N[rt].r == 0) S.N[rt].r = s_alc(); S.N[S.N[rt].l].mul = S.N[S.N[rt].l].mul * S.N[rt].mul % MOD; S.N[S.N[rt].l].add = S.N[S.N[rt].l].add * S.N[rt].mul % MOD; S.N[S.N[rt].l].sum = S.N[S.N[rt].l].sum * S.N[rt].mul % MOD; S.N[S.N[rt].r].mul = S.N[S.N[rt].r].mul * S.N[rt].mul % MOD; S.N[S.N[rt].r].add = S.N[S.N[rt].r].add * S.N[rt].mul % MOD; S.N[S.N[rt].r].sum = S.N[S.N[rt].r].sum * S.N[rt].mul % MOD; S.N[rt].mul = 1; S.N[S.N[rt].l].add = (S.N[S.N[rt].l].add + S.N[rt].add) % MOD; S.N[S.N[rt].l].sum = (S.N[S.N[rt].l].sum + S.N[rt].add * (m - l + 1) % MOD) % MOD; S.N[S.N[rt].r].add = (S.N[S.N[rt].r].add + S.N[rt].add) % MOD; S.N[S.N[rt].r].sum = (S.N[S.N[rt].r].sum + S.N[rt].add * (r - m) % MOD) % MOD; S.N[rt].add = 0; } } void s_mt(int rt, int l, int r) { if (l < r) S.N[rt].sum = (S.N[S.N[rt].l].sum + S.N[S.N[rt].r].sum) % MOD; } void s_add(int rt, int l, int r, int ll, int rr, long long x) { assert(rt != 0); s_pd(rt, l, r); Z(("%s: %d %d %d %d %d %lld\n", __func__, rt, l, r, ll, rr, x)); if (ll <= l && r <= rr) { S.N[rt].sum = (S.N[rt].sum + x * (r - l + 1) % MOD) % MOD; S.N[rt].add = (S.N[rt].add + x) % MOD; } else { int m = l + (r - l) / 2; if (ll <= m) s_add(S.N[rt].l, l, m, ll, rr, x); if (m < rr) s_add(S.N[rt].r, m + 1, r, ll, rr, x); s_mt(rt, l, r); } } void s_mul(int rt, int l, int r, int ll, int rr, long long x) { assert(rt != 0); s_pd(rt, l, r); Z(("%s: %d %d %d %d %d %lld\n", __func__, rt, l, r, ll, rr, x)); if (ll <= l && r <= rr) { Z(("hit\n")); S.N[rt].sum = S.N[rt].sum * x % MOD; S.N[rt].mul = S.N[rt].mul * x % MOD; } else { int m = l + (r - l) / 2; if (ll <= m) s_mul(S.N[rt].l, l, m, ll, rr, x); if (m < rr) s_mul(S.N[rt].r, m + 1, r, ll, rr, x); s_mt(rt, l, r); } } long long s_qry(int rt, int l, int r, int ll, int rr) { long long ans = 0; int m; assert(rt != 0); Z(("%s: %d %d %d %d %d\n", __func__, rt, l, r, ll, rr)); if (ll <= l && r <= rr) { Z(("hit: %lld\n", S.N[rt].sum)); return S.N[rt].sum; } s_pd(rt, l, r); m = l + (r - l) / 2; s_pd(rt, l, r); if (ll <= m) ans = s_qry(S.N[rt].l, l, m, ll, rr); if (m < rr) ans = (ans + s_qry(S.N[rt].r, m + 1, r, ll, rr)) % MOD; return ans; } void s_gao(int rt, int l, int r, int ll, int rr) { int m = l + (r - l) / 2; Z(("%s: %d %d %d %d %d\n", __func__, rt, l, r, ll, rr)); assert(rt != 0); s_pd(rt, l, r); if (ll <= l && r <= rr) { Z(("hit: %d %d\n", l, r)); if (S.N[rt].sum == r - l + 1) { Z(("all added\n")); s_mul(S.ans, 1, S.n, l, r, 2); } else if (S.N[rt].sum == 0) { Z(("no added\n")); s_add(S.ans, 1, S.n, l, r, 1); S.N[rt].sum = (S.N[rt].sum + (r - l + 1) % MOD) % MOD; S.N[rt].add = (S.N[rt].add + 1) % MOD; } else { Z(("process recursive\n")); s_gao(S.N[rt].l, l, m, ll, rr); s_gao(S.N[rt].r, m + 1, r, ll, rr); } } else { if (ll <= m) s_gao(S.N[rt].l, l, m, ll, rr); if (m < rr) s_gao(S.N[rt].r, m + 1, r, ll, rr); s_mt(rt, l, r); } } long long l_qry(int l, int r) { Z(("l_qry: %d %d\n", l, r)); return s_qry(S.ans, 1, S.n, l, r); } void l_add(int l, int r, int x) { Z(("l_add: %d %d %d\n", l, r, x)); s_gao(S.vis[x], 1, S.n, l, r); } int main(void) { int n, m; #ifdef DEBUG freopen("in", "r", stdin); setvbuf(stdout, NULL, _IONBF, 0); #endif scanf("%d%d", &n, &m); s_ini(n); while (m--) { int opt; scanf("%d", &opt); if (opt == 1) { int l, r, x; scanf("%d%d%d", &l, &r, &x); l_add(l, r, x); } else { int l, r; scanf("%d%d", &l, &r); printf("%lld\n", l_qry(l, r)); } } return 0; }
the_stack_data/782701.c
// RUN: clang-cc -emit-llvm -o - -triple i386-linux-gnu %s | FileCheck %s // This checks that the global won't be marked as common. // (It shouldn't because it's being initialized). int a; int a = 242; // CHECK: @a = global i32 242 // This should get normal weak linkage. int c __attribute__((weak))= 0; // CHECK: @c = weak global i32 0 // Since this is marked const, it should get weak_odr linkage, since all // definitions have to be the same. // CHECK: @d = weak_odr constant i32 0 const int d __attribute__((weak))= 0; // NOTE: tentative definitions are processed at the end of the translation unit. // This shouldn't be emitted as common because it has an explicit section. // rdar://7119244 int b __attribute__((section("foo"))); // CHECK: @b = global i32 0, section "foo"
the_stack_data/22011706.c
/* * Copyright (c) 2001-2003 The ffmpeg Project * * This file is part of FFmpeg. * * FFmpeg 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. * * FFmpeg 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 FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @file * ADPCM tables */ #include <stdint.h> /* ff_adpcm_step_table[] and ff_adpcm_index_table[] are from the ADPCM reference source */ /* This is the index table: */ const int8_t ff_adpcm_index_table[16] = { -1, -1, -1, -1, 2, 4, 6, 8, -1, -1, -1, -1, 2, 4, 6, 8, }; /** * This is the step table. Note that many programs use slight deviations from * this table, but such deviations are negligible: */ const int16_t ff_adpcm_step_table[89] = { 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, 130, 143, 157, 173, 190, 209, 230, 253, 279, 307, 337, 371, 408, 449, 494, 544, 598, 658, 724, 796, 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358, 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767 }; /* These are for MS-ADPCM */ /* ff_adpcm_AdaptationTable[], ff_adpcm_AdaptCoeff1[], and ff_adpcm_AdaptCoeff2[] are from libsndfile */ const int16_t ff_adpcm_AdaptationTable[] = { 230, 230, 230, 230, 307, 409, 512, 614, 768, 614, 512, 409, 307, 230, 230, 230 }; /** Divided by 4 to fit in 8-bit integers */ const uint8_t ff_adpcm_AdaptCoeff1[] = { 64, 128, 0, 48, 60, 115, 98 }; /** Divided by 4 to fit in 8-bit integers */ const int8_t ff_adpcm_AdaptCoeff2[] = { 0, -64, 0, 16, 0, -52, -58 }; const int16_t ff_adpcm_yamaha_indexscale[] = { 230, 230, 230, 230, 307, 409, 512, 614, 230, 230, 230, 230, 307, 409, 512, 614 }; const int8_t ff_adpcm_yamaha_difflookup[] = { 1, 3, 5, 7, 9, 11, 13, 15, -1, -3, -5, -7, -9, -11, -13, -15 };
the_stack_data/182952838.c
/*********************************************************************** Copyright (c) 1994 by Wesley Steiner o/a KW Software All rights reserved. ***********************************************************************/ /********************************************************************** Purpose: Comments: $Header: K:/lib/stdms.c_v 1.0 28 Jan 1995 10:32:30 WES $ $Log: K:/lib/stdms.c_v $ * * Rev 1.0 28 Jan 1995 10:32:30 WES * Initial revision. ***********************************************************************/
the_stack_data/15762324.c
#include <limits.h> #include <stdarg.h> #include <stdint.h> #include <stdio.h> #undef vsprintf int vsprintf(char * restrict s, const char * restrict fmt, va_list va) { return vsnprintf(s, SIZE_MAX, fmt, va); }
the_stack_data/1154864.c
#include <pthread.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/time.h> #define MILLION 1000000L int increment(); int getcount(int *thecount); static void *incthread(void *arg) { int num; int i; char c; num = *(int *)arg; fprintf(stderr,"incthread started: %d\n",num); for (i=0;i<num;i++) increment(); fprintf(stderr,"incthread done\n"); return NULL; } int main(int argc, char *argv[]) { pthread_t *tids; int final_count; int numthreads; int incsperthread; int i; if (argc != 3) { fprintf(stderr,"Usage: %s numthreads incsperthread\n",argv[0]); return 1; } numthreads = atoi(argv[1]); incsperthread = atoi(argv[2]); tids = (pthread_t *)malloc(numthreads*sizeof(pthread_t *)); if (tids == NULL) { fprintf(stderr,"Error allocating space for %d thread ids\n",numthreads); return 1; } long timedif; struct timeval tpend; struct timeval tpstart; if (gettimeofday(&tpstart, NULL)) { fprintf(stderr, "Failed to get start time\n"); return 1; } for (i=0;i<numthreads;i++) if (pthread_create(tids+i,NULL,incthread,&incsperthread)) { fprintf(stderr,"Error creating thread %d\n",i+1); return 1; } for (i=0;i<numthreads;i++) if (pthread_join(tids[i],NULL)) { fprintf(stderr,"Error joining thread %d\n",i+1); return 1; } if (gettimeofday(&tpend, NULL)) { fprintf(stderr, "Failed to get end time\n"); return 1; } timedif = MILLION*(tpend.tv_sec - tpstart.tv_sec) + tpend.tv_usec - tpstart.tv_usec; fprintf(stderr,"Count should be %d\n",numthreads*incsperthread); getcount(&final_count); fprintf(stderr,"Count is %d\n",final_count); printf("\nTime dif: %ld\n",timedif); return 0; }
the_stack_data/232652.c
#include <stdio.h> #include <stdlib.h> int main() { int n,i; scanf("%d", &n); int a[n]; for(i=0;i<n;i++) { scanf("%d", &a[i]); } for(i=n-1;i>=0;i--) { printf("\n %d", a[i]); } return 0; }
the_stack_data/986212.c
typedef short JCOEF; typedef JCOEF JBLOCK[64]; typedef JCOEF *JCOEFPTR; typedef int DCTELEM; #pragma hmpp astex_codelet__13 codelet & #pragma hmpp astex_codelet__13 , args[workspace].io=in & #pragma hmpp astex_codelet__13 , args[divisors].io=in & #pragma hmpp astex_codelet__13 , args[output_ptr].io=inout & #pragma hmpp astex_codelet__13 , target=C & #pragma hmpp astex_codelet__13 , version=1.4.0 void astex_codelet__13(JCOEFPTR output_ptr, DCTELEM *divisors, DCTELEM workspace[64]) { int i; DCTELEM qval; DCTELEM temp; astex_thread_begin: { for (i = 0 ; i < 64 ; i++) { qval = divisors[i]; temp = workspace[i]; if (temp < 0) { temp = -temp; temp += qval >> 1; if (temp >= qval) temp /= qval; else temp = 0; temp = -temp; } else { temp += qval >> 1; if (temp >= qval) temp /= qval; else temp = 0; } output_ptr[i] = (JCOEF ) temp; } } astex_thread_end:; }
the_stack_data/54682.c
/*Exercise 4 - Functions Implement the three functions minimum(), maximum() and multiply() below the main() function. Do not change the code given in the main() function when you are implementing your solution.*/ #include <stdio.h> int min (int no1, int no2); int max (int no1, int no2); int mul (int no1, int no2); int main() { int no1, no2; printf("Enter a value for no 1 : "); scanf("%d", &no1); printf("Enter a value for no 2 : "); scanf("%d", &no2); printf("%d ", minimum(no1, no2)); printf("%d ", maximum(no1, no2)); printf("%d ", multiply(no1, no2)); return 0; } int minimum (int no1, int no2, int min){ if(no1 > no2){ min = no2; return min; } } int maximum (int no1, int no2, int max){ if(no1 > no2){ max = no1; return max; } else{ max = no2; return max; } } int multiply (int no1, int no2, int mul){ mul = no1 * no2; return mul; }
the_stack_data/176705174.c
#include <stdio.h> int isPrime(int n){ int limit = (int)sqrt(n); int i; for(i = 2; i <= limit; i++){ if(n % i == 0){ return 0; } } return 1; } int main(){ int n; scanf("%d", &n); int i; if(n == 2){ n = 1; } for(i = n + 2; i < 110000; i++){ if(isPrime(i)){ printf("%d", i); return 0; } } }
the_stack_data/848067.c
#include <stdio.h> #include <stdlib.h> #include <sys/inotify.h> #include <limits.h> #include <string.h> #include <unistd.h> #include <time.h> #define handle_error(msg) \ do { perror(msg); exit(EXIT_FAILURE); } while(0) int main(int argc, char *argv[]) { time_t datetime; struct tm *lt; char buffer[1000]; datetime=time(NULL); if(!datetime) { handle_error("time"); } lt = localtime(&datetime); strftime(buffer, 1000, "%R %A %e %B", lt); printf("The time returned by ctime is %s\n", ctime(&datetime)); printf("The time returned by localtime is %s\n", buffer); return EXIT_SUCCESS; }
the_stack_data/218893058.c
const unsigned char image_Sysinit_0000s_0000_L1[875] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xef, 0xff, 0xff, 0xff, 0xf5, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0xad, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x7b, 0xef, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x59, 0xdf, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x37, 0xbe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; const unsigned char image_Sysinit_0000s_0001_L2[875] = { 0xc7, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xea, 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xfc, 0x83, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xa6, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xd8, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfb, 0x62, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0x94, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc7, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xea, 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xa5, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xd8, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfb, 0x62, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0x94, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0x2f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf4, 0x9d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x02, 0x6b, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x48, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0xae, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x8c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x5a, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x37, 0xcf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x9d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x6b, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x26, 0xaf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x8c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x5a, 0xef, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x37, 0xcf, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0x9e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; const unsigned char image_Sysinit_0001s_0000_R1[875] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x4f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x6f, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x25, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xa5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xeb, 0x74, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xd9, 0x52, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xb7, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; const unsigned char image_Sysinit_0001s_0001_R2[875] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0xae, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0xcf, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x6a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x8d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x26, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x7c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0xae, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x37, 0xcf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x5a, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x8d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x26, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x49, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf2, 0x7b, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xd9, 0x4f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb6, 0x20, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0x84, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xea, 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc8, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xa5, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xd9, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb6, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfa, 0x62, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc8, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xfe, 0xa5, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xfc, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe9, 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
the_stack_data/941012.c
#include <stdlib.h> #include <stdio.h> #include <semaphore.h> #include <pthread.h> #define TRUE 1 #define FALSE 0 #define TMAX 64L struct _primelist { long prime; struct _primelist *next; }; typedef struct _primelist primelist; primelist *head=NULL, *tail=NULL; struct _thdata { pthread_t th; long n0; long n1; primelist *head; primelist *tail; }; typedef struct _thdata thdata; thdata thd[TMAX]; int checkprime(long n) { primelist *p; long i, n_div_i, n_mod_i; int flag; flag = TRUE; p = head; while(p) { i = p->prime; n_div_i = n / i; n_mod_i = n % i; if (n_mod_i == 0) { flag = FALSE; break; /* found not to be prime */ } if (n_div_i < i) { break; /* no use doing more i-loop if n < i*i */ } p = p->next; } return flag; } void subthread(thdata *thd) { long i; primelist *p=NULL, *q=NULL; thd->head = NULL; for (i = thd->n0; i <= thd->n1; i++) { #ifdef DEBUG printf ("I: LOOPING inner AA i=%li, n0=%li, n1=%li\n", i, thd->n0, thd->n1); #endif if (checkprime(i)) { #ifdef DEBUG printf ("I: LOOPING inner CC i=%li, n0=%li, n1=%li\n", i, thd->n0, thd->n1); #endif q = calloc(1, sizeof(primelist)); q->prime = i; if (!thd->head) { thd->head = q; p = q; } else { p->next = q; p = q; } thd->tail = q; #ifdef DEBUG printf ("I: LOOPING inner ZZ i=%li, n0=%li, n1=%li\n", i, thd->n0, thd->n1); #endif } } } int main(int argc, char **argv) { primelist *p=NULL, *q=NULL; long n, n_max, i, nd; n_max = atol(argv[1]); head = calloc(1, sizeof(primelist)); tail = head; tail->prime = 2; n = 2; while((n - 1) * (n - 1) <= n_max) { n++; if (checkprime(n)) { q= calloc(1, sizeof(primelist)); tail->next = q; tail = q; tail->prime = n; } } nd = (n_max - n ) / (long) TMAX + 1L; for (i=0; i < TMAX; i++) { /* TMAX thread of checkprime loop */ thd[i].n0 = n; thd[i].n1 = n + nd; if (thd[i].n1 >= n_max) { thd[i].n1 = n_max; } n = thd[i].n1; #ifdef DEBUG printf ("I: LOOPING outer i=%li, n0=%li n1=%li\n", i, thd[i].n0, thd[i].n1); #endif if (pthread_create(&thd[i].th, NULL, (void *) subthread, (void *) &(thd[i]) ) ) { printf ("E: error creating thread at %li\n", i); } } for (i=0; i < TMAX; i++) { /* TMAX thread of checkprime loop */ if (pthread_join(thd[i].th, (void *) NULL) ) { printf ("E: error joining thread at %li\n", i); } #ifdef DEBUG printf ("I: LOOPING join i=%li\n", i); #endif tail->next = thd[i].head; tail = thd[i].tail; } p=head; while(p) { printf ("%ld\n", p->prime); p = p->next; } p=head; while(p) { q = p->next; free(p); p = q; } return EXIT_SUCCESS; }
the_stack_data/134971.c
/* insert_string_acle.c -- insert_string variant using ACLE's CRC instructions * * Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h * */ #if defined(__ARM_FEATURE_CRC32) && defined(ARM_ACLE_CRC_HASH) #include <arm_acle.h> #include "zbuild.h" #include "deflate.h" /* =========================================================================== * Insert string str in the dictionary and set match_head to the previous head * of the hash chain (the most recent string with same hash key). Return * the previous length of the hash chain. * IN assertion: all calls to to INSERT_STRING are made with consecutive * input characters and the first MIN_MATCH bytes of str are valid * (except for the last MIN_MATCH-1 bytes of the input file). */ Pos insert_string_acle(deflate_state *const s, const Pos str, unsigned int count) { Pos p, lp, ret; if (unlikely(count == 0)) { return s->prev[str & s->w_mask]; } ret = 0; lp = str + count - 1; /* last position */ for (p = str; p <= lp; p++) { uint32_t val, h, hm; memcpy(&val, &s->window[p], sizeof(val)); if (s->level >= TRIGGER_LEVEL) val &= 0xFFFFFF; h = __crc32w(0, val); hm = h & s->hash_mask; Pos head = s->head[hm]; if (head != p) { s->prev[p & s->w_mask] = head; s->head[hm] = p; if (p == lp) ret = head; } else if (p == lp) { ret = p; } } return ret; } #endif
the_stack_data/93482.c
/* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END * $FreeBSD$ */ /* * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #pragma ident "@(#)mmap_exec.c 1.3 07/05/25 SMI" #include <stdio.h> #include <sys/stat.h> #include <fcntl.h> #include <sys/types.h> #include <sys/mman.h> #include <errno.h> extern int errno; int main(int argc, char *argv[]) { int fd; struct stat statbuf; if (argc != 2) { (void) printf("Error: missing binary name.\n"); (void) printf("Usage:\n\t%s <binary name>\n", argv[0]); return (1); } errno = 0; if ((fd = open(argv[1], O_RDONLY)) < 0) { perror("open"); return (errno); } if (fstat(fd, &statbuf) < 0) { perror("fstat"); return (errno); } if (mmap(0, statbuf.st_size, PROT_EXEC, MAP_SHARED, fd, 0) == MAP_FAILED) { perror("mmap"); return (errno); } return (0); }
the_stack_data/590448.c
#include <stdio.h> int main(void) { int t,n,k,r,i,j; scanf("%d",&t); while(t--){ scanf("%d",&k); r=64-k; for(i=1;i<=8;i++){ for(j=1;j<=8;j++){ if(i==8&&j==8) {printf("O");} else if(r) {printf("X");r--;} else { printf(".");} } printf("\n"); } } return 0; }
the_stack_data/14200233.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strcapitalize.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: kkozlov <[email protected]> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2018/10/29 20:49:58 by kkozlov #+# #+# */ /* Updated: 2018/10/30 12:58:24 by kkozlov ### ########.fr */ /* */ /* ************************************************************************** */ int is_alpha(char c) { if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) return (1); return (0); } int is_lowcase(char c) { if (c >= 'a' && c <= 'z') return (1); return (0); } void to_upper(char *pc) { if (is_lowcase(*pc)) *pc = *pc + ('A' - 'a'); } void to_lower(char *pc) { if (*pc >= 'A' && *pc <= 'Z') *pc = *pc - ('A' - 'a'); } char *ft_strcapitalize(char *str) { char *pbeg; pbeg = str; if (is_alpha(*str)) if (is_lowcase(*str++)) to_upper(str - 1); while (*str) { if (!is_alpha(*str) && (*str < '0' || *str > '9')) { ++str; if (is_alpha(*str)) if (is_lowcase(*str++)) to_upper(str - 1); continue; } else if (*str >= 'A' && *str <= 'Z') to_lower(str); ++str; } return (pbeg); }
the_stack_data/136422.c
#include <stdio.h> #include <stdlib.h> // incerting a node // inorder traversal //defining the Node structure struct Node{ int data ; struct Node *left, *right; }; //returns a pointer to new Node struct Node* getNewNode(int data){ struct Node* temp = (struct Node*)malloc(sizeof(struct Node)); temp -> data = data; temp -> left = temp -> right = NULL; return temp; } // incerts at the required position as per the binery search tree struct Node* incert(struct Node* root, int data){ if(root == NULL){ root = getNewNode(data); } else if( root <= data){ root->left = incert(root->left, data); } else{ root -> right = incert(root -> right, data); } return root; } void print(struct Node* root){ // printing inorder if(root == NULL) return; print(root->left); printf("%d\t",root->data); print(root->right); } int main(){ struct Node* root = NULL; root = incert(root, 5); root = incert(root, 2); root = incert(root, 8); print(root); }
the_stack_data/111364.c
/* ヘッダファイルのインクルード */ #include <stdio.h> /* 標準入出力(ファイル入出力も含む.) */ /* main関数の定義 */ int main(void){ /* 変数・配列・ポインタの宣言 */ char name[32]; /* test.txtから読み込んだ名前を格納するchar型配列name. */ int age; /* test.txtから読み込んだ年齢を格納するint型変数age. */ char address[128]; /* test.txtから読み込んだ住所を格納するchar型配列address. */ FILE *fp; /* ファイルポインタfp */ /* ファイルtest.txtを開く. */ fp = fopen("test.txt", "r"); /* fopenで"test.txt"というファイルを読込専用("r")で開く. */ if (fp == NULL){ /* fp == NULLならファイルを開くのに失敗. */ /* エラー処理 */ printf("Can't open file!\n"); /* ファイルが開けない場合のエラーメッセージ. */ return -1; /* 異常終了 */ } /* ファイルからの読み込み */ fscanf(fp, "%s %d %s", name, &age, address); /* fscanfで"test.txt"から読み込んだ内容をname, age, addressに格納する. */ /* 読み込んだname, age, addressの出力 */ printf("name: %s\n", name); /* printfでnameを出力. */ printf("age: %d\n", age); /* printfでageを出力. */ printf("address: %s\n", address); /* printfでaddressを出力. */ /* ファイルを閉じる. */ fclose(fp); /* fcloseで"test.txt"を閉じる. */ /* プログラムの終了 */ return 0; /* 正常終了 */ }
the_stack_data/103265300.c
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <string.h> static int dfs(int** triangle, int row_size, int *col_sizes, int row, int col, int **sums, bool **passes) { if (row == row_size - 1) { return triangle[row][col]; } else if (passes[row][col]) { return sums[row][col]; } else { int s1 = dfs(triangle, row_size, col_sizes, row + 1, col, sums, passes); int s2 = dfs(triangle, row_size, col_sizes, row + 1, col + 1, sums, passes); sums[row][col] = triangle[row][col] + (s1 < s2 ? s1 : s2); /* Set pass marks in backtracing as the paths are overlapped */ passes[row][col] = true; return sums[row][col]; } } static int minimumTotal(int** triangle, int triangleSize, int *triangleColSizes) { int i; int **sums = malloc(triangleSize * sizeof(int *)); bool **passes = malloc(triangleSize * sizeof(bool *)); for (i = 0; i < triangleSize; i++) { passes[i] = malloc(triangleColSizes[i]); memset(passes[i], false, triangleColSizes[i]); sums[i] = malloc(triangleColSizes[i] * sizeof(int)); } return dfs(triangle, triangleSize, triangleColSizes, 0, 0, sums, passes); } int main(void) { int i, row = 4; int **nums = malloc(row * sizeof(int *)); int *sizes = malloc(row * sizeof(int)); for (i = 0; i < row; i++) { sizes[i] = i + 1; nums[i] = malloc(sizes[i] * sizeof(int)); } #if 0 nums[0][0] = -1; nums[1][0] = 3; nums[1][1] = 2; nums[2][0] = -3; nums[2][1] = 1; nums[2][2] = -1; #else nums[0][0] = 2; nums[1][0] = 3; nums[1][1] = 4; nums[2][0] = 6; nums[2][1] = 5; nums[2][2] = 7; nums[3][0] = 4; nums[3][1] = 1; nums[3][2] = 8; nums[3][3] = 3; #endif printf("%d\n", minimumTotal(nums, row, sizes)); return 0; }
the_stack_data/57859.c
extern void __VERIFIER_error() __attribute__ ((__noreturn__)); void __VERIFIER_assert(int expression) { if (!expression) { ERROR: /* assert not proved */ __VERIFIER_error(); }; return; } int __global_lock; void __VERIFIER_atomic_begin() { /* reachable */ /* reachable */ /* reachable */ /* reachable */ /* reachable */ /* reachable */ /* reachable */ __VERIFIER_assume(__global_lock==0); __global_lock=1; return; } void __VERIFIER_atomic_end() { __VERIFIER_assume(__global_lock==1); __global_lock=0; return; } #include <assert.h> #include <pthread.h> #ifndef TRUE #define TRUE (_Bool)1 #endif #ifndef FALSE #define FALSE (_Bool)0 #endif #ifndef NULL #define NULL ((void*)0) #endif #ifndef FENCE #define FENCE(x) ((void)0) #endif #ifndef IEEE_FLOAT_EQUAL #define IEEE_FLOAT_EQUAL(x,y) (x==y) #endif #ifndef IEEE_FLOAT_NOTEQUAL #define IEEE_FLOAT_NOTEQUAL(x,y) (x!=y) #endif void * P0(void *arg); void * P1(void *arg); void * P2(void *arg); void fence(); void isync(); void lwfence(); int __unbuffered_cnt; int __unbuffered_cnt = 0; int __unbuffered_p0_EAX; int __unbuffered_p0_EAX = 0; int __unbuffered_p2_EAX; int __unbuffered_p2_EAX = 0; _Bool __unbuffered_p2_EAX$flush_delayed; int __unbuffered_p2_EAX$mem_tmp; _Bool __unbuffered_p2_EAX$r_buff0_thd0; _Bool __unbuffered_p2_EAX$r_buff0_thd1; _Bool __unbuffered_p2_EAX$r_buff0_thd2; _Bool __unbuffered_p2_EAX$r_buff0_thd3; _Bool __unbuffered_p2_EAX$r_buff1_thd0; _Bool __unbuffered_p2_EAX$r_buff1_thd1; _Bool __unbuffered_p2_EAX$r_buff1_thd2; _Bool __unbuffered_p2_EAX$r_buff1_thd3; _Bool __unbuffered_p2_EAX$read_delayed; int *__unbuffered_p2_EAX$read_delayed_var; int __unbuffered_p2_EAX$w_buff0; _Bool __unbuffered_p2_EAX$w_buff0_used; int __unbuffered_p2_EAX$w_buff1; _Bool __unbuffered_p2_EAX$w_buff1_used; _Bool main$tmp_guard0; _Bool main$tmp_guard1; int x; int x = 0; _Bool x$flush_delayed; int x$mem_tmp; _Bool x$r_buff0_thd0; _Bool x$r_buff0_thd1; _Bool x$r_buff0_thd2; _Bool x$r_buff0_thd3; _Bool x$r_buff1_thd0; _Bool x$r_buff1_thd1; _Bool x$r_buff1_thd2; _Bool x$r_buff1_thd3; _Bool x$read_delayed; int *x$read_delayed_var; int x$w_buff0; _Bool x$w_buff0_used; int x$w_buff1; _Bool x$w_buff1_used; int y; int y = 0; _Bool weak$$choice0; _Bool weak$$choice1; _Bool weak$$choice2; void * P0(void *arg) { __VERIFIER_atomic_begin(); y = 2; __VERIFIER_atomic_end(); __VERIFIER_atomic_begin(); __VERIFIER_atomic_end(); __VERIFIER_atomic_begin(); weak$$choice0 = nondet_0(); weak$$choice2 = nondet_0(); x$flush_delayed = weak$$choice2; x$mem_tmp = x; x = !x$w_buff0_used || !x$r_buff0_thd1 && !x$w_buff1_used || !x$r_buff0_thd1 && !x$r_buff1_thd1 ? x : (x$w_buff0_used && x$r_buff0_thd1 ? x$w_buff0 : x$w_buff1); x$w_buff0 = weak$$choice2 ? x$w_buff0 : (!x$w_buff0_used || !x$r_buff0_thd1 && !x$w_buff1_used || !x$r_buff0_thd1 && !x$r_buff1_thd1 ? x$w_buff0 : (x$w_buff0_used && x$r_buff0_thd1 ? x$w_buff0 : x$w_buff0)); x$w_buff1 = weak$$choice2 ? x$w_buff1 : (!x$w_buff0_used || !x$r_buff0_thd1 && !x$w_buff1_used || !x$r_buff0_thd1 && !x$r_buff1_thd1 ? x$w_buff1 : (x$w_buff0_used && x$r_buff0_thd1 ? x$w_buff1 : x$w_buff1)); x$w_buff0_used = weak$$choice2 ? x$w_buff0_used : (!x$w_buff0_used || !x$r_buff0_thd1 && !x$w_buff1_used || !x$r_buff0_thd1 && !x$r_buff1_thd1 ? x$w_buff0_used : (x$w_buff0_used && x$r_buff0_thd1 ? FALSE : x$w_buff0_used)); x$w_buff1_used = weak$$choice2 ? x$w_buff1_used : (!x$w_buff0_used || !x$r_buff0_thd1 && !x$w_buff1_used || !x$r_buff0_thd1 && !x$r_buff1_thd1 ? x$w_buff1_used : (x$w_buff0_used && x$r_buff0_thd1 ? FALSE : FALSE)); x$r_buff0_thd1 = weak$$choice2 ? x$r_buff0_thd1 : (!x$w_buff0_used || !x$r_buff0_thd1 && !x$w_buff1_used || !x$r_buff0_thd1 && !x$r_buff1_thd1 ? x$r_buff0_thd1 : (x$w_buff0_used && x$r_buff0_thd1 ? FALSE : x$r_buff0_thd1)); x$r_buff1_thd1 = weak$$choice2 ? x$r_buff1_thd1 : (!x$w_buff0_used || !x$r_buff0_thd1 && !x$w_buff1_used || !x$r_buff0_thd1 && !x$r_buff1_thd1 ? x$r_buff1_thd1 : (x$w_buff0_used && x$r_buff0_thd1 ? FALSE : FALSE)); __unbuffered_p0_EAX = x; x = x$flush_delayed ? x$mem_tmp : x; x$flush_delayed = FALSE; __VERIFIER_atomic_end(); __VERIFIER_atomic_begin(); __VERIFIER_atomic_end(); __VERIFIER_atomic_begin(); __unbuffered_cnt = __unbuffered_cnt + 1; __VERIFIER_atomic_end(); return nondet_1(); } void * P1(void *arg) { __VERIFIER_atomic_begin(); x = 1; __VERIFIER_atomic_end(); __VERIFIER_atomic_begin(); x = 2; __VERIFIER_atomic_end(); __VERIFIER_atomic_begin(); x = x$w_buff0_used && x$r_buff0_thd2 ? x$w_buff0 : (x$w_buff1_used && x$r_buff1_thd2 ? x$w_buff1 : x); x$w_buff0_used = x$w_buff0_used && x$r_buff0_thd2 ? FALSE : x$w_buff0_used; x$w_buff1_used = x$w_buff0_used && x$r_buff0_thd2 || x$w_buff1_used && x$r_buff1_thd2 ? FALSE : x$w_buff1_used; x$r_buff0_thd2 = x$w_buff0_used && x$r_buff0_thd2 ? FALSE : x$r_buff0_thd2; x$r_buff1_thd2 = x$w_buff0_used && x$r_buff0_thd2 || x$w_buff1_used && x$r_buff1_thd2 ? FALSE : x$r_buff1_thd2; __VERIFIER_atomic_end(); __VERIFIER_atomic_begin(); __unbuffered_cnt = __unbuffered_cnt + 1; __VERIFIER_atomic_end(); return nondet_1(); } void * P2(void *arg) { __VERIFIER_atomic_begin(); weak$$choice0 = nondet_0(); weak$$choice2 = nondet_0(); x$flush_delayed = weak$$choice2; x$mem_tmp = x; x = !x$w_buff0_used || !x$r_buff0_thd3 && !x$w_buff1_used || !x$r_buff0_thd3 && !x$r_buff1_thd3 ? x : (x$w_buff0_used && x$r_buff0_thd3 ? x$w_buff0 : x$w_buff1); x$w_buff0 = weak$$choice2 ? x$w_buff0 : (!x$w_buff0_used || !x$r_buff0_thd3 && !x$w_buff1_used || !x$r_buff0_thd3 && !x$r_buff1_thd3 ? x$w_buff0 : (x$w_buff0_used && x$r_buff0_thd3 ? x$w_buff0 : x$w_buff0)); x$w_buff1 = weak$$choice2 ? x$w_buff1 : (!x$w_buff0_used || !x$r_buff0_thd3 && !x$w_buff1_used || !x$r_buff0_thd3 && !x$r_buff1_thd3 ? x$w_buff1 : (x$w_buff0_used && x$r_buff0_thd3 ? x$w_buff1 : x$w_buff1)); x$w_buff0_used = weak$$choice2 ? x$w_buff0_used : (!x$w_buff0_used || !x$r_buff0_thd3 && !x$w_buff1_used || !x$r_buff0_thd3 && !x$r_buff1_thd3 ? x$w_buff0_used : (x$w_buff0_used && x$r_buff0_thd3 ? FALSE : x$w_buff0_used)); x$w_buff1_used = weak$$choice2 ? x$w_buff1_used : (!x$w_buff0_used || !x$r_buff0_thd3 && !x$w_buff1_used || !x$r_buff0_thd3 && !x$r_buff1_thd3 ? x$w_buff1_used : (x$w_buff0_used && x$r_buff0_thd3 ? FALSE : FALSE)); x$r_buff0_thd3 = weak$$choice2 ? x$r_buff0_thd3 : (!x$w_buff0_used || !x$r_buff0_thd3 && !x$w_buff1_used || !x$r_buff0_thd3 && !x$r_buff1_thd3 ? x$r_buff0_thd3 : (x$w_buff0_used && x$r_buff0_thd3 ? FALSE : x$r_buff0_thd3)); x$r_buff1_thd3 = weak$$choice2 ? x$r_buff1_thd3 : (!x$w_buff0_used || !x$r_buff0_thd3 && !x$w_buff1_used || !x$r_buff0_thd3 && !x$r_buff1_thd3 ? x$r_buff1_thd3 : (x$w_buff0_used && x$r_buff0_thd3 ? FALSE : FALSE)); __unbuffered_p2_EAX$read_delayed = TRUE; __unbuffered_p2_EAX$read_delayed_var = &x; __unbuffered_p2_EAX = x; x = x$flush_delayed ? x$mem_tmp : x; x$flush_delayed = FALSE; __VERIFIER_atomic_end(); __VERIFIER_atomic_begin(); y = 1; __VERIFIER_atomic_end(); __VERIFIER_atomic_begin(); x = x$w_buff0_used && x$r_buff0_thd3 ? x$w_buff0 : (x$w_buff1_used && x$r_buff1_thd3 ? x$w_buff1 : x); x$w_buff0_used = x$w_buff0_used && x$r_buff0_thd3 ? FALSE : x$w_buff0_used; x$w_buff1_used = x$w_buff0_used && x$r_buff0_thd3 || x$w_buff1_used && x$r_buff1_thd3 ? FALSE : x$w_buff1_used; x$r_buff0_thd3 = x$w_buff0_used && x$r_buff0_thd3 ? FALSE : x$r_buff0_thd3; x$r_buff1_thd3 = x$w_buff0_used && x$r_buff0_thd3 || x$w_buff1_used && x$r_buff1_thd3 ? FALSE : x$r_buff1_thd3; __VERIFIER_atomic_end(); __VERIFIER_atomic_begin(); __unbuffered_cnt = __unbuffered_cnt + 1; __VERIFIER_atomic_end(); return nondet_1(); } void fence() { } void isync() { } void lwfence() { } int main() { pthread_create(NULL, NULL, P0, NULL); pthread_create(NULL, NULL, P1, NULL); pthread_create(NULL, NULL, P2, NULL); __VERIFIER_atomic_begin(); main$tmp_guard0 = __unbuffered_cnt == 3; __VERIFIER_atomic_end(); __VERIFIER_assume(main$tmp_guard0); __VERIFIER_atomic_begin(); x = x$w_buff0_used && x$r_buff0_thd0 ? x$w_buff0 : (x$w_buff1_used && x$r_buff1_thd0 ? x$w_buff1 : x); x$w_buff0_used = x$w_buff0_used && x$r_buff0_thd0 ? FALSE : x$w_buff0_used; x$w_buff1_used = x$w_buff0_used && x$r_buff0_thd0 || x$w_buff1_used && x$r_buff1_thd0 ? FALSE : x$w_buff1_used; x$r_buff0_thd0 = x$w_buff0_used && x$r_buff0_thd0 ? FALSE : x$r_buff0_thd0; x$r_buff1_thd0 = x$w_buff0_used && x$r_buff0_thd0 || x$w_buff1_used && x$r_buff1_thd0 ? FALSE : x$r_buff1_thd0; __VERIFIER_atomic_end(); __VERIFIER_atomic_begin(); /* Program was expected to be safe for X86, model checker should have said NO. This likely is a bug in the tool chain. */ weak$$choice0 = nondet_0(); /* Program was expected to be safe for X86, model checker should have said NO. This likely is a bug in the tool chain. */ weak$$choice2 = nondet_0(); /* Program was expected to be safe for X86, model checker should have said NO. This likely is a bug in the tool chain. */ x$flush_delayed = weak$$choice2; /* Program was expected to be safe for X86, model checker should have said NO. This likely is a bug in the tool chain. */ x$mem_tmp = x; /* Program was expected to be safe for X86, model checker should have said NO. This likely is a bug in the tool chain. */ x = !x$w_buff0_used || !x$r_buff0_thd0 && !x$w_buff1_used || !x$r_buff0_thd0 && !x$r_buff1_thd0 ? x : (x$w_buff0_used && x$r_buff0_thd0 ? x$w_buff0 : x$w_buff1); /* Program was expected to be safe for X86, model checker should have said NO. This likely is a bug in the tool chain. */ x$w_buff0 = weak$$choice2 ? x$w_buff0 : (!x$w_buff0_used || !x$r_buff0_thd0 && !x$w_buff1_used || !x$r_buff0_thd0 && !x$r_buff1_thd0 ? x$w_buff0 : (x$w_buff0_used && x$r_buff0_thd0 ? x$w_buff0 : x$w_buff0)); /* Program was expected to be safe for X86, model checker should have said NO. This likely is a bug in the tool chain. */ x$w_buff1 = weak$$choice2 ? x$w_buff1 : (!x$w_buff0_used || !x$r_buff0_thd0 && !x$w_buff1_used || !x$r_buff0_thd0 && !x$r_buff1_thd0 ? x$w_buff1 : (x$w_buff0_used && x$r_buff0_thd0 ? x$w_buff1 : x$w_buff1)); /* Program was expected to be safe for X86, model checker should have said NO. This likely is a bug in the tool chain. */ x$w_buff0_used = weak$$choice2 ? x$w_buff0_used : (!x$w_buff0_used || !x$r_buff0_thd0 && !x$w_buff1_used || !x$r_buff0_thd0 && !x$r_buff1_thd0 ? x$w_buff0_used : (x$w_buff0_used && x$r_buff0_thd0 ? FALSE : x$w_buff0_used)); /* Program was expected to be safe for X86, model checker should have said NO. This likely is a bug in the tool chain. */ x$w_buff1_used = weak$$choice2 ? x$w_buff1_used : (!x$w_buff0_used || !x$r_buff0_thd0 && !x$w_buff1_used || !x$r_buff0_thd0 && !x$r_buff1_thd0 ? x$w_buff1_used : (x$w_buff0_used && x$r_buff0_thd0 ? FALSE : FALSE)); /* Program was expected to be safe for X86, model checker should have said NO. This likely is a bug in the tool chain. */ x$r_buff0_thd0 = weak$$choice2 ? x$r_buff0_thd0 : (!x$w_buff0_used || !x$r_buff0_thd0 && !x$w_buff1_used || !x$r_buff0_thd0 && !x$r_buff1_thd0 ? x$r_buff0_thd0 : (x$w_buff0_used && x$r_buff0_thd0 ? FALSE : x$r_buff0_thd0)); /* Program was expected to be safe for X86, model checker should have said NO. This likely is a bug in the tool chain. */ x$r_buff1_thd0 = weak$$choice2 ? x$r_buff1_thd0 : (!x$w_buff0_used || !x$r_buff0_thd0 && !x$w_buff1_used || !x$r_buff0_thd0 && !x$r_buff1_thd0 ? x$r_buff1_thd0 : (x$w_buff0_used && x$r_buff0_thd0 ? FALSE : FALSE)); /* Program was expected to be safe for X86, model checker should have said NO. This likely is a bug in the tool chain. */ weak$$choice1 = nondet_0(); /* Program was expected to be safe for X86, model checker should have said NO. This likely is a bug in the tool chain. */ __unbuffered_p2_EAX = __unbuffered_p2_EAX$read_delayed ? (weak$$choice1 ? *__unbuffered_p2_EAX$read_delayed_var : __unbuffered_p2_EAX) : __unbuffered_p2_EAX; /* Program was expected to be safe for X86, model checker should have said NO. This likely is a bug in the tool chain. */ main$tmp_guard1 = !(x == 2 && y == 2 && __unbuffered_p0_EAX == 0 && __unbuffered_p2_EAX == 2); /* Program was expected to be safe for X86, model checker should have said NO. This likely is a bug in the tool chain. */ x = x$flush_delayed ? x$mem_tmp : x; /* Program was expected to be safe for X86, model checker should have said NO. This likely is a bug in the tool chain. */ x$flush_delayed = FALSE; __VERIFIER_atomic_end(); /* Program was expected to be safe for X86, model checker should have said NO. This likely is a bug in the tool chain. */ __VERIFIER_assert(main$tmp_guard1); /* reachable */ return 0; }
the_stack_data/98574258.c
#include<stdio.h> float calculaTaxa(float qtdHoras) { if ( qtdHoras <= 3.00 ) { return 2.0; } else if ( qtdHoras == 24 ) { return 10.0; } else { return 2.0 + ( qtdHoras * 0.50 ); } } int main ( void ) { int i; float h; for(i == 1; i <= 3; i++) { printf("carro: %d\n",i); printf("Digite a quantidade de horas: "); scanf("%f", &h); printf("Valor a ser pago, carro %d: %.1f\n\n",i, calculaTaxa(h)); } }
the_stack_data/20357.c
#include<stdio.h> int A = 10; int B = 0; int boucle() { for (int i = 33; i < 127 ; i++) { printf("le nombre %d vaut %c\n",i,i); } } int main() { boucle(); }
the_stack_data/1010846.c
#include <stdio.h> #include <unistd.h> #include <sys/wait.h> int main(int argc, const char *argv[]){ pid_t pid = fork(); int status; int execRet; if (pid < 0) perror("Fork failed."); else if (pid == 0) { execRet = execl("/usr/bin/ls", "ls", "-l", NULL); if (execRet == -1) { printf("execl failed\n"); _exit(1); } } else { wait(&status); printf("\nChild executed with exit code: %d\n", WEXITSTATUS(status)); } return 0; }
the_stack_data/246387.c
// 不确定参数传递,... 符 #include <stdio.h> #include <stdarg.h> int sum(int num, ...) { va_list valist; va_start(valist, num); // 为 num 个参数初始化 valist int sum = 0; for(int i = 0; i < num; i ++) sum += va_arg(valist, int); // 逐个访问参数 va_end(valist); // 清理为 valist 保留的内存 return sum; } int main() { printf("1 + 2 = %d\n", sum(2, 1, 2)); printf("1 + 2 + 3 = %d\n", sum(3, 1, 2, 3)); return 0; }
the_stack_data/234518531.c
// This problem can be found on this URL : https://www.codechef.com/problems/HS08TEST #include<stdio.h> int main() { int w; float t; scanf("%d%f",&w,&t); if(w+0.5>t) { printf("%.2f",t); } else if(w%5!=0) printf("%.2f",t); else printf("%.2f",t-w-0.5); return 0 ; }
the_stack_data/601523.c
// // main.c // ReverseArray // // Created by Bikramjit Saha on 26/04/20. // Copyright © 2020 Bikramjit Saha. All rights reserved. // #include <stdio.h> #include <stdlib.h> struct array { int A[10]; int size; int length; }; void Display(struct array arr){ printf("The Elements are: " ); for(int i=0;i<arr.length;i++) printf("%d ",arr.A[i]); } void Reverse(struct array *arr){ int*B=(int*)malloc(arr->length*sizeof(int)); for(int i=arr->length-1,j=0;i>=0;j++,i--) B[j]=arr->A[i]; for(int i=0;i<arr->length;i++) arr->A[i]=B[i]; }void swap(int*x,int*y){ int temp=*x; *x=*y; *y=temp; } void Reverse1(struct array *arr){ for(int i=0,j=arr->length-1;i<j;i++,j--) swap(&arr->A[i],&arr->A[j]); } int main(int argc, const char * argv[]) { // insert code here... struct array arr={{1,3,4,2,5},10,5}; Reverse(&arr); Reverse1(&arr); Display(arr); printf("\n"); return 0; }
the_stack_data/151705310.c
/* Quick Sort Demo for Pintia. * Copyright (c) 2021 Chen Songze * Everyone is premitted to use these code in terms of The Unlicense. * However, I strongly suggest everyone to translate my comments into Chinese. */ #include<stdio.h> void swap(int* a, int* b){ int temp = *a; *a = *b; *b = temp; } void printArray(int numbers[], int size){ for (int i = 0; i < size; ++i){ printf("%d ",numbers[i]); } printf("\n"); } /* QUICK SORT FORMULA * numbers: Array with numbers to be sorted. * lowMark & highMark: the range to be sorted. * Yay, because range may change. * size: the size of the array, since C don't have & */ void QuickSort(int numbers[], int lowMark, int highMark, int size){ // For the valid range... if (lowMark < highMark){ // Since range may change while sorting. int left = lowMark; int right = highMark; // As a flag, smaller left, bigger right. int flag = numbers[lowMark]; while (left < right){ // Find the two invalid number, each on the one side. while (left < right && numbers[right] > flag){ right --; } while (left < right && numbers[left] <= flag){ left ++; } // Then swap it. swap(&numbers[left],&numbers[right]); } // Since left equals to right on the end, it is where we // put the flag on. swap(&numbers[left],&numbers[lowMark]); // Then do the same thing, first on the left, then on the right. QuickSort(numbers, lowMark, left-1, size); QuickSort(numbers, left+1, highMark, size); return; } else { return; } } int main(){ //int numbers[1000] = {0}; int numbers[] = {49,38,65,97,76,13,27,49}, total = 8; //int numbers[] = {4,5,3,2,1}; //int total = 0; //scanf("%d",&total); //for (int i = 0; i < total; ++i){ // scanf("%d",&numbers[i]); //} QuickSort(numbers, 0, total - 1, total); printArray(numbers, total); return 0; }
the_stack_data/7950422.c
/** * @file AETC_GSMF.c * Program for serial communication between Owner and TollPlaza through GSM Module. * Send Fail Message * @author Puskar Kothavade, Ashish Pardhi, Mugdha Nazare, IIT Bombay * @date 10/Oct/2010 * @version 1.0 * * @section LICENSE * Copyright (c) 2010. ERTS Lab IIT Bombay * 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 copyright holders nor the names of * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * Source code can be used for academic purpose. * For commercial use permission form the author needs to be taken. */ #include<stdio.h> #include<string.h> #include<malloc.h> #include<unistd.h> #include<fcntl.h> #include<errno.h> #include<termios.h> #include <sys/time.h> #include <sys/types.h> /** * Open port for serial communication. * display error messsage if unable to open. */ int port_open(void) { int fd; fd = open("/dev/ttyS0",O_RDWR | O_NOCTTY | O_NDELAY); if(fd == -1) { perror("Unable to open the port: /dev/ttyS0"); } else { fcntl(fd,F_SETFL,0); } return(fd); //return file descriptor } /** * Configure port * @param fd File Descriptor to access serial port */ void port_config(int fd) { struct termios settings; tcgetattr(fd,&settings); cfsetispeed(&settings,9600); cfsetospeed(&settings,9600); settings.c_cflag |= (CLOCAL | CREAD); settings.c_cflag &= ~PARENB; settings.c_cflag &= ~CSTOPB; settings.c_cflag &= ~CSIZE; settings.c_cflag |= CS8; tcsetattr(fd,TCSANOW,&settings); } /** *Generate Delay of two seconds. * */ void del_2s(void) // Delay for wait { unsigned char r, s; for(r=0;r<125;r++) for(s=0;s<255;s++); void del_1s(void) { unsigned char p, q; for(p=0;p<125;p++) for(q=0;q=125;q++); } } /** *Send Message to register owner * @param fd File Descriptor to access serial port * @param *c character pointer */ void write_data(int fd,char *c) { char ch; char s[2] = ""; int n; char *charPointer; charPointer = (char *)malloc(sizeof(char) * 10); sprintf(charPointer,"%x",26); n = write(fd, c, strlen(c)); if(n<0) { fputs("write() of data failed! \n",stderr); } printf("sent String: %d\n",n); n = write(fd, "\nAT\r", 4); sleep(2); n = write(fd, "AT+IPR=9600\r",12); sleep(2); n = write(fd, "AT+CSQ\r", 7); sleep(2); n = write(fd, "AT+CMGF=1\r", 10); sleep(2); n = write(fd, "AT+CMGS=\"9619821002\"\r", 21); sleep(5); n = write(fd, "Dear Customer, Your Account Does Not Have Sufficient Balance To Use Our Service. Thank You!\n", 93); n = write(fd, "\x1a", 3); sleep(2); n = write(fd, "\rAT+CMGR=1\n", 11); } /** * Close port for reuse * @param fd File Descriptor to access serial port */ void port_close(int fd) { close(fd); } int main(void) { int fd; fd = port_open(); // Open Port port_config(fd); //Configure Port write_data(fd,""); //Write Message del_2s(); //Generate Delay port_close(fd); //Close Port return 0; //Return }
the_stack_data/48915.c
#include <stdio.h> #include <stdlib.h> int programme_candidat(int** tableau, int x, int y) { int i, j; int out0 = 0; for (i = 0; i < y; i++) for (j = 0; j < x; j++) out0 += tableau[i][j] * (i * 2 + j); return out0; } int main(void) { int a, c, taille_y, taille_x; scanf("%d %d ", &taille_x, &taille_y); int* *tableau = calloc(taille_y, sizeof(int*)); for (a = 0; a < taille_y; a++) { int *b = calloc(taille_x, sizeof(int)); for (c = 0; c < taille_x; c++) scanf("%d ", &b[c]); tableau[a] = b; } printf("%d\n", programme_candidat(tableau, taille_x, taille_y)); return 0; }
the_stack_data/11075700.c
/* Função: Calcular area e o perimetro do retangulo Autor: Gabriel Maciel dos Santos Data: 11/03/18 */ #include <stdio.h> int main(){ float base, altura, area, perimetro; printf("Informe a base em metros:\n"); scanf("%f", &base); printf("Informe a altura em metros:\n"); scanf("%f", &altura); area = (base * altura); perimetro = ((base * 2) + (altura * 2)); printf("Area: %2.f\nPerimetro: %2.f\n", area, perimetro); return 0; }
the_stack_data/504590.c
yylex() { return getchar(); }
the_stack_data/857060.c
/*** * This code is a part of EvoApproxLib library (ehw.fit.vutbr.cz/approxlib) distributed under The MIT License. * When used, please cite the following article(s): V. Mrazek, L. Sekanina, Z. Vasicek "Libraries of Approximate Circuits: Automated Design and Application in CNN Accelerators" IEEE Journal on Emerging and Selected Topics in Circuits and Systems, Vol 10, No 4, 2020 * This file contains a circuit from a sub-set of pareto optimal circuits with respect to the pwr and wce parameters ***/ // MAE% = 0.0045 % // MAE = 0.74 // WCE% = 0.012 % // WCE = 2.0 // WCRE% = 100.00 % // EP% = 37.11 % // MRE% = 0.16 % // MSE = 1.5 // PDK45_PWR = 0.255 mW // PDK45_AREA = 493.7 um2 // PDK45_DELAY = 1.58 ns #include <stdint.h> #include <stdlib.h> uint64_t mul8x6u_5TS(const uint64_t A,const uint64_t B) { uint64_t dout_14, dout_16, dout_17, dout_18, dout_19, dout_20, dout_21, dout_22, dout_23, dout_24, dout_25, dout_26, dout_27, dout_28, dout_29, dout_30, dout_32, dout_33, dout_35, dout_37, dout_38, dout_39, dout_40, dout_41, dout_42, dout_43, dout_44, dout_45, dout_46, dout_47, dout_48, dout_49, dout_50, dout_51, dout_52, dout_53, dout_54, dout_55, dout_56, dout_57, dout_58, dout_59, dout_60, dout_61, dout_62, dout_63, dout_64, dout_65, dout_66, dout_67, dout_68, dout_69, dout_70, dout_71, dout_72, dout_73, dout_74, dout_75, dout_76, dout_77, dout_78, dout_79, dout_80, dout_81, dout_82, dout_83, dout_84, dout_85, dout_86, dout_87, dout_88, dout_89, dout_90, dout_91, dout_92, dout_93, dout_94, dout_95, dout_96, dout_97, dout_98, dout_99, dout_100, dout_101, dout_102, dout_103, dout_104, dout_105, dout_106, dout_107, dout_108, dout_109, dout_110, dout_111, dout_112, dout_113, dout_114, dout_115, dout_116, dout_117, dout_118, dout_119, dout_120, dout_121, dout_122, dout_123, dout_124, dout_125, dout_126, dout_127, dout_128, dout_129, dout_130, dout_131, dout_132, dout_133, dout_134, dout_135, dout_136, dout_137, dout_138, dout_139, dout_140, dout_141, dout_142, dout_143, dout_144, dout_145, dout_146, dout_147, dout_148, dout_149, dout_150, dout_151, dout_152, dout_153, dout_154, dout_155, dout_156, dout_157, dout_158, dout_159, dout_160, dout_161, dout_162, dout_163, dout_164, dout_165, dout_166, dout_167, dout_168, dout_169, dout_170, dout_171, dout_172, dout_173, dout_174, dout_175, dout_176, dout_177, dout_178, dout_179, dout_180, dout_181, dout_182, dout_183, dout_184, dout_185, dout_186, dout_187, dout_188, dout_189, dout_190, dout_191, dout_192, dout_193, dout_194, dout_195, dout_196, dout_197, dout_198, dout_199, dout_200, dout_201, dout_202, dout_203, dout_204, dout_205, dout_206, dout_207, dout_208, dout_209, dout_210, dout_211, dout_212, dout_213, dout_214, dout_215, dout_216, dout_217, dout_218, dout_219, dout_220, dout_221, dout_222, dout_223, dout_224, dout_225, dout_226, dout_227, dout_228, dout_229, dout_230, dout_231, dout_232, dout_233, dout_234, dout_235, dout_236, dout_237, dout_238, dout_239, dout_240, dout_241, dout_242, dout_243; uint64_t O; dout_14=((A >> 0)&1)&((B >> 0)&1); dout_16=((A >> 2)&1)&((B >> 0)&1); dout_17=((A >> 3)&1)&((B >> 0)&1); dout_18=((A >> 4)&1)&((B >> 0)&1); dout_19=((A >> 5)&1)&((B >> 0)&1); dout_20=((A >> 6)&1)&((B >> 0)&1); dout_21=((A >> 7)&1)&((B >> 0)&1); dout_22=((B >> 0)&1)&((B >> 1)&1); dout_23=((A >> 1)&1)&((B >> 1)&1); dout_24=((A >> 2)&1)&((B >> 1)&1); dout_25=((A >> 3)&1)&((B >> 1)&1); dout_26=((A >> 4)&1)&((B >> 1)&1); dout_27=((A >> 5)&1)&((B >> 1)&1); dout_28=((A >> 6)&1)&((B >> 1)&1); dout_29=((A >> 7)&1)&((B >> 1)&1); dout_30=((A >> 1)&1)&dout_22; dout_32=dout_16^dout_23; dout_33=((B >> 0)&1)&dout_23; dout_35=dout_32^dout_30; dout_37=dout_17^dout_24; dout_38=dout_17&dout_24; dout_39=dout_37&dout_33; dout_40=dout_37^dout_33; dout_41=dout_38|dout_39; dout_42=dout_18^dout_25; dout_43=dout_18&dout_25; dout_44=dout_42&dout_41; dout_45=dout_42^dout_41; dout_46=dout_43|dout_44; dout_47=dout_19^dout_26; dout_48=dout_19&dout_26; dout_49=dout_47&dout_46; dout_50=dout_47^dout_46; dout_51=dout_48|dout_49; dout_52=dout_20^dout_27; dout_53=dout_20&dout_27; dout_54=dout_52&dout_51; dout_55=dout_52^dout_51; dout_56=dout_53|dout_54; dout_57=dout_21^dout_28; dout_58=dout_21&dout_28; dout_59=dout_57&dout_56; dout_60=dout_57^dout_56; dout_61=dout_58|dout_59; dout_62=dout_61&dout_29; dout_63=dout_61^dout_29; dout_64=((A >> 0)&1)&((B >> 2)&1); dout_65=((A >> 1)&1)&((B >> 2)&1); dout_66=((A >> 2)&1)&((B >> 2)&1); dout_67=((A >> 3)&1)&((B >> 2)&1); dout_68=((A >> 4)&1)&((B >> 2)&1); dout_69=((A >> 5)&1)&((B >> 2)&1); dout_70=((A >> 6)&1)&((B >> 2)&1); dout_71=((A >> 7)&1)&((B >> 2)&1); dout_72=dout_35&dout_64; dout_73=dout_35^dout_64; dout_74=dout_40^dout_65; dout_75=dout_40&dout_65; dout_76=dout_74&dout_72; dout_77=dout_74^dout_72; dout_78=dout_75|dout_76; dout_79=dout_45^dout_66; dout_80=dout_45&dout_66; dout_81=dout_79&dout_78; dout_82=dout_79^dout_78; dout_83=dout_80|dout_81; dout_84=dout_50^dout_67; dout_85=dout_50&dout_67; dout_86=dout_84&dout_83; dout_87=dout_84^dout_83; dout_88=dout_85|dout_86; dout_89=dout_55^dout_68; dout_90=dout_55&dout_68; dout_91=dout_89&dout_88; dout_92=dout_89^dout_88; dout_93=dout_90|dout_91; dout_94=dout_60^dout_69; dout_95=dout_60&dout_69; dout_96=dout_94&dout_93; dout_97=dout_94^dout_93; dout_98=dout_95|dout_96; dout_99=dout_63^dout_70; dout_100=dout_63&dout_70; dout_101=dout_99&dout_98; dout_102=dout_99^dout_98; dout_103=dout_100|dout_101; dout_104=dout_62^dout_71; dout_105=dout_62&((B >> 2)&1); dout_106=((A >> 7)&1)&dout_103; dout_107=dout_104^dout_103; dout_108=dout_105|dout_106; dout_109=((A >> 0)&1)&((B >> 3)&1); dout_110=((A >> 1)&1)&((B >> 3)&1); dout_111=((A >> 2)&1)&((B >> 3)&1); dout_112=((A >> 3)&1)&((B >> 3)&1); dout_113=((A >> 4)&1)&((B >> 3)&1); dout_114=((A >> 5)&1)&((B >> 3)&1); dout_115=((A >> 6)&1)&((B >> 3)&1); dout_116=((A >> 7)&1)&((B >> 3)&1); dout_117=dout_77&dout_109; dout_118=dout_77^dout_109; dout_119=dout_82^dout_110; dout_120=dout_82&dout_110; dout_121=dout_119&dout_117; dout_122=dout_119^dout_117; dout_123=dout_120|dout_121; dout_124=dout_87^dout_111; dout_125=dout_87&dout_111; dout_126=dout_124&dout_123; dout_127=dout_124^dout_123; dout_128=dout_125|dout_126; dout_129=dout_92^dout_112; dout_130=dout_92&dout_112; dout_131=dout_129&dout_128; dout_132=dout_129^dout_128; dout_133=dout_130|dout_131; dout_134=dout_97^dout_113; dout_135=dout_97&dout_113; dout_136=dout_134&dout_133; dout_137=dout_134^dout_133; dout_138=dout_135|dout_136; dout_139=dout_102^dout_114; dout_140=dout_102&dout_114; dout_141=dout_139&dout_138; dout_142=dout_139^dout_138; dout_143=dout_140|dout_141; dout_144=dout_107^dout_115; dout_145=dout_107&dout_115; dout_146=dout_144&dout_143; dout_147=dout_144^dout_143; dout_148=dout_145|dout_146; dout_149=dout_108^dout_116; dout_150=dout_108&((B >> 3)&1); dout_151=dout_149&dout_148; dout_152=dout_149^dout_148; dout_153=dout_150|dout_151; dout_154=((A >> 0)&1)&((B >> 4)&1); dout_155=((A >> 1)&1)&((B >> 4)&1); dout_156=((A >> 2)&1)&((B >> 4)&1); dout_157=((A >> 3)&1)&((B >> 4)&1); dout_158=((A >> 4)&1)&((B >> 4)&1); dout_159=((A >> 5)&1)&((B >> 4)&1); dout_160=((A >> 6)&1)&((B >> 4)&1); dout_161=((A >> 7)&1)&((B >> 4)&1); dout_162=dout_122&dout_154; dout_163=dout_122^dout_154; dout_164=dout_127^dout_155; dout_165=dout_127&dout_155; dout_166=dout_164&dout_162; dout_167=dout_164^dout_162; dout_168=dout_165|dout_166; dout_169=dout_132^dout_156; dout_170=dout_132&dout_156; dout_171=dout_169&dout_168; dout_172=dout_169^dout_168; dout_173=dout_170|dout_171; dout_174=dout_137^dout_157; dout_175=dout_137&dout_157; dout_176=dout_174&dout_173; dout_177=dout_174^dout_173; dout_178=dout_175|dout_176; dout_179=dout_142^dout_158; dout_180=dout_142&dout_158; dout_181=dout_179&dout_178; dout_182=dout_179^dout_178; dout_183=dout_180|dout_181; dout_184=dout_147^dout_159; dout_185=dout_147&dout_159; dout_186=dout_184&dout_183; dout_187=dout_184^dout_183; dout_188=dout_185|dout_186; dout_189=dout_152^dout_160; dout_190=dout_152&dout_160; dout_191=dout_189&dout_188; dout_192=dout_189^dout_188; dout_193=dout_190|dout_191; dout_194=dout_153^dout_161; dout_195=dout_153&((B >> 4)&1); dout_196=dout_161&dout_193; dout_197=dout_194^dout_193; dout_198=dout_195|dout_196; dout_199=((A >> 0)&1)&((B >> 5)&1); dout_200=((A >> 1)&1)&((B >> 5)&1); dout_201=((A >> 2)&1)&((B >> 5)&1); dout_202=((A >> 3)&1)&((B >> 5)&1); dout_203=((A >> 4)&1)&((B >> 5)&1); dout_204=((A >> 5)&1)&((B >> 5)&1); dout_205=((A >> 6)&1)&((B >> 5)&1); dout_206=((A >> 7)&1)&((B >> 5)&1); dout_207=dout_167&dout_199; dout_208=dout_167^dout_199; dout_209=dout_172^dout_200; dout_210=dout_172&dout_200; dout_211=dout_209&dout_207; dout_212=dout_209^dout_207; dout_213=dout_210|dout_211; dout_214=dout_177^dout_201; dout_215=dout_177&dout_201; dout_216=dout_214&dout_213; dout_217=dout_214^dout_213; dout_218=dout_215|dout_216; dout_219=dout_182^dout_202; dout_220=dout_182&dout_202; dout_221=dout_219&dout_218; dout_222=dout_219^dout_218; dout_223=dout_220|dout_221; dout_224=dout_187^dout_203; dout_225=dout_187&dout_203; dout_226=dout_224&dout_223; dout_227=dout_224^dout_223; dout_228=dout_225|dout_226; dout_229=dout_192^dout_204; dout_230=dout_192&dout_204; dout_231=dout_229&dout_228; dout_232=dout_229^dout_228; dout_233=dout_230|dout_231; dout_234=dout_197^dout_205; dout_235=dout_197&dout_205; dout_236=dout_234&dout_233; dout_237=dout_234^dout_233; dout_238=dout_235|dout_236; dout_239=dout_198^dout_206; dout_240=dout_198&((B >> 5)&1); dout_241=((A >> 7)&1)&dout_238; dout_242=dout_239^dout_238; dout_243=dout_240|dout_241; O = 0; O |= (dout_14&1) << 0; O |= (dout_207&1) << 1; O |= (dout_73&1) << 2; O |= (dout_118&1) << 3; O |= (dout_163&1) << 4; O |= (dout_208&1) << 5; O |= (dout_212&1) << 6; O |= (dout_217&1) << 7; O |= (dout_222&1) << 8; O |= (dout_227&1) << 9; O |= (dout_232&1) << 10; O |= (dout_237&1) << 11; O |= (dout_242&1) << 12; O |= (dout_243&1) << 13; return O; }
the_stack_data/182952973.c
// Elementos únicos - ex19 #include <stdio.h> main(){ int n, i, foi; scanf("%d", &n); int numeros[n]; for(i = 0; i < n; i++){ scanf("%d", &numeros[i]); } for(i = 0; i < n; i++){ if(numeros[i] != numeros[i - 1] && i){ printf("%d\n", numeros[i]); } else if(!i){ printf("%d\n", numeros[i]); } } }
the_stack_data/181393843.c
#include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct node Node; struct node { Node* left; Node* right; int data; }; typedef Node* Tree; Tree ins(Tree, int); void parse(int* bi, Tree b) { Tree queue[1000]; int head, tail; head = tail = 0; queue[head] = b; while (head <= tail) { if (queue[head]->left) queue[++tail] = queue[head]->left; if (queue[head]->right) queue[++tail] = queue[head]->right; bi[head] = queue[head]->data; ++head; } } void compare(int *b1, int* b2, int n) { int i; int yes = 1; for (i = 0; i < n; i++) { if (b1[i] != b2[i]) yes = 0; } if (yes) printf("Yes\n"); else printf("No\n"); } Tree build(Tree b0, int n) { int temp; b0 = (Tree)malloc(sizeof (Node)); b0->left = NULL; b0->right = NULL; //cin >> temp; scanf("%d", &temp); b0->data = temp; while (--n) { //cin >> temp; scanf("%d", &temp); b0 = ins(b0, temp); } return b0; } Tree ins(Tree t, int i) { Tree T = t; Node** prv = NULL; while (t != NULL) { if (i < t->data) { prv = &(t->left); t = t->left; } else if (i > t->data) { prv = &(t->right); t = t->right; } } *prv = (Node*)malloc(sizeof(Node)); t = *prv; t->data = i; t->right = t->left = NULL; return T; } int main() { int N, L; //cin >> N >> L; scanf("%d ", &N); int n = N; Tree b0 = NULL; Tree b = NULL; while (N) { scanf("%d", &L); b0 = build(b0, n); int* b0i = (int*)malloc(sizeof(int)* N); parse(b0i, b0); while (L--) { b = build(b, n); int* bi = (int*)malloc(sizeof(int)* N); parse(bi, b); compare(bi, b0i, n); free(bi); free(b); } free(b0i); free(b0); scanf("%d ", &N); n = N; } return 0; }
the_stack_data/161079581.c
#ifdef __cplusplus # error "A C++ compiler has been selected for C." #endif /* Version number components: V=Version, R=Revision, P=Patch Version date components: YYYY=Year, MM=Month, DD=Day */ #if defined(__18CXX) # define ID_VOID_MAIN #endif #if defined(__INTEL_COMPILER) || defined(__ICC) # define COMPILER_ID "Intel" /* __INTEL_COMPILER = VRP */ # define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100) # define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10) # if defined(__INTEL_COMPILER_UPDATE) # define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER_UPDATE) # else # define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10) # endif # if defined(__INTEL_COMPILER_BUILD_DATE) /* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */ # define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE) # endif # if defined(_MSC_VER) # define SIMULATE_ID "MSVC" /* _MSC_VER = VVRR */ # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) # endif #elif defined(__PATHCC__) # define COMPILER_ID "PathScale" # define COMPILER_VERSION_MAJOR DEC(__PATHCC__) # define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__) # if defined(__PATHCC_PATCHLEVEL__) # define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__) # endif #elif defined(__clang__) # if defined(__apple_build_version__) # define COMPILER_ID "AppleClang" # define COMPILER_VERSION_TWEAK DEC(__apple_build_version__) # else # define COMPILER_ID "Clang" # endif # define COMPILER_VERSION_MAJOR DEC(__clang_major__) # define COMPILER_VERSION_MINOR DEC(__clang_minor__) # define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__) # if defined(_MSC_VER) # define SIMULATE_ID "MSVC" /* _MSC_VER = VVRR */ # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) # endif #elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__) # define COMPILER_ID "Embarcadero" # define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF) # define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF) # define COMPILER_VERSION_PATCH HEX(__CODEGEARC_VERSION__ & 0xFFFF) #elif defined(__BORLANDC__) # define COMPILER_ID "Borland" /* __BORLANDC__ = 0xVRR */ # define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8) # define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF) #elif defined(__WATCOMC__) # define COMPILER_ID "Watcom" /* __WATCOMC__ = VVRR */ # define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100) # define COMPILER_VERSION_MINOR DEC(__WATCOMC__ % 100) #elif defined(__SUNPRO_C) # define COMPILER_ID "SunPro" # if __SUNPRO_C >= 0x5100 /* __SUNPRO_C = 0xVRRP */ # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>12) # define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xFF) # define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF) # else /* __SUNPRO_C = 0xVRP */ # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>8) # define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xF) # define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF) # endif #elif defined(__HP_cc) # define COMPILER_ID "HP" /* __HP_cc = VVRRPP */ # define COMPILER_VERSION_MAJOR DEC(__HP_cc/10000) # define COMPILER_VERSION_MINOR DEC(__HP_cc/100 % 100) # define COMPILER_VERSION_PATCH DEC(__HP_cc % 100) #elif defined(__DECC) # define COMPILER_ID "Compaq" /* __DECC_VER = VVRRTPPPP */ # define COMPILER_VERSION_MAJOR DEC(__DECC_VER/10000000) # define COMPILER_VERSION_MINOR DEC(__DECC_VER/100000 % 100) # define COMPILER_VERSION_PATCH DEC(__DECC_VER % 10000) #elif defined(__IBMC__) # if defined(__COMPILER_VER__) # define COMPILER_ID "zOS" # else # if __IBMC__ >= 800 # define COMPILER_ID "XL" # else # define COMPILER_ID "VisualAge" # endif /* __IBMC__ = VRP */ # define COMPILER_VERSION_MAJOR DEC(__IBMC__/100) # define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10) # define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10) # endif #elif defined(__PGI) # define COMPILER_ID "PGI" # define COMPILER_VERSION_MAJOR DEC(__PGIC__) # define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__) # if defined(__PGIC_PATCHLEVEL__) # define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__) # endif #elif defined(_CRAYC) # define COMPILER_ID "Cray" # define COMPILER_VERSION_MAJOR DEC(_RELEASE) # define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR) #elif defined(__TI_COMPILER_VERSION__) # define COMPILER_ID "TI" /* __TI_COMPILER_VERSION__ = VVVRRRPPP */ # define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000) # define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000) # define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000) #elif defined(__TINYC__) # define COMPILER_ID "TinyCC" #elif defined(__SCO_VERSION__) # define COMPILER_ID "SCO" #elif defined(__GNUC__) # define COMPILER_ID "GNU" # define COMPILER_VERSION_MAJOR DEC(__GNUC__) # define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__) # if defined(__GNUC_PATCHLEVEL__) # define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__) # endif #elif defined(_MSC_VER) # define COMPILER_ID "MSVC" /* _MSC_VER = VVRR */ # define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100) # define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100) # if defined(_MSC_FULL_VER) # if _MSC_VER >= 1400 /* _MSC_FULL_VER = VVRRPPPPP */ # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000) # else /* _MSC_FULL_VER = VVRRPPPP */ # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000) # endif # endif # if defined(_MSC_BUILD) # define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD) # endif /* Analog VisualDSP++ >= 4.5.6 */ #elif defined(__VISUALDSPVERSION__) # define COMPILER_ID "ADSP" /* __VISUALDSPVERSION__ = 0xVVRRPP00 */ # define COMPILER_VERSION_MAJOR HEX(__VISUALDSPVERSION__>>24) # define COMPILER_VERSION_MINOR HEX(__VISUALDSPVERSION__>>16 & 0xFF) # define COMPILER_VERSION_PATCH HEX(__VISUALDSPVERSION__>>8 & 0xFF) /* Analog VisualDSP++ < 4.5.6 */ #elif defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__) # define COMPILER_ID "ADSP" /* IAR Systems compiler for embedded systems. http://www.iar.com */ #elif defined(__IAR_SYSTEMS_ICC__ ) || defined(__IAR_SYSTEMS_ICC) # define COMPILER_ID "IAR" /* sdcc, the small devices C compiler for embedded systems, http://sdcc.sourceforge.net */ #elif defined(SDCC) # define COMPILER_ID "SDCC" /* SDCC = VRP */ # define COMPILER_VERSION_MAJOR DEC(SDCC/100) # define COMPILER_VERSION_MINOR DEC(SDCC/10 % 10) # define COMPILER_VERSION_PATCH DEC(SDCC % 10) #elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION) # define COMPILER_ID "MIPSpro" # if defined(_SGI_COMPILER_VERSION) /* _SGI_COMPILER_VERSION = VRP */ # define COMPILER_VERSION_MAJOR DEC(_SGI_COMPILER_VERSION/100) # define COMPILER_VERSION_MINOR DEC(_SGI_COMPILER_VERSION/10 % 10) # define COMPILER_VERSION_PATCH DEC(_SGI_COMPILER_VERSION % 10) # else /* _COMPILER_VERSION = VRP */ # define COMPILER_VERSION_MAJOR DEC(_COMPILER_VERSION/100) # define COMPILER_VERSION_MINOR DEC(_COMPILER_VERSION/10 % 10) # define COMPILER_VERSION_PATCH DEC(_COMPILER_VERSION % 10) # endif /* This compiler is either not known or is too old to define an identification macro. Try to identify the platform and guess that it is the native compiler. */ #elif defined(__sgi) # define COMPILER_ID "MIPSpro" #elif defined(__hpux) || defined(__hpua) # define COMPILER_ID "HP" #else /* unknown compiler */ # define COMPILER_ID "" #endif /* Construct the string literal in pieces to prevent the source from getting matched. Store it in a pointer rather than an array because some compilers will just produce instructions to fill the array rather than assigning a pointer to a static array. */ char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]"; #ifdef SIMULATE_ID char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]"; #endif #ifdef __QNXNTO__ char const* qnxnto = "INFO" ":" "qnxnto"; #endif /* Identify known platforms by name. */ #if defined(__linux) || defined(__linux__) || defined(linux) # define PLATFORM_ID "Linux" #elif defined(__CYGWIN__) # define PLATFORM_ID "Cygwin" #elif defined(__MINGW32__) # define PLATFORM_ID "MinGW" #elif defined(__APPLE__) # define PLATFORM_ID "Darwin" #elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32) # define PLATFORM_ID "Windows" #elif defined(__FreeBSD__) || defined(__FreeBSD) # define PLATFORM_ID "FreeBSD" #elif defined(__NetBSD__) || defined(__NetBSD) # define PLATFORM_ID "NetBSD" #elif defined(__OpenBSD__) || defined(__OPENBSD) # define PLATFORM_ID "OpenBSD" #elif defined(__sun) || defined(sun) # define PLATFORM_ID "SunOS" #elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__) # define PLATFORM_ID "AIX" #elif defined(__sgi) || defined(__sgi__) || defined(_SGI) # define PLATFORM_ID "IRIX" #elif defined(__hpux) || defined(__hpux__) # define PLATFORM_ID "HP-UX" #elif defined(__HAIKU__) # define PLATFORM_ID "Haiku" #elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS) # define PLATFORM_ID "BeOS" #elif defined(__QNX__) || defined(__QNXNTO__) # define PLATFORM_ID "QNX" #elif defined(__tru64) || defined(_tru64) || defined(__TRU64__) # define PLATFORM_ID "Tru64" #elif defined(__riscos) || defined(__riscos__) # define PLATFORM_ID "RISCos" #elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__) # define PLATFORM_ID "SINIX" #elif defined(__UNIX_SV__) # define PLATFORM_ID "UNIX_SV" #elif defined(__bsdos__) # define PLATFORM_ID "BSDOS" #elif defined(_MPRAS) || defined(MPRAS) # define PLATFORM_ID "MP-RAS" #elif defined(__osf) || defined(__osf__) # define PLATFORM_ID "OSF1" #elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv) # define PLATFORM_ID "SCO_SV" #elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX) # define PLATFORM_ID "ULTRIX" #elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX) # define PLATFORM_ID "Xenix" #else /* unknown platform */ # define PLATFORM_ID "" #endif /* For windows compilers MSVC and Intel we can determine the architecture of the compiler being used. This is because the compilers do not have flags that can change the architecture, but rather depend on which compiler is being used */ #if defined(_WIN32) && defined(_MSC_VER) # if defined(_M_IA64) # define ARCHITECTURE_ID "IA64" # elif defined(_M_X64) || defined(_M_AMD64) # define ARCHITECTURE_ID "x64" # elif defined(_M_IX86) # define ARCHITECTURE_ID "X86" # elif defined(_M_ARM) # define ARCHITECTURE_ID "ARM" # elif defined(_M_MIPS) # define ARCHITECTURE_ID "MIPS" # elif defined(_M_SH) # define ARCHITECTURE_ID "SHx" # else /* unknown architecture */ # define ARCHITECTURE_ID "" # endif #else # define ARCHITECTURE_ID "" #endif /* Convert integer to decimal digit literals. */ #define DEC(n) \ ('0' + (((n) / 10000000)%10)), \ ('0' + (((n) / 1000000)%10)), \ ('0' + (((n) / 100000)%10)), \ ('0' + (((n) / 10000)%10)), \ ('0' + (((n) / 1000)%10)), \ ('0' + (((n) / 100)%10)), \ ('0' + (((n) / 10)%10)), \ ('0' + ((n) % 10)) /* Convert integer to hex digit literals. */ #define HEX(n) \ ('0' + ((n)>>28 & 0xF)), \ ('0' + ((n)>>24 & 0xF)), \ ('0' + ((n)>>20 & 0xF)), \ ('0' + ((n)>>16 & 0xF)), \ ('0' + ((n)>>12 & 0xF)), \ ('0' + ((n)>>8 & 0xF)), \ ('0' + ((n)>>4 & 0xF)), \ ('0' + ((n) & 0xF)) /* Construct a string literal encoding the version number components. */ #ifdef COMPILER_VERSION_MAJOR char const info_version[] = { 'I', 'N', 'F', 'O', ':', 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[', COMPILER_VERSION_MAJOR, # ifdef COMPILER_VERSION_MINOR '.', COMPILER_VERSION_MINOR, # ifdef COMPILER_VERSION_PATCH '.', COMPILER_VERSION_PATCH, # ifdef COMPILER_VERSION_TWEAK '.', COMPILER_VERSION_TWEAK, # endif # endif # endif ']','\0'}; #endif /* Construct a string literal encoding the version number components. */ #ifdef SIMULATE_VERSION_MAJOR char const info_simulate_version[] = { 'I', 'N', 'F', 'O', ':', 's','i','m','u','l','a','t','e','_','v','e','r','s','i','o','n','[', SIMULATE_VERSION_MAJOR, # ifdef SIMULATE_VERSION_MINOR '.', SIMULATE_VERSION_MINOR, # ifdef SIMULATE_VERSION_PATCH '.', SIMULATE_VERSION_PATCH, # ifdef SIMULATE_VERSION_TWEAK '.', SIMULATE_VERSION_TWEAK, # endif # endif # endif ']','\0'}; #endif /* Construct the string literal in pieces to prevent the source from getting matched. Store it in a pointer rather than an array because some compilers will just produce instructions to fill the array rather than assigning a pointer to a static array. */ char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]"; char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]"; /*--------------------------------------------------------------------------*/ #ifdef ID_VOID_MAIN void main() {} #else int main(int argc, char* argv[]) { int require = 0; require += info_compiler[argc]; require += info_platform[argc]; require += info_arch[argc]; #ifdef COMPILER_VERSION_MAJOR require += info_version[argc]; #endif #ifdef SIMULATE_ID require += info_simulate[argc]; #endif #ifdef SIMULATE_VERSION_MAJOR require += info_simulate_version[argc]; #endif (void)argv; return require; } #endif
the_stack_data/11074488.c
#include<stdio.h> int main() { long long int n,m,x,y,i,j,k; x=1; y=1; scanf("%lld%lld",&m,&n); for(i=m;i>m-n;i--) x=x*i; for(j=1;j<=n;j++) y=y*j; k=x/y; printf("%lld",k); return 0; }
the_stack_data/999215.c
extern int ar[2]; extern int in; int out1, out2, out3; void array_task(void) { if(in == 1) ar[0]++; if(in == 2) ar[1]++; out1 = ar[0]; out2 = ar[1]; out3 = ar[0] + ar[1]; }
the_stack_data/143334.c
// reads data from "april.txt", and stores each column into an 1D array. #include <stdio.h> #include <stdlib.h> int main(void) { int c = 12, r, i = 0, j; int *arr1, *arr2, *arr3, *arr4; float temp; float *arr5, *arr6, *arr7, *arr8, *arr9, *arr10, *arr11, *arr12; FILE *fp; fp = fopen("april.txt", "r"); arr1 = (int *)(malloc(4330*sizeof(int))); arr2 = (int *)(malloc(4330*sizeof(int))); arr3 = (int *)(malloc(4330*sizeof(int))); arr4 = (int *)(malloc(4330*sizeof(int))); arr5 = (float *)(malloc(4330*sizeof(float))); arr6 = (float *)(malloc(4330*sizeof(float))); arr7 = (float *)(malloc(4330*sizeof(float))); arr8 = (float *)(malloc(4330*sizeof(float))); arr9 = (float *)(malloc(4330*sizeof(float))); arr10 = (float *)(malloc(4330*sizeof(float))); arr11 = (float *)(malloc(4330*sizeof(float))); arr12 = (float *)(malloc(4330*sizeof(float))); if (fp != NULL) { i = 0; while (fscanf(fp, "%f", &temp) != EOF) { switch(i%c) { case 0: arr1[i/c] = (int)temp; break; case 1: arr2[i/c] = (int)temp; break; case 2: arr3[i/c] = (int)temp; break; case 3: arr4[i/c] = (int)temp; break; case 4: arr5[i/c] = temp; break; case 5: arr6[i/c] = temp; break; case 6: arr7[i/c] = temp; break; case 7: arr8[i/c] = temp; break; case 8: arr9[i/c] = temp; break; case 9: arr10[i/c] = temp; break; case 10: arr11[i/c] = temp; break; case 11: arr12[i/c] = temp; break; } i++; } } fclose(fp); r = i/c; return 0; }
the_stack_data/104829204.c
/* f2c.h -- Standard Fortran to C header file */ /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ #ifndef F2C_INCLUDE #define F2C_INCLUDE #include <math.h> #include <stdlib.h> #include <string.h> #include <stdio.h> #include <complex.h> #ifdef complex #undef complex #endif #ifdef I #undef I #endif #if defined(_WIN64) typedef long long BLASLONG; typedef unsigned long long BLASULONG; #else typedef long BLASLONG; typedef unsigned long BLASULONG; #endif #ifdef LAPACK_ILP64 typedef BLASLONG blasint; #if defined(_WIN64) #define blasabs(x) llabs(x) #else #define blasabs(x) labs(x) #endif #else typedef int blasint; #define blasabs(x) abs(x) #endif typedef blasint integer; typedef unsigned int uinteger; typedef char *address; typedef short int shortint; typedef float real; typedef double doublereal; typedef struct { real r, i; } complex; typedef struct { doublereal r, i; } doublecomplex; static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} #define pCf(z) (*_pCf(z)) #define pCd(z) (*_pCd(z)) typedef int logical; typedef short int shortlogical; typedef char logical1; typedef char integer1; #define TRUE_ (1) #define FALSE_ (0) /* Extern is for use with -E */ #ifndef Extern #define Extern extern #endif /* I/O stuff */ typedef int flag; typedef int ftnlen; typedef int ftnint; /*external read, write*/ typedef struct { flag cierr; ftnint ciunit; flag ciend; char *cifmt; ftnint cirec; } cilist; /*internal read, write*/ typedef struct { flag icierr; char *iciunit; flag iciend; char *icifmt; ftnint icirlen; ftnint icirnum; } icilist; /*open*/ typedef struct { flag oerr; ftnint ounit; char *ofnm; ftnlen ofnmlen; char *osta; char *oacc; char *ofm; ftnint orl; char *oblnk; } olist; /*close*/ typedef struct { flag cerr; ftnint cunit; char *csta; } cllist; /*rewind, backspace, endfile*/ typedef struct { flag aerr; ftnint aunit; } alist; /* inquire */ typedef struct { flag inerr; ftnint inunit; char *infile; ftnlen infilen; ftnint *inex; /*parameters in standard's order*/ ftnint *inopen; ftnint *innum; ftnint *innamed; char *inname; ftnlen innamlen; char *inacc; ftnlen inacclen; char *inseq; ftnlen inseqlen; char *indir; ftnlen indirlen; char *infmt; ftnlen infmtlen; char *inform; ftnint informlen; char *inunf; ftnlen inunflen; ftnint *inrecl; ftnint *innrec; char *inblank; ftnlen inblanklen; } inlist; #define VOID void union Multitype { /* for multiple entry points */ integer1 g; shortint h; integer i; /* longint j; */ real r; doublereal d; complex c; doublecomplex z; }; typedef union Multitype Multitype; struct Vardesc { /* for Namelist */ char *name; char *addr; ftnlen *dims; int type; }; typedef struct Vardesc Vardesc; struct Namelist { char *name; Vardesc **vars; int nvars; }; typedef struct Namelist Namelist; #define abs(x) ((x) >= 0 ? (x) : -(x)) #define dabs(x) (fabs(x)) #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) #define dmin(a,b) (f2cmin(a,b)) #define dmax(a,b) (f2cmax(a,b)) #define bit_test(a,b) ((a) >> (b) & 1) #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) #define abort_() { sig_die("Fortran abort routine called", 1); } #define c_abs(z) (cabsf(Cf(z))) #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} #define d_abs(x) (fabs(*(x))) #define d_acos(x) (acos(*(x))) #define d_asin(x) (asin(*(x))) #define d_atan(x) (atan(*(x))) #define d_atn2(x, y) (atan2(*(x),*(y))) #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } #define d_cos(x) (cos(*(x))) #define d_cosh(x) (cosh(*(x))) #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) #define d_exp(x) (exp(*(x))) #define d_imag(z) (cimag(Cd(z))) #define r_imag(z) (cimag(Cf(z))) #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) #define d_log(x) (log(*(x))) #define d_mod(x, y) (fmod(*(x), *(y))) #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) #define d_nint(x) u_nint(*(x)) #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) #define d_sign(a,b) u_sign(*(a),*(b)) #define r_sign(a,b) u_sign(*(a),*(b)) #define d_sin(x) (sin(*(x))) #define d_sinh(x) (sinh(*(x))) #define d_sqrt(x) (sqrt(*(x))) #define d_tan(x) (tan(*(x))) #define d_tanh(x) (tanh(*(x))) #define i_abs(x) abs(*(x)) #define i_dnnt(x) ((integer)u_nint(*(x))) #define i_len(s, n) (n) #define i_nint(x) ((integer)u_nint(*(x))) #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) #define pow_si(B,E) spow_ui(*(B),*(E)) #define pow_ri(B,E) spow_ui(*(B),*(E)) #define pow_di(B,E) dpow_ui(*(B),*(E)) #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } #define sig_die(s, kill) { exit(1); } #define s_stop(s, n) {exit(0);} static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; #define z_abs(z) (cabs(Cd(z))) #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} #define myexit_() break; #define mycycle() continue; #define myceiling(w) {ceil(w)} #define myhuge(w) {HUGE_VAL} //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} /* procedure parameter types for -A and -C++ */ #define F2C_proc_par_types 1 #ifdef __cplusplus typedef logical (*L_fp)(...); #else typedef logical (*L_fp)(); #endif static float spow_ui(float x, integer n) { float pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static double dpow_ui(double x, integer n) { double pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static _Complex float cpow_ui(_Complex float x, integer n) { _Complex float pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static _Complex double zpow_ui(_Complex double x, integer n) { _Complex double pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static integer pow_ii(integer x, integer n) { integer pow; unsigned long int u; if (n <= 0) { if (n == 0 || x == 1) pow = 1; else if (x != -1) pow = x == 0 ? 1/x : 0; else n = -n; } if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { u = n; for(pow = 1; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static integer dmaxloc_(double *w, integer s, integer e, integer *n) { double m; integer i, mi; for(m=w[s-1], mi=s, i=s+1; i<=e; i++) if (w[i-1]>m) mi=i ,m=w[i-1]; return mi-s+1; } static integer smaxloc_(float *w, integer s, integer e, integer *n) { float m; integer i, mi; for(m=w[s-1], mi=s, i=s+1; i<=e; i++) if (w[i-1]>m) mi=i ,m=w[i-1]; return mi-s+1; } static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; _Complex float zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); } } pCf(z) = zdotc; } static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; _Complex double zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conj(Cd(&x[i])) * Cd(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); } } pCd(z) = zdotc; } static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; _Complex float zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cf(&x[i]) * Cf(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); } } pCf(z) = zdotc; } static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; _Complex double zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cd(&x[i]) * Cd(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); } } pCd(z) = zdotc; } #endif /* -- translated by f2c (version 20000121). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ /* Table of constant values */ static integer c__1 = 1; static integer c_n1 = -1; static integer c__2 = 2; static integer c__65 = 65; /* > \brief \b SORMRQ */ /* =========== DOCUMENTATION =========== */ /* Online html documentation available at */ /* http://www.netlib.org/lapack/explore-html/ */ /* > \htmlonly */ /* > Download SORMRQ + dependencies */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sormrq. f"> */ /* > [TGZ]</a> */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sormrq. f"> */ /* > [ZIP]</a> */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sormrq. f"> */ /* > [TXT]</a> */ /* > \endhtmlonly */ /* Definition: */ /* =========== */ /* SUBROUTINE SORMRQ( SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC, */ /* WORK, LWORK, INFO ) */ /* CHARACTER SIDE, TRANS */ /* INTEGER INFO, K, LDA, LDC, LWORK, M, N */ /* REAL A( LDA, * ), C( LDC, * ), TAU( * ), */ /* $ WORK( * ) */ /* > \par Purpose: */ /* ============= */ /* > */ /* > \verbatim */ /* > */ /* > SORMRQ overwrites the general real M-by-N matrix C with */ /* > */ /* > SIDE = 'L' SIDE = 'R' */ /* > TRANS = 'N': Q * C C * Q */ /* > TRANS = 'T': Q**T * C C * Q**T */ /* > */ /* > where Q is a real orthogonal matrix defined as the product of k */ /* > elementary reflectors */ /* > */ /* > Q = H(1) H(2) . . . H(k) */ /* > */ /* > as returned by SGERQF. Q is of order M if SIDE = 'L' and of order N */ /* > if SIDE = 'R'. */ /* > \endverbatim */ /* Arguments: */ /* ========== */ /* > \param[in] SIDE */ /* > \verbatim */ /* > SIDE is CHARACTER*1 */ /* > = 'L': apply Q or Q**T from the Left; */ /* > = 'R': apply Q or Q**T from the Right. */ /* > \endverbatim */ /* > */ /* > \param[in] TRANS */ /* > \verbatim */ /* > TRANS is CHARACTER*1 */ /* > = 'N': No transpose, apply Q; */ /* > = 'T': Transpose, apply Q**T. */ /* > \endverbatim */ /* > */ /* > \param[in] M */ /* > \verbatim */ /* > M is INTEGER */ /* > The number of rows of the matrix C. M >= 0. */ /* > \endverbatim */ /* > */ /* > \param[in] N */ /* > \verbatim */ /* > N is INTEGER */ /* > The number of columns of the matrix C. N >= 0. */ /* > \endverbatim */ /* > */ /* > \param[in] K */ /* > \verbatim */ /* > K is INTEGER */ /* > The number of elementary reflectors whose product defines */ /* > the matrix Q. */ /* > If SIDE = 'L', M >= K >= 0; */ /* > if SIDE = 'R', N >= K >= 0. */ /* > \endverbatim */ /* > */ /* > \param[in] A */ /* > \verbatim */ /* > A is REAL array, dimension */ /* > (LDA,M) if SIDE = 'L', */ /* > (LDA,N) if SIDE = 'R' */ /* > The i-th row must contain the vector which defines the */ /* > elementary reflector H(i), for i = 1,2,...,k, as returned by */ /* > SGERQF in the last k rows of its array argument A. */ /* > \endverbatim */ /* > */ /* > \param[in] LDA */ /* > \verbatim */ /* > LDA is INTEGER */ /* > The leading dimension of the array A. LDA >= f2cmax(1,K). */ /* > \endverbatim */ /* > */ /* > \param[in] TAU */ /* > \verbatim */ /* > TAU is REAL array, dimension (K) */ /* > TAU(i) must contain the scalar factor of the elementary */ /* > reflector H(i), as returned by SGERQF. */ /* > \endverbatim */ /* > */ /* > \param[in,out] C */ /* > \verbatim */ /* > C is REAL array, dimension (LDC,N) */ /* > On entry, the M-by-N matrix C. */ /* > On exit, C is overwritten by Q*C or Q**T*C or C*Q**T or C*Q. */ /* > \endverbatim */ /* > */ /* > \param[in] LDC */ /* > \verbatim */ /* > LDC is INTEGER */ /* > The leading dimension of the array C. LDC >= f2cmax(1,M). */ /* > \endverbatim */ /* > */ /* > \param[out] WORK */ /* > \verbatim */ /* > WORK is REAL array, dimension (MAX(1,LWORK)) */ /* > On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ /* > \endverbatim */ /* > */ /* > \param[in] LWORK */ /* > \verbatim */ /* > LWORK is INTEGER */ /* > The dimension of the array WORK. */ /* > If SIDE = 'L', LWORK >= f2cmax(1,N); */ /* > if SIDE = 'R', LWORK >= f2cmax(1,M). */ /* > For good performance, LWORK should generally be larger. */ /* > */ /* > If LWORK = -1, then a workspace query is assumed; the routine */ /* > only calculates the optimal size of the WORK array, returns */ /* > this value as the first entry of the WORK array, and no error */ /* > message related to LWORK is issued by XERBLA. */ /* > \endverbatim */ /* > */ /* > \param[out] INFO */ /* > \verbatim */ /* > INFO is INTEGER */ /* > = 0: successful exit */ /* > < 0: if INFO = -i, the i-th argument had an illegal value */ /* > \endverbatim */ /* Authors: */ /* ======== */ /* > \author Univ. of Tennessee */ /* > \author Univ. of California Berkeley */ /* > \author Univ. of Colorado Denver */ /* > \author NAG Ltd. */ /* > \date December 2016 */ /* > \ingroup realOTHERcomputational */ /* ===================================================================== */ /* Subroutine */ int sormrq_(char *side, char *trans, integer *m, integer *n, integer *k, real *a, integer *lda, real *tau, real *c__, integer *ldc, real *work, integer *lwork, integer *info) { /* System generated locals */ address a__1[2]; integer a_dim1, a_offset, c_dim1, c_offset, i__1, i__2, i__3[2], i__4, i__5; char ch__1[2]; /* Local variables */ logical left; integer i__; extern logical lsame_(char *, char *); integer nbmin, iinfo, i1, i2, i3, ib, nb; extern /* Subroutine */ int sormr2_(char *, char *, integer *, integer *, integer *, real *, integer *, real *, real *, integer *, real *, integer *); integer mi, ni, nq, nw; extern /* Subroutine */ int slarfb_(char *, char *, char *, char *, integer *, integer *, integer *, real *, integer *, real *, integer *, real *, integer *, real *, integer *), xerbla_(char *, integer *, ftnlen); extern integer ilaenv_(integer *, char *, char *, integer *, integer *, integer *, integer *, ftnlen, ftnlen); extern /* Subroutine */ int slarft_(char *, char *, integer *, integer *, real *, integer *, real *, real *, integer *); logical notran; integer ldwork; char transt[1]; integer lwkopt; logical lquery; integer iwt; /* -- LAPACK computational routine (version 3.7.0) -- */ /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ /* December 2016 */ /* ===================================================================== */ /* Test the input arguments */ /* Parameter adjustments */ a_dim1 = *lda; a_offset = 1 + a_dim1 * 1; a -= a_offset; --tau; c_dim1 = *ldc; c_offset = 1 + c_dim1 * 1; c__ -= c_offset; --work; /* Function Body */ *info = 0; left = lsame_(side, "L"); notran = lsame_(trans, "N"); lquery = *lwork == -1; /* NQ is the order of Q and NW is the minimum dimension of WORK */ if (left) { nq = *m; nw = f2cmax(1,*n); } else { nq = *n; nw = f2cmax(1,*m); } if (! left && ! lsame_(side, "R")) { *info = -1; } else if (! notran && ! lsame_(trans, "T")) { *info = -2; } else if (*m < 0) { *info = -3; } else if (*n < 0) { *info = -4; } else if (*k < 0 || *k > nq) { *info = -5; } else if (*lda < f2cmax(1,*k)) { *info = -7; } else if (*ldc < f2cmax(1,*m)) { *info = -10; } else if (*lwork < nw && ! lquery) { *info = -12; } if (*info == 0) { /* Compute the workspace requirements */ if (*m == 0 || *n == 0) { lwkopt = 1; } else { /* Computing MIN */ /* Writing concatenation */ i__3[0] = 1, a__1[0] = side; i__3[1] = 1, a__1[1] = trans; s_cat(ch__1, a__1, i__3, &c__2, (ftnlen)2); i__1 = 64, i__2 = ilaenv_(&c__1, "SORMRQ", ch__1, m, n, k, &c_n1, (ftnlen)6, (ftnlen)2); nb = f2cmin(i__1,i__2); lwkopt = nw * nb + 4160; } work[1] = (real) lwkopt; } if (*info != 0) { i__1 = -(*info); xerbla_("SORMRQ", &i__1, (ftnlen)6); return 0; } else if (lquery) { return 0; } /* Quick return if possible */ if (*m == 0 || *n == 0) { return 0; } nbmin = 2; ldwork = nw; if (nb > 1 && nb < *k) { if (*lwork < nw * nb + 4160) { nb = (*lwork - 4160) / ldwork; /* Computing MAX */ /* Writing concatenation */ i__3[0] = 1, a__1[0] = side; i__3[1] = 1, a__1[1] = trans; s_cat(ch__1, a__1, i__3, &c__2, (ftnlen)2); i__1 = 2, i__2 = ilaenv_(&c__2, "SORMRQ", ch__1, m, n, k, &c_n1, ( ftnlen)6, (ftnlen)2); nbmin = f2cmax(i__1,i__2); } } if (nb < nbmin || nb >= *k) { /* Use unblocked code */ sormr2_(side, trans, m, n, k, &a[a_offset], lda, &tau[1], &c__[ c_offset], ldc, &work[1], &iinfo); } else { /* Use blocked code */ iwt = nw * nb + 1; if (left && ! notran || ! left && notran) { i1 = 1; i2 = *k; i3 = nb; } else { i1 = (*k - 1) / nb * nb + 1; i2 = 1; i3 = -nb; } if (left) { ni = *n; } else { mi = *m; } if (notran) { *(unsigned char *)transt = 'T'; } else { *(unsigned char *)transt = 'N'; } i__1 = i2; i__2 = i3; for (i__ = i1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) { /* Computing MIN */ i__4 = nb, i__5 = *k - i__ + 1; ib = f2cmin(i__4,i__5); /* Form the triangular factor of the block reflector */ /* H = H(i+ib-1) . . . H(i+1) H(i) */ i__4 = nq - *k + i__ + ib - 1; slarft_("Backward", "Rowwise", &i__4, &ib, &a[i__ + a_dim1], lda, &tau[i__], &work[iwt], &c__65); if (left) { /* H or H**T is applied to C(1:m-k+i+ib-1,1:n) */ mi = *m - *k + i__ + ib - 1; } else { /* H or H**T is applied to C(1:m,1:n-k+i+ib-1) */ ni = *n - *k + i__ + ib - 1; } /* Apply H or H**T */ slarfb_(side, transt, "Backward", "Rowwise", &mi, &ni, &ib, &a[ i__ + a_dim1], lda, &work[iwt], &c__65, &c__[c_offset], ldc, &work[1], &ldwork); /* L10: */ } } work[1] = (real) lwkopt; return 0; /* End of SORMRQ */ } /* sormrq_ */
the_stack_data/225142402.c
#include <err.h> #include <errno.h> #include <grp.h> #include <libgen.h> #include <pwd.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> static void usage(int ex) { fprintf( stderr , "usage: getgrent -h\n" "usage: getgrent [-Nq] -t USER GROUP\n" "usage: getgrent [-FNgmnpq] GROUP\n" ); if (ex != 0) exit(ex); fprintf( stderr , "\n" "Display group(5) info for a group\n" "\n" " Options:\n" " -h Display this message\n" " -F Omit field names from output\n" " -N GROUP and USER are group and user ids, not names\n" " -g Display group id\n" " -m Display group members\n" " -n Display group name\n" #ifdef __FreeBSD__ " -p Display encrypted password\n" #endif " -q No error message for nonexistent GROUP or USER\n" " -t USER Test whether USER in is GROUP\n" " Operands:\n" " GROUP Display information for group GROUP\n" ); exit(ex); } #define bit(opt) \ (1 << (opt - 'a')) static void enable(uint32_t *opts, char opt) { *opts |= bit(opt); } static int is_on(uint32_t opts, char opt) { return opts & bit(opt); } #define field(rec, fmt, fname) \ do { \ printf("%s" fmt "\n", (names ? #fname "=" : ""), (rec)->gr_ ## fname); \ } while (0) int main(int argc, char **argv) { char const *progname = basename(argv[0]); uint32_t opts = 0; int input_id = 0; int names = 1; int noerror = 0; int membertest = 0; char const *testee = NULL; int opt; while ((opt = getopt(argc, argv, ":hFNgmnpqt:")) > -1) { switch (opt) { case 'g': // gid case 'm': // members case 'n': // name case 'p': // passwd enable(&opts, opt); break; case 'F': // no field names names = 0; break; case 'N': // GROUP, USER are ids, not names input_id = 1; break; case 'q': // quiet: no error for nonexistent group or user noerror = 1; break; case 't': membertest = 1; testee = optarg; break; case 'h': usage(0); case '?': default: fprintf(stderr, "%s: invalid option -- '%c'\n" , progname , optopt ); usage(1); } } argc -= optind; argv += optind; if (argc != 1) usage(1); char const *arg = argv[0]; struct group *gr; uid_t uid; if (input_id) { const char *err; gid_t gid = strtonum(arg, 0, UINT32_MAX, &err); if (err) errx(1, "gid value is %s: %s", err, arg); if (membertest) { uid = strtonum(testee, 0, UINT32_MAX, &err); if (err) errx(1, "uid value is %s: %s", err, testee); } gr = getgrgid(gid); } else { gr = getgrnam(arg); } if (!gr) errno ? err(1, NULL) : noerror ? exit(1) : errx(1, "%s: no such group", arg) ; if (membertest) { struct passwd *pw; if (input_id) { pw = getpwuid(uid); } else { pw = getpwnam(testee); } if (!pw) errno ? err(1, NULL) : noerror ? exit(1) : errx(1, "%s: no such user", testee) ; for (char **p = gr->gr_mem; *p != NULL; ++p) if (0 == strcmp(*p, pw->pw_name)) exit(0); exit(1); } // output in field order in group(5) if (is_on(opts, 'n')) field(gr, "%s", name); if (is_on(opts, 'p')) field(gr, "%s", passwd); if (is_on(opts, 'g')) field(gr, "%d", gid); if (is_on(opts, 'm')) { int memcnt = 0; for (char **p = gr->gr_mem; *p != NULL; ++p) ++memcnt; printf("members=%d\n", memcnt); for (int i = 0; i < memcnt; ++i) { printf("member_%d=%s\n", i, gr->gr_mem[i]); } } return 0; }
the_stack_data/198580880.c
/* Program to demonstrate following bitwise operators as per priority and associtavity: a. <<, >> (L->R) b. & (L->R) c. ^ (L->R) d. | (L->R) */ #include <stdio.h> int main() { /* Note: bitwise values of integers used are as follows: 2: 010, 4:100, 5:101, 3: 011, 7: 111, 8: 1000 */ int num = 8; printf("Result of left shift, << by 2: %d\n", num << 2); printf("Result of right shift, >> by 2: %d\n", num >> 2); printf("Result of bitwise and, & by 2: %d\n", 4 & 5); printf("Result of bitwise xor, ^ by 2: %d\n", 7 ^ 3); printf("Result of left or, | by 2: %d\n", 5 | 3); return 0; }
the_stack_data/55441.c
#include <signal.h> #include <stdio.h> #include <unistd.h> int c[10000000]; int main() { int a, b; scanf("%d%d", &a, &b); for (int i = 0; i < 1000000; i++) c[i] = i; printf("%d\n", a + b); return 0; }
the_stack_data/72307.c
#include <threads.h> #include <pthread.h> int cnd_wait(cnd_t *cond, mtx_t *mtx) { return pthread_cond_wait(cond, mtx) == 0 ? thrd_success : thrd_error; } /* STDC(201112) */
the_stack_data/218893113.c
/* Copyright (c) 1990-1999 Info-ZIP. All rights reserved. See the accompanying file LICENSE, version 1999-Oct-05 or later (the contents of which are also included in zip.h) for terms of use. If, for some reason, both of these files are missing, the Info-ZIP license also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html */ /* crypt.c (dummy version) by Info-ZIP. Last revised: 15 Aug 98 This is a non-functional version of Info-ZIP's crypt.c encryption/ decryption code for Zip, ZipCloak, UnZip and fUnZip. This file is not copyrighted and may be distributed freely. :-) See the "WHERE" file for sites from which to obtain the full encryption/decryption sources (zcrypt28.zip or later). */ /* something "externally visible" to shut up compiler/linker warnings */ int zcr_dummy;
the_stack_data/92641.c
/* -*- Last-Edit: Fri Jan 29 11:13:27 1993 by Tarak S. Goradia; -*- */ /* $Log: tcas.c,v $ * Revision 1.2 1993/03/12 19:29:50 foster * Correct logic bug which didn't allow output of 2 - hf * */ #include <stdio.h> #define OLEV 600 /* in feets/minute */ #define MAXALTDIFF 600 /* max altitude difference in feet */ #define MINSEP 300 /* min separation in feet */ #define NOZCROSS 100 /* in feet */ /* variables */ typedef int bool; int Cur_Vertical_Sep; bool High_Confidence; bool Two_of_Three_Reports_Valid; int Own_Tracked_Alt; int Own_Tracked_Alt_Rate; int Other_Tracked_Alt; int Alt_Layer_Value; /* 0, 1, 2, 3 */ int Positive_RA_Alt_Thresh[4]; int Up_Separation; int Down_Separation; /* state variables */ int Other_RAC; /* NO_INTENT, DO_NOT_CLIMB, DO_NOT_DESCEND */ #define NO_INTENT 0 #define DO_NOT_CLIMB 1 #define DO_NOT_DESCEND 2 int Other_Capability; /* TCAS_TA, OTHER */ #define TCAS_TA 1 #define OTHER 2 int Climb_Inhibit; /* true/false */ #define UNRESOLVED 0 #define UPWARD_RA 1 #define DOWNWARD_RA 2 void initialize() { Positive_RA_Alt_Thresh[0] = 400; Positive_RA_Alt_Thresh[1] = 500; Positive_RA_Alt_Thresh[2] = 640; Positive_RA_Alt_Thresh[3] = 740; } int ALIM () { return Positive_RA_Alt_Thresh[Alt_Layer_Value]; } int Inhibit_Biased_Climb () { return (Climb_Inhibit ? Up_Separation : Up_Separation); } bool Non_Crossing_Biased_Climb() { int upward_preferred; int upward_crossing_situation; bool result; upward_preferred = Inhibit_Biased_Climb() > Down_Separation; if (upward_preferred) { result = !(Own_Below_Threat()) || ((Own_Below_Threat()) && (!(Down_Separation >= ALIM()))); } else { result = Own_Above_Threat() && (Cur_Vertical_Sep >= MINSEP) && (Up_Separation >= ALIM()); } return result; } bool Non_Crossing_Biased_Descend() { int upward_preferred; int upward_crossing_situation; bool result; upward_preferred = Inhibit_Biased_Climb() > Down_Separation; if (upward_preferred) { result = Own_Below_Threat() && (Cur_Vertical_Sep >= MINSEP) && (Down_Separation >= ALIM()); } else { result = !(Own_Above_Threat()) || ((Own_Above_Threat()) && (Up_Separation >= ALIM())); } return result; } bool Own_Below_Threat() { return (Own_Tracked_Alt < Other_Tracked_Alt); } bool Own_Above_Threat() { return (Other_Tracked_Alt < Own_Tracked_Alt); } int alt_sep_test() { bool enabled, tcas_equipped, intent_not_known; bool need_upward_RA, need_downward_RA; int alt_sep; enabled = High_Confidence && (Own_Tracked_Alt_Rate <= OLEV) && (Cur_Vertical_Sep > MAXALTDIFF); tcas_equipped = Other_Capability == TCAS_TA; intent_not_known = Two_of_Three_Reports_Valid && Other_RAC == NO_INTENT; alt_sep = UNRESOLVED; if (enabled && ((tcas_equipped && intent_not_known) || !tcas_equipped)) { need_upward_RA = Non_Crossing_Biased_Climb() && Own_Below_Threat(); need_downward_RA = Non_Crossing_Biased_Descend() && Own_Above_Threat(); if (need_upward_RA && need_downward_RA) /* unreachable: requires Own_Below_Threat and Own_Above_Threat to both be true - that requires Own_Tracked_Alt < Other_Tracked_Alt and Other_Tracked_Alt < Own_Tracked_Alt, which isn't possible */ alt_sep = UNRESOLVED; else if (need_upward_RA) alt_sep = UPWARD_RA; else if (need_downward_RA) alt_sep = DOWNWARD_RA; else alt_sep = UNRESOLVED; } return alt_sep; } main(argc, argv) int argc; char *argv[]; { if(argc < 13) { fprintf(stdout, "Error: Command line arguments are\n"); fprintf(stdout, "Cur_Vertical_Sep, High_Confidence, Two_of_Three_Reports_Valid\n"); fprintf(stdout, "Own_Tracked_Alt, Own_Tracked_Alt_Rate, Other_Tracked_Alt\n"); fprintf(stdout, "Alt_Layer_Value, Up_Separation, Down_Separation\n"); fprintf(stdout, "Other_RAC, Other_Capability, Climb_Inhibit\n"); exit(1); } initialize(); Cur_Vertical_Sep = atoi(argv[1]); High_Confidence = atoi(argv[2]); Two_of_Three_Reports_Valid = atoi(argv[3]); Own_Tracked_Alt = atoi(argv[4]); Own_Tracked_Alt_Rate = atoi(argv[5]); Other_Tracked_Alt = atoi(argv[6]); Alt_Layer_Value = atoi(argv[7]); Up_Separation = atoi(argv[8]); Down_Separation = atoi(argv[9]); Other_RAC = atoi(argv[10]); Other_Capability = atoi(argv[11]); Climb_Inhibit = atoi(argv[12]); fprintf(stdout, "%d\n", alt_sep_test()); exit(0); }
the_stack_data/12637371.c
#include <stdio.h> #include <stdint.h> void print_prime_factors(uint64_t n) { uint64_t i = 0; uint64_t nPrime = n; printf("%ju : ", n); for( i = 2 ; i <= nPrime ; i ++) { if(nPrime%i == 0) { nPrime = nPrime/i; printf("%ju ", i); fflush(stdout); i = 1; } else if(nPrime < 2 || nPrime > n) { break; } } printf("\r\n"); } int main(void) { print_prime_factors(77); // expected result: 77: 7 11 print_prime_factors(84); // expected result: 84: 2 2 3 7 // expected result: 429496729675917: 3 18229 7853726291 print_prime_factors(429496729675917); return 0; }
the_stack_data/674235.c
/* -*- linux-c -*- ------------------------------------------------------- * * * Copyright 2002-2007 H. Peter Anvin - All Rights Reserved * * This file is part of the Linux kernel, and is made available under * the terms of the GNU General Public License version 2 or (at your * option) any later version; incorporated herein by reference. * * ----------------------------------------------------------------------- */ /* * mktables.c * * Make RAID-6 tables. This is a host user space program to be run at * compile time. */ #include <stdio.h> #include <string.h> #include <inttypes.h> #include <stdlib.h> #include <time.h> static uint8_t gfmul(uint8_t a, uint8_t b) { uint8_t v = 0; while (b) { if (b & 1) v ^= a; a = (a << 1) ^ (a & 0x80 ? 0x1d : 0); b >>= 1; } return v; } static uint8_t gfpow(uint8_t a, int b) { uint8_t v = 1; b %= 255; if (b < 0) b += 255; while (b) { if (b & 1) v = gfmul(v, a); a = gfmul(a, a); b >>= 1; } return v; } int main(int argc, char *argv[]) { int i, j, k; uint8_t v; uint8_t exptbl[256], invtbl[256]; printf("#include <linux/raid/pq.h>\n"); printf("#include <linux/export.h>\n"); /* Compute multiplication table */ printf("\nconst u8 __attribute__((aligned(256)))\n" "raid6_gfmul[256][256] =\n" "{\n"); for (i = 0; i < 256; i++) { printf("\t{\n"); for (j = 0; j < 256; j += 8) { printf("\t\t"); for (k = 0; k < 8; k++) printf("0x%02x,%c", gfmul(i, j + k), (k == 7) ? '\n' : ' '); } printf("\t},\n"); } printf("};\n"); printf("#ifdef __KERNEL__\n"); printf("EXPORT_SYMBOL(raid6_gfmul);\n"); printf("#endif\n"); /* Compute power-of-2 table (exponent) */ v = 1; printf("\nconst u8 __attribute__((aligned(256)))\n" "raid6_gfexp[256] =\n" "{\n"); for (i = 0; i < 256; i += 8) { printf("\t"); for (j = 0; j < 8; j++) { exptbl[i + j] = v; printf("0x%02x,%c", v, (j == 7) ? '\n' : ' '); v = gfmul(v, 2); if (v == 1) v = 0; /* For entry 255, not a real entry */ } } printf("};\n"); printf("#ifdef __KERNEL__\n"); printf("EXPORT_SYMBOL(raid6_gfexp);\n"); printf("#endif\n"); /* Compute inverse table x^-1 == x^254 */ printf("\nconst u8 __attribute__((aligned(256)))\n" "raid6_gfinv[256] =\n" "{\n"); for (i = 0; i < 256; i += 8) { printf("\t"); for (j = 0; j < 8; j++) { invtbl[i + j] = v = gfpow(i + j, 254); printf("0x%02x,%c", v, (j == 7) ? '\n' : ' '); } } printf("};\n"); printf("#ifdef __KERNEL__\n"); printf("EXPORT_SYMBOL(raid6_gfinv);\n"); printf("#endif\n"); /* Compute inv(2^x + 1) (exponent-xor-inverse) table */ printf("\nconst u8 __attribute__((aligned(256)))\n" "raid6_gfexi[256] =\n" "{\n"); for (i = 0; i < 256; i += 8) { printf("\t"); for (j = 0; j < 8; j++) printf("0x%02x,%c", invtbl[exptbl[i + j] ^ 1], (j == 7) ? '\n' : ' '); } printf("};\n"); printf("#ifdef __KERNEL__\n"); printf("EXPORT_SYMBOL(raid6_gfexi);\n"); printf("#endif\n"); return 0; }
the_stack_data/1067203.c
#include <assert.h> #include <elf.h> #include <errno.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/stat.h> Elf32_Phdr * read_exec_file(FILE **execfile, Elf32_Ehdr **ehdr) { //*execfile = fopen(filename, "rb"); //assert(execfile); *ehdr = (Elf32_Ehdr *) malloc (512 * sizeof(uint8_t)); fread( *ehdr, 512, 1, *execfile ); //printf( "%d\n", (*ehdr)->e_phoff ); Elf32_Phdr *phdr; phdr = (Elf32_Phdr *) malloc ((512 - (*ehdr)->e_phoff) * sizeof(uint8_t)); fseek(*execfile, (*ehdr)->e_phoff, SEEK_SET); fread (phdr, 512 - (*ehdr)->e_phoff, 1, *execfile ); //printf( "%d\n", phdr->p_memsz ); return phdr; } void write_boot(FILE **imagefile, FILE *boot_file, Elf32_Ehdr *boot_header, Elf32_Phdr *boot_phdr, int *count) { int i; for ( i = 0; i < boot_header->e_phnum; i++ ) { if( boot_phdr[i].p_type == PT_LOAD ){//need write to image *count += boot_phdr[i].p_filesz; int test = fseek(boot_file, boot_phdr[i].p_offset, SEEK_SET);//seek to the beginning of the section assert(!test); //read to buf and write to image uint8_t buf[boot_phdr[i].p_filesz]; fread(buf, boot_phdr[i].p_filesz, 1, boot_file); fwrite(buf, boot_phdr[i].p_filesz, 1, *imagefile); } } //printf( "countboot = %d\n", *count ); //write zero to the left bytes uint8_t zero[512 - *count - 2 ]; for ( i = 0; i < 512 - *count -2 ; i++ ) { zero[i] = 0; } //write 0x55 and 0xaa to the last two bytes of the first sector. uint8_t end[2] = {85,170}; fwrite(zero, 512 - *count - 2, 1, *imagefile); fwrite(end, 2, 1, *imagefile); } void write_kernel(FILE **image_file, FILE *kernel_file, Elf32_Ehdr *kernel_ehdr, Elf32_Phdr *kernel_phdr, int *count) { int i; for ( i = 0; i < kernel_ehdr->e_phnum; i++ ) { if( kernel_phdr[i].p_type == PT_LOAD ){//need write to image *count += kernel_phdr[i].p_filesz; int test = fseek(kernel_file, kernel_phdr[i].p_offset, SEEK_SET);//seek to the beginning of the section assert(!test); //read to buf and write to image uint8_t buf[kernel_phdr[i].p_filesz]; fread(buf, kernel_phdr[i].p_filesz, 1, kernel_file); fwrite(buf, kernel_phdr[i].p_filesz, 1, *image_file); } } //printf( "countkernel = %d\n", *count ); //write zero to the left bytes int co = *count % 512; uint8_t zero[512 - co]; for ( i = 0; i < 512 - co; i++ ) { zero[i] = 0; } fwrite(zero, 512 - co, 1, *image_file); } int count_kernel_sectors(Elf32_Ehdr *kernel_header, Elf32_Phdr *kernel_phdr){ int i, count = 0; for ( i = 0; i < kernel_header->e_phnum; i++ ) { if ( kernel_phdr[i].p_type == PT_LOAD ) count += kernel_phdr[i].p_filesz; } return (count + 511) >> 9; } void record_kernel_sectors(FILE **image_file, int num_sec){ int test = fseek(*image_file, 0x1f8, SEEK_SET);//seek to the second inst of bootblock assert( !test ); int bytes = num_sec * 512; //LI $6, 0x200 * num_sec //printf ("!!!!!!!!!!!!!\n%d\n %d\n !!!!!!!!!!!!",num_sec, bytes); fwrite(&bytes, 4, 1, *image_file );//modify the image file } void extended_opt(Elf32_Ehdr *boot_ehdr, Elf32_Ehdr *kernel_ehdr, Elf32_Phdr *boot_phdr, Elf32_Phdr *kernel_phdr, int cb, int ck, int cp1, int cp2, int cp3, int cps){ struct stat buf_boot, buf_kernel; stat("bootblock", &buf_boot); stat("kernel", &buf_kernel); printf("\nlength_of_bootblock = %d\n", (int)buf_boot.st_size); printf( "p_offset = %d, p_filesz = %d\n",boot_phdr->p_offset, boot_phdr->p_filesz ); printf( "length_of_kernel = %d\n", (int)buf_kernel.st_size ); int ker_sec = count_kernel_sectors(kernel_ehdr, kernel_phdr); printf( "kernel_sectors: = %d\n", ker_sec ); printf( "p_offset = %d, p_filesz = %d\n",kernel_phdr->p_offset, kernel_phdr->p_filesz ); printf( "kernel_phdr->p_offset = %d\n\n", kernel_phdr->p_offset ); printf( "bootblock image info\n" ); int boot_sec = count_kernel_sectors(boot_ehdr, boot_phdr); printf( "sectors = %d\n", boot_sec ); printf( "offset of segment in the file: 0x%x\n", boot_phdr->p_offset ); printf("the image's virtural address of segment in memory: 0x%x\n", boot_phdr->p_vaddr); printf("the file image size of segment: 0x%x\n", boot_phdr->p_filesz ); printf("the memory image size of segment: 0x%x\n", boot_phdr->p_memsz); printf("size of write to the OS image: 0x%x\n", cb); printf("padding up to 0x200\n\n" ); printf( "kernel image info\n" ); printf( "sectors = %d\n", ker_sec ); printf( "offset of segment in the file: 0x%x\n", kernel_phdr->p_offset ); printf("the image's virtural address of segment in memory: 0x%x\n", kernel_phdr->p_vaddr); printf("the file image size of segment: 0x%x\n", kernel_phdr->p_filesz); printf("the memory image size of segment: 0x%x\n", kernel_phdr->p_memsz); printf("size of write to the OS image: 0x%x\n", ck); printf("padding up to 0x200\n\n" ); printf( "process 1 sectors = %d\n", cp1 ); printf( "process 2 sectors = %d\n", cp2 ); printf( "process 3 sectors = %d\n", cp3 ); printf( "process 4 sectors = %d\n", cps ); } void write_zero( FILE **fp, int sec_num ){ int bytes_num = 512 * sec_num; int zero[bytes_num]; for ( int i = 0; i < bytes_num; i++ ) zero[i] = 0; fwrite( zero, bytes_num, 1, *fp ); } int main(int argc, char *argv[]){ if (argc < 3) exit(0); Elf32_Ehdr *ehdr, *ehdrk, *ep1, *ep2, *ep3, *eps; Elf32_Phdr *phdr, *phdrk, *pp1, *pp2, *pp3, *pps; FILE *fp, *fpk, *p1, *p2, *p3, *ps; FILE *imfp = fopen("image", "w+"); p1 = fopen(argv[4], "rb"); p2 = fopen(argv[5], "rb"); p3 = fopen(argv[6], "rb"); ps = fopen(argv[7], "rb"); if(strcmp(argv[2], "bootblock") || strcmp(argv[3], "kernel")) exit(0); fp = fopen(argv[2], "rb"); assert(fp); fpk = fopen(argv[3], "rb"); assert(fpk); phdr = read_exec_file(&fp, &ehdr); phdrk = read_exec_file(&fpk, &ehdrk); pp1 = read_exec_file(&p1, &ep1); pp2 = read_exec_file(&p2, &ep2); pp3 = read_exec_file(&p3, &ep3); pps = read_exec_file(&ps, &eps); int ker_sec, p1_sec, p2_sec, boot_sec, p3_sec, ps_sec; ker_sec = count_kernel_sectors(ehdrk, phdrk); p1_sec = count_kernel_sectors(ep1, pp1); p2_sec = count_kernel_sectors(ep2, pp2); boot_sec = count_kernel_sectors(ehdr, phdr); p3_sec = count_kernel_sectors(ep3, pp3); ps_sec = count_kernel_sectors(eps, pps); int cb = 0, ck = 0; write_boot(&imfp, fp, ehdr, phdr, &cb);//write bootblock to image write_kernel(&imfp, fpk, ehdrk, phdrk, &ck);//write kernel to image write_zero( &imfp, 255 - ker_sec ); int temp1, temp2, temp3, temps; temp1 = temp2 = temp3 = temps = 0; write_kernel(&imfp, p1, ep1, pp1, &temp1 ); write_zero( &imfp, 16 - p1_sec ); write_kernel(&imfp, p2, ep2, pp2, &temp2); write_zero(&imfp, 16 - p2_sec); write_kernel( &imfp, p3, ep3, pp3, &temp3 ); write_zero( &imfp, 16 - p3_sec); write_kernel( &imfp, ps, eps, pps, &temps ); record_kernel_sectors( &imfp, 303 + p3_sec ); //printf ("===============\n %d\n==============", 303+p3_sec); if(!strcmp(argv[1], "--extended")) extended_opt(ehdr, ehdrk, phdr, phdrk, cb, ck, p1_sec, p2_sec, p3_sec, ps_sec); fclose(fp); fclose(fpk); fclose(imfp); fclose(p1); fclose(p2); }
the_stack_data/258008.c
//file: _insn_test_shli_X0.c //op=196 #include <stdio.h> #include <stdlib.h> void func_exit(void) { printf("%s\n", __func__); exit(0); } void func_call(void) { printf("%s\n", __func__); exit(0); } unsigned long mem[2] = { 0x555a73f8e7686b53, 0xca681c3c17f1785e }; int main(void) { unsigned long a[4] = { 0, 0 }; asm __volatile__ ( "moveli r3, -17698\n" "shl16insli r3, r3, -1407\n" "shl16insli r3, r3, 3238\n" "shl16insli r3, r3, 14331\n" "moveli r38, -19915\n" "shl16insli r38, r38, -2852\n" "shl16insli r38, r38, 32613\n" "shl16insli r38, r38, 14940\n" "{ shli r3, r38, 16 ; fnop }\n" "move %0, r3\n" "move %1, r38\n" :"=r"(a[0]),"=r"(a[1])); printf("%016lx\n", a[0]); printf("%016lx\n", a[1]); return 0; }
the_stack_data/36075564.c
/* ansi2knr.c */ /* Convert ANSI C function definitions to K&R ("traditional C") syntax */ /* ansi2knr is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY. No author or distributor accepts responsibility to anyone for the consequences of using it or for whether it serves any particular purpose or works at all, unless he says so in writing. Refer to the GNU General Public License (the "GPL") for full details. Everyone is granted permission to copy, modify and redistribute ansi2knr, but only under the conditions described in the GPL. A copy of this license is supposed to have been given to you along with ansi2knr so you can know your rights and responsibilities. It should be in a file named COPYLEFT. [In the IJG distribution, the GPL appears below, not in a separate file.] Among other things, the copyright notice and this notice must be preserved on all copies. We explicitly state here what we believe is already implied by the GPL: if the ansi2knr program is distributed as a separate set of sources and a separate executable file which are aggregated on a storage medium together with another program, this in itself does not bring the other program under the GPL, nor does the mere fact that such a program or the procedures for constructing it invoke the ansi2knr executable bring any other part of the program under the GPL. */ /* ---------- Here is the GNU GPL file COPYLEFT, referred to above ---------- ----- These terms do NOT apply to the JPEG software itself; see README ------ GHOSTSCRIPT GENERAL PUBLIC LICENSE (Clarified 11 Feb 1988) Copyright (C) 1988 Richard M. Stallman Everyone is permitted to copy and distribute verbatim copies of this license, but changing it is not allowed. You can also use this wording to make the terms for other programs. The license agreements of most software companies keep you at the mercy of those companies. By contrast, our general public license is intended to give everyone the right to share Ghostscript. To make sure that you get the rights we want you to have, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. Hence this license agreement. Specifically, we want to make sure that you have the right to give away copies of Ghostscript, that you receive source code or else can get it if you want it, that you can change Ghostscript or use pieces of it in new free programs, and that you know you can do these things. To make sure that everyone has such rights, we have to forbid you to deprive anyone else of these rights. For example, if you distribute copies of Ghostscript, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. Also, for our own protection, we must make certain that everyone finds out that there is no warranty for Ghostscript. If Ghostscript is modified by someone else and passed on, we want its recipients to know that what they have is not what we distributed, so that any problems introduced by others will not reflect on our reputation. Therefore we (Richard M. Stallman and the Free Software Foundation, Inc.) make the following terms which say what you must do to be allowed to distribute or change Ghostscript. COPYING POLICIES 1. You may copy and distribute verbatim copies of Ghostscript source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy a valid copyright and license notice "Copyright (C) 1989 Aladdin Enterprises. All rights reserved. Distributed by Free Software Foundation, Inc." (or with whatever year is appropriate); keep intact the notices on all files that refer to this License Agreement and to the absence of any warranty; and give any other recipients of the Ghostscript program a copy of this License Agreement along with the program. You may charge a distribution fee for the physical act of transferring a copy. 2. You may modify your copy or copies of Ghostscript or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains or is a derivative of Ghostscript or any part thereof, to be licensed at no charge to all third parties on terms identical to those contained in this License Agreement (except that you may choose to grant more extensive warranty protection to some or all third parties, at your option). c) You may charge a distribution fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another unrelated program with this program (or its derivative) on a volume of a storage or distribution medium does not bring the other program under the scope of these terms. 3. You may copy and distribute Ghostscript (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal shipping charge) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs. 4. You may not copy, sublicense, distribute or transfer Ghostscript except as expressly provided under this License Agreement. Any attempt otherwise to copy, sublicense, distribute or transfer Ghostscript is void and your rights to use the program under this License agreement shall be automatically terminated. However, parties who have received computer software programs from you with this License Agreement will not have their licenses terminated so long as such parties remain in full compliance. 5. If you wish to incorporate parts of Ghostscript into other free programs whose distribution conditions are different, write to the Free Software Foundation at 675 Mass Ave, Cambridge, MA 02139. We have not yet worked out a simple rule that can be stated here, but we will often permit this. We will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software. Your comments and suggestions about our licensing policies and our software are welcome! Please contact the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, or call (617) 876-3296. NO WARRANTY BECAUSE GHOSTSCRIPT IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC, RICHARD M. STALLMAN, ALADDIN ENTERPRISES, L. PETER DEUTSCH, AND/OR OTHER PARTIES PROVIDE GHOSTSCRIPT "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF GHOSTSCRIPT IS WITH YOU. SHOULD GHOSTSCRIPT PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M. STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., L. PETER DEUTSCH, ALADDIN ENTERPRISES, AND/OR ANY OTHER PARTY WHO MAY MODIFY AND REDISTRIBUTE GHOSTSCRIPT AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR OTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) GHOSTSCRIPT, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. -------------------- End of file COPYLEFT ------------------------------ */ /* * Usage: ansi2knr input_file [output_file] * If no output_file is supplied, output goes to stdout. * There are no error messages. * * ansi2knr recognizes function definitions by seeing a non-keyword * identifier at the left margin, followed by a left parenthesis, * with a right parenthesis as the last character on the line, * and with a left brace as the first token on the following line * (ignoring possible intervening comments). * It will recognize a multi-line header provided that no intervening * line ends with a left or right brace or a semicolon. * These algorithms ignore whitespace and comments, except that * the function name must be the first thing on the line. * The following constructs will confuse it: * - Any other construct that starts at the left margin and * follows the above syntax (such as a macro or function call). * - Some macros that tinker with the syntax of the function header. */ /* * The original and principal author of ansi2knr is L. Peter Deutsch * <[email protected]>. Other authors are noted in the change history * that follows (in reverse chronological order): lpd 96-01-21 added code to cope with not HAVE_CONFIG_H and with compilers that don't understand void, as suggested by Tom Lane lpd 96-01-15 changed to require that the first non-comment token on the line following a function header be a left brace, to reduce sensitivity to macros, as suggested by Tom Lane <[email protected]> lpd 95-06-22 removed #ifndefs whose sole purpose was to define undefined preprocessor symbols as 0; changed all #ifdefs for configuration symbols to #ifs lpd 95-04-05 changed copyright notice to make it clear that including ansi2knr in a program does not bring the entire program under the GPL lpd 94-12-18 added conditionals for systems where ctype macros don't handle 8-bit characters properly, suggested by Francois Pinard <[email protected]>; removed --varargs switch (this is now the default) lpd 94-10-10 removed CONFIG_BROKETS conditional lpd 94-07-16 added some conditionals to help GNU `configure', suggested by Francois Pinard <[email protected]>; properly erase prototype args in function parameters, contributed by Jim Avera <[email protected]>; correct error in writeblanks (it shouldn't erase EOLs) lpd 89-xx-xx original version */ /* Most of the conditionals here are to make ansi2knr work with */ /* or without the GNU configure machinery. */ #if HAVE_CONFIG_H # include <config.h> #endif #include <stdio.h> #include <ctype.h> #if HAVE_CONFIG_H /* For properly autoconfiguring ansi2knr, use AC_CONFIG_HEADER(config.h). This will define HAVE_CONFIG_H and so, activate the following lines. */ # if STDC_HEADERS || HAVE_STRING_H # include <string.h> # else # include <strings.h> # endif #else /* not HAVE_CONFIG_H */ /* Otherwise do it the hard way */ # ifdef BSD # include <strings.h> # else # ifdef VMS extern int strlen(), strncmp(); # else # include <string.h> # endif # endif #endif /* not HAVE_CONFIG_H */ #if STDC_HEADERS # include <stdlib.h> #else /* malloc and free should be declared in stdlib.h, but if you've got a K&R compiler, they probably aren't. */ # ifdef MSDOS # include <malloc.h> # else # ifdef VMS extern char *malloc(); extern void free(); # else //extern char *malloc(); //extern int free(); # endif # endif #endif /* * The ctype macros don't always handle 8-bit characters correctly. * Compensate for this here. */ #ifdef isascii # undef HAVE_ISASCII /* just in case */ # define HAVE_ISASCII 1 #else #endif #if STDC_HEADERS || !HAVE_ISASCII # define is_ascii(c) 1 #else # define is_ascii(c) isascii(c) #endif #define is_space(c) (is_ascii(c) && isspace(c)) #define is_alpha(c) (is_ascii(c) && isalpha(c)) #define is_alnum(c) (is_ascii(c) && isalnum(c)) /* Scanning macros */ #define isidchar(ch) (is_alnum(ch) || (ch) == '_') #define isidfirstchar(ch) (is_alpha(ch) || (ch) == '_') /* Forward references */ char *skipspace(); int writeblanks(); int test1(); int convert1(); /* The main program */ int main(argc, argv) int argc; char *argv[]; { FILE *in, *out; #define bufsize 5000 /* arbitrary size */ char *buf; char *line; char *more; /* * In previous versions, ansi2knr recognized a --varargs switch. * If this switch was supplied, ansi2knr would attempt to convert * a ... argument to va_alist and va_dcl; if this switch was not * supplied, ansi2knr would simply drop any such arguments. * Now, ansi2knr always does this conversion, and we only * check for this switch for backward compatibility. */ int convert_varargs = 1; if ( argc > 1 && argv[1][0] == '-' ) { if ( !strcmp(argv[1], "--varargs") ) { convert_varargs = 1; argc--; argv++; } else { fprintf(stderr, "Unrecognized switch: %s\n", argv[1]); exit(1); } } switch ( argc ) { default: printf("Usage: ansi2knr input_file [output_file]\n"); exit(0); case 2: out = stdout; break; case 3: out = fopen(argv[2], "w"); if ( out == NULL ) { fprintf(stderr, "Cannot open output file %s\n", argv[2]); exit(1); } } in = fopen(argv[1], "r"); if ( in == NULL ) { fprintf(stderr, "Cannot open input file %s\n", argv[1]); exit(1); } fprintf(out, "#line 1 \"%s\"\n", argv[1]); buf = malloc(bufsize); line = buf; while ( fgets(line, (unsigned)(buf + bufsize - line), in) != NULL ) { test: line += strlen(line); switch ( test1(buf) ) { case 2: /* a function header */ convert1(buf, out, 1, convert_varargs); break; case 1: /* a function */ /* Check for a { at the start of the next line. */ more = ++line; f: if ( line >= buf + (bufsize - 1) ) /* overflow check */ goto wl; if ( fgets(line, (unsigned)(buf + bufsize - line), in) == NULL ) goto wl; switch ( *skipspace(more, 1) ) { case '{': /* Definitely a function header. */ convert1(buf, out, 0, convert_varargs); fputs(more, out); break; case 0: /* The next line was blank or a comment: */ /* keep scanning for a non-comment. */ line += strlen(line); goto f; default: /* buf isn't a function header, but */ /* more might be. */ fputs(buf, out); strcpy(buf, more); line = buf; goto test; } break; case -1: /* maybe the start of a function */ if ( line != buf + (bufsize - 1) ) /* overflow check */ continue; /* falls through */ default: /* not a function */ wl: fputs(buf, out); break; } line = buf; } if ( line != buf ) fputs(buf, out); free(buf); fclose(out); fclose(in); return 0; } /* Skip over space and comments, in either direction. */ char * skipspace(p, dir) register char *p; register int dir; /* 1 for forward, -1 for backward */ { for ( ; ; ) { while ( is_space(*p) ) p += dir; if ( !(*p == '/' && p[dir] == '*') ) break; p += dir; p += dir; while ( !(*p == '*' && p[dir] == '/') ) { if ( *p == 0 ) return p; /* multi-line comment?? */ p += dir; } p += dir; p += dir; } return p; } /* * Write blanks over part of a string. * Don't overwrite end-of-line characters. */ int writeblanks(start, end) char *start; char *end; { char *p; for ( p = start; p < end; p++ ) if ( *p != '\r' && *p != '\n' ) *p = ' '; return 0; } /* * Test whether the string in buf is a function definition. * The string may contain and/or end with a newline. * Return as follows: * 0 - definitely not a function definition; * 1 - definitely a function definition; * 2 - definitely a function prototype (NOT USED); * -1 - may be the beginning of a function definition, * append another line and look again. * The reason we don't attempt to convert function prototypes is that * Ghostscript's declaration-generating macros look too much like * prototypes, and confuse the algorithms. */ int test1(buf) char *buf; { register char *p = buf; char *bend; char *endfn; int contin; if ( !isidfirstchar(*p) ) return 0; /* no name at left margin */ bend = skipspace(buf + strlen(buf) - 1, -1); switch ( *bend ) { case ';': contin = 0 /*2*/; break; case ')': contin = 1; break; case '{': return 0; /* not a function */ case '}': return 0; /* not a function */ default: contin = -1; } while ( isidchar(*p) ) p++; endfn = p; p = skipspace(p, 1); if ( *p++ != '(' ) return 0; /* not a function */ p = skipspace(p, 1); if ( *p == ')' ) return 0; /* no parameters */ /* Check that the apparent function name isn't a keyword. */ /* We only need to check for keywords that could be followed */ /* by a left parenthesis (which, unfortunately, is most of them). */ { static char *words[] = { "asm", "auto", "case", "char", "const", "double", "extern", "float", "for", "if", "int", "long", "register", "return", "short", "signed", "sizeof", "static", "switch", "typedef", "unsigned", "void", "volatile", "while", 0 }; char **key = words; char *kp; int len = endfn - buf; while ( (kp = *key) != 0 ) { if ( strlen(kp) == len && !strncmp(kp, buf, len) ) return 0; /* name is a keyword */ key++; } } return contin; } /* Convert a recognized function definition or header to K&R syntax. */ int convert1(buf, out, header, convert_varargs) char *buf; FILE *out; int header; /* Boolean */ int convert_varargs; /* Boolean */ { char *endfn; register char *p; char **breaks; unsigned num_breaks = 2; /* for testing */ char **btop; char **bp; char **ap; char *vararg = 0; /* Pre-ANSI implementations don't agree on whether strchr */ /* is called strchr or index, so we open-code it here. */ for ( endfn = buf; *(endfn++) != '('; ) ; top: p = endfn; breaks = (char **)malloc(sizeof(char *) * num_breaks * 2); if ( breaks == 0 ) { /* Couldn't allocate break table, give up */ fprintf(stderr, "Unable to allocate break table!\n"); fputs(buf, out); return -1; } btop = breaks + num_breaks * 2 - 2; bp = breaks; /* Parse the argument list */ do { int level = 0; char *lp = NULL; char *rp; char *end = NULL; if ( bp >= btop ) { /* Filled up break table. */ /* Allocate a bigger one and start over. */ free((char *)breaks); num_breaks <<= 1; goto top; } *bp++ = p; /* Find the end of the argument */ for ( ; end == NULL; p++ ) { switch(*p) { case ',': if ( !level ) end = p; break; case '(': if ( !level ) lp = p; level++; break; case ')': if ( --level < 0 ) end = p; else rp = p; break; case '/': p = skipspace(p, 1) - 1; break; default: ; } } /* Erase any embedded prototype parameters. */ if ( lp ) writeblanks(lp + 1, rp); p--; /* back up over terminator */ /* Find the name being declared. */ /* This is complicated because of procedure and */ /* array modifiers. */ for ( ; ; ) { p = skipspace(p - 1, -1); switch ( *p ) { case ']': /* skip array dimension(s) */ case ')': /* skip procedure args OR name */ { int level = 1; while ( level ) switch ( *--p ) { case ']': case ')': level++; break; case '[': case '(': level--; break; case '/': p = skipspace(p, -1) + 1; break; default: ; } } if ( *p == '(' && *skipspace(p + 1, 1) == '*' ) { /* We found the name being declared */ while ( !isidfirstchar(*p) ) p = skipspace(p, 1) + 1; goto found; } break; default: goto found; } } found: if ( *p == '.' && p[-1] == '.' && p[-2] == '.' ) { if ( convert_varargs ) { *bp++ = "va_alist"; vararg = p-2; } else { p++; if ( bp == breaks + 1 ) /* sole argument */ writeblanks(breaks[0], p); else writeblanks(bp[-1] - 1, p); bp--; } } else { while ( isidchar(*p) ) p--; *bp++ = p+1; } p = end; } while ( *p++ == ',' ); *bp = p; /* Make a special check for 'void' arglist */ if ( bp == breaks+2 ) { p = skipspace(breaks[0], 1); if ( !strncmp(p, "void", 4) ) { p = skipspace(p+4, 1); if ( p == breaks[2] - 1 ) { bp = breaks; /* yup, pretend arglist is empty */ writeblanks(breaks[0], p + 1); } } } /* Put out the function name and left parenthesis. */ p = buf; while ( p != endfn ) putc(*p, out), p++; /* Put out the declaration. */ if ( header ) { fputs(");", out); for ( p = breaks[0]; *p; p++ ) if ( *p == '\r' || *p == '\n' ) putc(*p, out); } else { for ( ap = breaks+1; ap < bp; ap += 2 ) { p = *ap; while ( isidchar(*p) ) putc(*p, out), p++; if ( ap < bp - 1 ) fputs(", ", out); } fputs(") ", out); /* Put out the argument declarations */ for ( ap = breaks+2; ap <= bp; ap += 2 ) (*ap)[-1] = ';'; if ( vararg != 0 ) { *vararg = 0; fputs(breaks[0], out); /* any prior args */ fputs("va_dcl", out); /* the final arg */ fputs(bp[0], out); } else fputs(breaks[0], out); } free((char *)breaks); return 0; }
the_stack_data/40764010.c
#include <stdio.h> int main() { int val1 = -11; int val2 = 3; int res; res = val1 % val2; printf("%d\n", res); return 0; }
the_stack_data/730217.c
/* Basic test case: make sure no useless renaming occurs for variables * * No renaming is observed, with or without initializations */ #include <stdio.h> int flatten_code19() { int i = 1; { int j = 2; j = 3; } i = 2; }
the_stack_data/98574313.c
#include <stdio.h> #include <string.h> #define MAXLINE 80 #define PAGELINE 20 main(int argc, char* argv[]) { char line[MAXLINE], *pattern; long lineno, pageno; FILE* fp; if (argc == 1) { printf("error: no files are named as arguments\n"); return -1; } else { while (--argc > 0) { if ((fp = fopen(*++argv, "r")) == NULL) { printf("find: can't open %s\n", *argv); continue; } lineno = 0; pageno = 1; printf("%s:\nPage %ld:\n", *argv, pageno); while (fgets(line, MAXLINE, fp) != NULL) { lineno++; printf("%s", line); if (lineno == PAGELINE) { lineno = 0; pageno++; printf("\nPage %ld:\n", pageno); } } printf("\n"); pageno++; } fclose(fp); } return pageno; }
the_stack_data/28262324.c
#include <stdio.h> int check(int x) { if (x > 0) { return(0); } else { return(1); } } int main() { int a; scanf("%d", &a); printf("%d\n", check(a)); return(0); }
the_stack_data/136569.c
/* american fuzzy lop - postprocessor for PNG ------------------------------------------ Written and maintained by Michal Zalewski <[email protected]> Copyright 2015 Google Inc. All rights reserved. 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 See post_library.so.c for a general discussion of how to implement postprocessors. This specific postprocessor attempts to fix up PNG checksums, providing a slightly more complicated example than found in post_library.so.c. Compile with: gcc -shared -Wall -O3 post_library_png.so.c -o post_library_png.so -lz */ #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <string.h> #include <zlib.h> #include <arpa/inet.h> /* A macro to round an integer up to 4 kB. */ #define UP4K(_i) ((((_i) >> 12) + 1) << 12) const unsigned char* afl_postprocess(const unsigned char* in_buf, unsigned int* len) { static unsigned char* saved_buf; static unsigned int saved_len; unsigned char* new_buf = (unsigned char*)in_buf; unsigned int pos = 8; /* Don't do anything if there's not enough room for the PNG header (8 bytes). */ if (*len < 8) return in_buf; /* Minimum size of a zero-length PNG chunk is 12 bytes; if we don't have that, we can bail out. */ while (pos + 12 <= *len) { unsigned int chunk_len, real_cksum, file_cksum; /* Chunk length is the first big-endian dword in the chunk. */ chunk_len = ntohl(*(uint32_t*)(in_buf + pos)); /* Bail out if chunk size is too big or goes past EOF. */ if (chunk_len > 1024 * 1024 || pos + 12 + chunk_len > *len) break; /* Chunk checksum is calculated for chunk ID (dword) and the actual payload. */ real_cksum = htonl(crc32(0, in_buf + pos + 4, chunk_len + 4)); /* The in-file checksum is the last dword past the chunk data. */ file_cksum = *(uint32_t*)(in_buf + pos + 8 + chunk_len); /* If the checksums do not match, we need to fix the file. */ if (real_cksum != file_cksum) { /* First modification? Make a copy of the input buffer. Round size up to 4 kB to minimize the number of reallocs needed. */ if (new_buf == in_buf) { if (*len <= saved_len) { new_buf = saved_buf; } else { new_buf = realloc(saved_buf, UP4K(*len)); if (!new_buf) return in_buf; saved_buf = new_buf; saved_len = UP4K(*len); memcpy(new_buf, in_buf, *len); } } *(uint32_t*)(new_buf + pos + 8 + chunk_len) = real_cksum; } /* Skip the entire chunk and move to the next one. */ pos += 12 + chunk_len; } return new_buf; }
the_stack_data/57912.c
/****************************************************************************** * FILE: omp_orphan.c * DESCRIPTION: * OpenMP Example - Parallel region with an orphaned directive - C/C++ Version * This example demonstrates a dot product being performed by an orphaned * loop reduction construct. Scoping of the reduction variable is critical. * AUTHOR: Blaise Barney 5/99 * LAST REVISED: 06/30/05 ******************************************************************************/ #include <omp.h> #include <stdio.h> #include <stdlib.h> #define VECLEN 100 float a[VECLEN], b[VECLEN], sum; float dotprod () { int i,tid; tid = omp_get_thread_num(); #pragma omp for reduction(+:sum) for (i=0; i < VECLEN; i++) { sum = sum + (a[i]*b[i]); printf(" tid= %d i=%d\n",tid,i); } } int main (int argc, char *argv[]) { int i; for (i=0; i < VECLEN; i++) a[i] = b[i] = 1.0 * i; sum = 0.0; #pragma omp parallel dotprod(); printf("Sum = %f\n",sum); }
the_stack_data/1149530.c
/* TAGS: min c */ /* LIFT_OPTS: explicit +--explicit_args +--explicit_args_count 8 */ /* LIFT_OPTS: default */ /* TEST: 12 */ /* TEST: 26 */ /* TEST: 2 */ /* * Copyright (c) 2018 Trail of Bits, Inc. * * 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 <stdio.h> #include <stdlib.h> unsigned int fib (unsigned int i) { if (i == 0) return 0; else if ((i == 1) || (i == 2)) return 1; else return fib (i - 1) + fib (i - 2); } int main (int argc, char **argv) { if (argc < 2) return 1; int n = atoi (argv [1]); printf ("%u\n", fib (n)); return 0; }
the_stack_data/590503.c
/* { dg-do compile } */ /* APPLE LOCAL strict alias off */ /* { dg-options "-O2 -fstrict-aliasing" } */ /* { dg-final { scan-assembler-not "undefined" } } */ /* Make sure we optimize all calls away. */ extern void undefined (void); struct s { int a, b; }; void bar (struct s *ps, int *p, int *__restrict__ rp, int *__restrict__ rq) { ps->a = 0; ps->b = 1; if (ps->a != 0) undefined (); p[0] = 0; p[1] = 1; if (p[0] != 0) undefined (); rp[0] = 0; rq[0] = 1; if (rp[0] != 0) undefined (); } int main (void) { return 0; }
the_stack_data/206392954.c
#include <stdio.h> #define CUBE(x) (x*x*x) int main() { int a, b=3; a = CUBE(b++); printf("%d\n%d\n",a,b); // print 11 if SQR(x) (x * x) }
the_stack_data/14200378.c
#include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <string.h> #include <x86intrin.h> #define TRANSPOSE4(row0, row1, row2, row3) \ do { \ __m128 tmp3, tmp2, tmp1, tmp0; \ tmp0 = _mm_unpacklo_ps((__m128)(row0), (__m128)(row1)); \ tmp2 = _mm_unpacklo_ps((__m128)(row2), (__m128)(row3)); \ tmp1 = _mm_unpackhi_ps((__m128)(row0), (__m128)(row1)); \ tmp3 = _mm_unpackhi_ps((__m128)(row2), (__m128)(row3)); \ row0 = (__m128i)_mm_movelh_ps(tmp0, tmp2); \ row1 = (__m128i)_mm_movehl_ps(tmp2, tmp0); \ row2 = (__m128i)_mm_movelh_ps(tmp1, tmp3); \ row3 = (__m128i)_mm_movehl_ps(tmp3, tmp1); \ } while (0) #define NB_LOOP 1000000000 int main() { __m128i data[4]; for (int i = 0; i < 4; i++) data[i] = _mm_set_epi64x(rand(),rand()); for (int i = 0; i < 100000; i++) TRANSPOSE4(data[0], data[1], data[2], data[3]); uint64_t timer = _rdtsc(); for (int i = 0; i < NB_LOOP; i++) TRANSPOSE4(data[0], data[1], data[2], data[3]); timer = _rdtsc() - timer; printf("%.2f cycles/byte\n", (double)timer / NB_LOOP / (16*4)); FILE* FP = fopen("/dev/null","w"); fwrite(data,16,4,FP); fclose(FP); }
the_stack_data/651820.c
#include <stdlib.h> #include <stdint.h> #include <sys/types.h> size_t utility_u32_len(uint32_t n) { static const uint32_t pow_10[] = {0, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000}; uint32_t t; t = (32 - __builtin_clz(n | 1)) * 1233 >> 12; return t - (n < pow_10[t]) + 1; } void utility_u32_sprint(uint32_t n, char *string) { static const char digits[] = "0001020304050607080910111213141516171819" "2021222324252627282930313233343536373839" "4041424344454647484950515253545556575859" "6061626364656667686970717273747576777879" "8081828384858687888990919293949596979899"; size_t i; while (n >= 100) { i = (n % 100) << 1; n /= 100; *--string = digits[i + 1]; *--string = digits[i]; } if (n < 10) { *--string = n + '0'; } else { i = n << 1; *--string = digits[i + 1]; *--string = digits[i]; } } void utility_u32_toa(uint32_t n, char *string) { size_t length; length = utility_u32_len(n); string += length; *string = 0; utility_u32_sprint(n, string); } uint64_t utility_tsc(void) { #if defined(__x86_64__) || defined(__amd64__) uint32_t lo, hi; __asm__ volatile("RDTSC" : "=a"(lo), "=d"(hi)); return (((uint64_t) hi) << 32) | lo; #else return 0; #endif }
the_stack_data/18416.c
#include <stdio.h> int main(void) { int matriz[5][5] = {{ 1, 2, 3, 4, 5}, { 6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}, {16, 17, 18, 19, 20}, {21, 22, 23, 24, 25}}; for (int i = 0; i < 5; ++i) { for (int j = 0; j < 5; ++j){ printf("%i ", matriz[i][j]); } printf("\n"); } return 0; }
the_stack_data/247144.c
#include <stdio.h> #include <stdlib.h> static int compareNum = 0; static int insertNum = 0; void binarySearch(int arr[], int num, int key){ int low = 1; int high = num;//数组的最大下标n-1 int mid ; while(low <= high) { mid = (low + high) / 2 ;//下标的一半,int类型除法取整。 if(key < arr[mid]) { high = mid + 1; compareNum++; } if(key == arr[mid] ) { printf("已找到数字%d。", key); break; } else { low = mid - 1; compareNum++; } } } int main() { printf("请输入要查找的数组队列(用空格分隔数组元素):\n"); int i = 0, num = 0, key = 0; int *arr = (int*)malloc(num*sizeof(int)); char s; do{ arr = (int*)realloc(arr, ++num*sizeof(int)); scanf("%d", &arr[i++]); }while((s = getchar() != '\n')); printf("请输入要查找的数字:\n"); scanf("%d", &key); binarySearch(arr, num, key); printf("\n查找的次数为:%d\n", compareNum); free(arr); arr = NULL; system("pause"); return 0; }
the_stack_data/1099581.c
/* * Copyright (c) 2013, 2014 Jan-Piet Mens <[email protected]> * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. 2. Redistributions * in binary form must reproduce the above copyright notice, this list of * conditions and the following disclaimer in the documentation and/or other * materials provided with the distribution. 3. Neither the name of mosquitto * nor the names of its contributors may be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #ifdef BE_MYSQL #include <stdio.h> #include <stdlib.h> #include <string.h> #include <mosquitto.h> #include "be-mysql.h" #include "log.h" #include "hash.h" #include "backends.h" struct mysql_backend { MYSQL *mysql; char *host; int port; char *dbname; char *user; char *pass; bool auto_connect; char *userquery; //MUST return 1 row, 1 column char *superquery; //MUST return 1 row, 1 column,[0, 1] char *aclquery; //MAY return n rows, 1 column, string }; static char *get_bool(char *option, char *defval) { char *flag = p_stab(option); flag = flag ? flag : defval; if (!strcmp("true", flag) || !strcmp("false", flag)) { return flag; } _log(LOG_NOTICE, "WARN: %s is unexpected value -> %s", option, flag); return defval; } void *be_mysql_init() { struct mysql_backend *conf; char *host, *user, *pass, *dbname, *p; char *ssl_ca, *ssl_capath, *ssl_cert, *ssl_cipher, *ssl_key; char *userquery; char *opt_flag; int port; bool ssl_enabled; my_bool reconnect = false; _log(LOG_DEBUG, "}}}} MYSQL"); host = p_stab("host"); p = p_stab("port"); user = p_stab("user"); pass = p_stab("pass"); dbname = p_stab("dbname"); opt_flag = get_bool("ssl_enabled", "false"); if (!strcmp("true", opt_flag)) { ssl_enabled = true; _log(LOG_DEBUG, "SSL is enabled"); } else{ ssl_enabled = false; _log(LOG_DEBUG, "SSL is disabled"); } ssl_key = p_stab("ssl_key"); ssl_cert = p_stab("ssl_cert"); ssl_ca = p_stab("ssl_ca"); ssl_capath = p_stab("ssl_capath"); ssl_cipher = p_stab("ssl_cipher"); host = (host) ? host : strdup("localhost"); port = (!p) ? 3306 : atoi(p); userquery = p_stab("userquery"); if (!userquery) { _fatal("Mandatory option 'userquery' is missing"); return (NULL); } if ((conf = (struct mysql_backend *)malloc(sizeof(struct mysql_backend))) == NULL) return (NULL); conf->mysql = mysql_init(NULL); conf->host = host; conf->port = port; conf->user = user; conf->pass = pass; conf->auto_connect = false; conf->dbname = dbname; conf->userquery = userquery; conf->superquery = p_stab("superquery"); conf->aclquery = p_stab("aclquery"); if(ssl_enabled){ mysql_ssl_set(conf->mysql, ssl_key, ssl_cert, ssl_ca, ssl_capath, ssl_cipher); } opt_flag = get_bool("mysql_auto_connect", "true"); if (!strcmp("true", opt_flag)) { conf->auto_connect = true; } opt_flag = get_bool("mysql_opt_reconnect", "true"); if (!strcmp("true", opt_flag)) { reconnect = true; mysql_options(conf->mysql, MYSQL_OPT_RECONNECT, &reconnect); } if (!mysql_real_connect(conf->mysql, host, user, pass, dbname, port, NULL, 0)) { _log(LOG_NOTICE, "%s", mysql_error(conf->mysql)); if (!conf->auto_connect && !reconnect) { free(conf); mysql_close(conf->mysql); return (NULL); } } return ((void *)conf); } void be_mysql_destroy(void *handle) { struct mysql_backend *conf = (struct mysql_backend *)handle; if (conf) { mysql_close(conf->mysql); if (conf->userquery) free(conf->userquery); if (conf->superquery) free(conf->superquery); if (conf->aclquery) free(conf->aclquery); free(conf); } } static char *escape(void *handle, const char *value, long *vlen) { struct mysql_backend *conf = (struct mysql_backend *)handle; char *v; *vlen = strlen(value) * 2 + 1; if ((v = malloc(*vlen)) == NULL) return (NULL); mysql_real_escape_string(conf->mysql, v, value, strlen(value)); return (v); } static bool auto_connect(struct mysql_backend *conf) { if (conf->auto_connect) { if (!mysql_real_connect(conf->mysql, conf->host, conf->user, conf->pass, conf->dbname, conf->port, NULL, 0)) { fprintf(stderr, "do auto_connect but %s\n", mysql_error(conf->mysql)); return false; } return true; } return false; } int be_mysql_getuser(void *handle, const char *username, const char *password, char **phash) { struct mysql_backend *conf = (struct mysql_backend *)handle; char *query = NULL, *u = NULL, *value = NULL, *v; long nrows, ulen; MYSQL_RES *res = NULL; MYSQL_ROW rowdata; if (!conf || !conf->userquery || !username || !*username) return BACKEND_DEFER; if (mysql_ping(conf->mysql)) { fprintf(stderr, "%s\n", mysql_error(conf->mysql)); if (!auto_connect(conf)) { return BACKEND_ERROR; } } if ((u = escape(conf, username, &ulen)) == NULL) return BACKEND_ERROR; if ((query = malloc(strlen(conf->userquery) + ulen + 128)) == NULL) { free(u); return BACKEND_ERROR; } sprintf(query, conf->userquery, u); free(u); if (mysql_query(conf->mysql, query)) { fprintf(stderr, "%s\n", mysql_error(conf->mysql)); goto out; } res = mysql_store_result(conf->mysql); if ((nrows = mysql_num_rows(res)) != 1) { //DEBUG fprintf(stderr, "rowcount = %ld; not ok\n", nrows); goto out; } if (mysql_num_fields(res) != 1) { //DEBUG fprintf(stderr, "numfields not ok\n"); goto out; } if ((rowdata = mysql_fetch_row(res)) == NULL) { goto out; } v = rowdata[0]; value = (v) ? strdup(v) : NULL; out: mysql_free_result(res); free(query); *phash = value; return BACKEND_DEFER; } /* * Return T/F if user is superuser */ int be_mysql_superuser(void *handle, const char *username) { struct mysql_backend *conf = (struct mysql_backend *)handle; char *query = NULL, *u = NULL; long nrows, ulen; int issuper = BACKEND_DEFER; MYSQL_RES *res = NULL; MYSQL_ROW rowdata; if (!conf || !conf->superquery) return BACKEND_DEFER; if (mysql_ping(conf->mysql)) { fprintf(stderr, "%s\n", mysql_error(conf->mysql)); if (!auto_connect(conf)) { return (BACKEND_ERROR); } } if ((u = escape(conf, username, &ulen)) == NULL) return (BACKEND_ERROR); if ((query = malloc(strlen(conf->superquery) + ulen + 128)) == NULL) { free(u); return (BACKEND_ERROR); } sprintf(query, conf->superquery, u); free(u); if (mysql_query(conf->mysql, query)) { fprintf(stderr, "%s\n", mysql_error(conf->mysql)); issuper = BACKEND_ERROR; goto out; } res = mysql_store_result(conf->mysql); if ((nrows = mysql_num_rows(res)) != 1) { goto out; } if (mysql_num_fields(res) != 1) { //DEBUG fprintf(stderr, "numfields not ok\n"); goto out; } if ((rowdata = mysql_fetch_row(res)) == NULL) { goto out; } issuper = (atoi(rowdata[0])) ? BACKEND_ALLOW: BACKEND_DEFER; out: mysql_free_result(res); free(query); return (issuper); } /* * Check ACL. username is the name of the connected user attempting to access * topic is the topic user is trying to access (may contain wildcards) acc is * desired type of access: read/write for subscriptions (READ) (1) for * publish (WRITE) (2) * * SELECT topic FROM table WHERE username = '%s' AND (acc & %d) // * may user SUB or PUB topic? SELECT topic FROM table WHERE username = '%s' * / ignore ACC */ int be_mysql_aclcheck(void *handle, const char *clientid, const char *username, const char *topic, int acc) { struct mysql_backend *conf = (struct mysql_backend *)handle; char *query = NULL, *u = NULL, *v; long ulen; int match = BACKEND_DEFER; bool bf; MYSQL_RES *res = NULL; MYSQL_ROW rowdata; if (!conf || !conf->aclquery) return BACKEND_DEFER; if (mysql_ping(conf->mysql)) { fprintf(stderr, "%s\n", mysql_error(conf->mysql)); if (!auto_connect(conf)) { return (BACKEND_ERROR); } } if ((u = escape(conf, username, &ulen)) == NULL) return (BACKEND_ERROR); if ((query = malloc(strlen(conf->aclquery) + ulen + 128)) == NULL) { free(u); return (BACKEND_ERROR); } sprintf(query, conf->aclquery, u, acc); free(u); //_log(LOG_DEBUG, "SQL: %s", query); if (mysql_query(conf->mysql, query)) { _log(LOG_NOTICE, "%s", mysql_error(conf->mysql)); match = BACKEND_ERROR; goto out; } res = mysql_store_result(conf->mysql); if (mysql_num_fields(res) != 1) { fprintf(stderr, "numfields not ok\n"); goto out; } while (match == 0 && (rowdata = mysql_fetch_row(res)) != NULL) { if ((v = rowdata[0]) != NULL) { /* * Check mosquitto_match_topic. If true, if true, set * match and break out of loop. */ char *expanded; t_expand(clientid, username, v, &expanded); if (expanded && *expanded) { mosquitto_topic_matches_sub(expanded, topic, &bf); if (bf) match = BACKEND_ALLOW; _log(LOG_DEBUG, " mysql: topic_matches(%s, %s) == %d", expanded, v, bf); free(expanded); } } } out: mysql_free_result(res); free(query); return (match); } #endif /* BE_MYSQL */
the_stack_data/21194.c
#include <stdio.h> int main() { int ten = 10; int two = 2; printf("Doing it right:"); printf("%d minus %d is %d\n",ten,2,ten-two); printf("Doing it wrong:"); printf("%d minus %d is %d\n",ten); return 0; }
the_stack_data/61073990.c
/* * Copyright (c) 2011, 2012, 2013 Jonas 'Sortie' Termansen. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * stdio/fprintf.c * Prints a string to a FILE. */ #include <stdarg.h> #include <stdio.h> int fprintf(FILE* fp, const char* restrict format, ...) { va_list list; va_start(list, format); flockfile(fp); int result = vfprintf_unlocked(fp, format, list); funlockfile(fp); va_end(list); return result; }
the_stack_data/129425.c
/* Taxonomy Classification: 0000000100000142000210 */ /* * WRITE/READ 0 write * WHICH BOUND 0 upper * DATA TYPE 0 char * MEMORY LOCATION 0 stack * SCOPE 0 same * CONTAINER 0 no * POINTER 0 no * INDEX COMPLEXITY 1 variable * ADDRESS COMPLEXITY 0 constant * LENGTH COMPLEXITY 0 N/A * ADDRESS ALIAS 0 none * INDEX ALIAS 0 none * LOCAL CONTROL FLOW 0 none * SECONDARY CONTROL FLOW 1 if * LOOP STRUCTURE 4 non-standard for * LOOP COMPLEXITY 2 one * ASYNCHRONY 0 no * TAINT 0 no * RUNTIME ENV. DEPENDENCE 0 no * MAGNITUDE 2 8 bytes * CONTINUOUS/DISCRETE 1 continuous * SIGNEDNESS 0 no */ /* Copyright 2005 Massachusetts Institute of Technology All rights reserved. Redistribution and use of software 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 set of conditions and the disclaimer below. - Redistributions in binary form must reproduce the copyright notice, this set of conditions, and the disclaimer below in the documentation and/or other materials provided with the distribution. - Neither the name of the Massachusetts Institute of Technology 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". ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ int main(int argc, char *argv[]) { int inc_value; int loop_counter; char buf[10]; inc_value = 17 - (17 - 1); for(loop_counter = 0; ; loop_counter += inc_value) { if (loop_counter > 17) break; /* BAD */ buf[loop_counter] = 'A'; } return 0; }
the_stack_data/7950569.c
#include <stdio.h> int main() { while (1) { printf("Hello world... from hello1.c\n"); for(int i=0; i<100000000; i++) { }; } }
the_stack_data/781891.c
/* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * ICU License - ICU 1.8.1 and later * * COPYRIGHT AND PERMISSION NOTICE * * Copyright (c) 1995-2005 International Business Machines Corporation and others * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, and/or sell copies of the Software, and to permit persons * to whom the Software is furnished to do so, provided that the above * copyright notice(s) and this permission notice appear in all copies of * the Software and that both the above copyright notice(s) and this * permission notice appear in supporting documentation. * * 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 * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL * 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. * * Except as contained in this notice, the name of a copyright holder * shall not be used in advertising or otherwise to promote the sale, use * or other dealings in this Software without prior written authorization * of the copyright holder. * * -------------------------------------------------------------------------- * All trademarks and registered trademarks mentioned herein are the property * of their respective owners. */ /* Translation table for iconv */ /* Copr (c) 1995,96 by Sun Microsystems, Inc. */ /* I'm mapping everything that can't be mapped to 6D - underscore in cp500 and am leaving everything that's a correct map as lowercase (so 6d is a correct mapping of underscore) */ unsigned char __iso_to_cp500[256] = { /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */ 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, /* the above 2 lines don't appear in iso1 though... I'm mapping them to '_' */ 0x40, 0x4f, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d, 0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f, 0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0x4a, 0xe0, 0x5a, 0x5f, 0x6d, 0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xc0, 0xbb, 0xd0, 0xa1, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, /* 8 don't map this*/ 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, /* or this */ 0x41, 0xaa, 0xb0, 0xb1, 0x9f, 0xb2, 0x6a, 0xb5, 0xbd, 0xb4, 0x9a, 0x8a, 0xba, 0xca, 0xaf, 0xbc, 0x90, 0x8f, 0xea, 0xfa, 0xbe, 0xa0, 0xb6, 0xb3, 0x9d, 0xda, 0x9b, 0x8b, 0xb7, 0xb8, 0xb9, 0xab, 0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9e, 0x68, 0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77, 0xac, 0x69, 0xed, 0xee, 0xeb, 0xef, 0xec, 0xbf, 0x80, 0xfd, 0xfe, 0xfb, 0xfc, 0xad, 0x8e, 0x59, 0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9c, 0x48, 0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57, 0x8c, 0x49, 0xcd, 0xce, 0xcb, 0xcf, 0xcc, 0xe1, 0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0xae, 0xdf };
the_stack_data/22012896.c
/* Copyright (C) 2005-2020 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ #include <locale.h> #include <wchar.h> size_t __mbsrtowcs_chk (wchar_t *dst, const char **src, size_t len, mbstate_t *ps, size_t dstlen) { if (__glibc_unlikely (dstlen < len)) __chk_fail (); return __mbsrtowcs (dst, src, len, ps); }
the_stack_data/1236283.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* main.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: dakim <[email protected]> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2018/07/29 10:50:00 by dakim #+# #+# */ /* Updated: 2018/07/31 19:21:47 by dakim ### ########.fr */ /* */ /* ************************************************************************** */ #include <unistd.h> #include <stdio.h> int ft_putchar(char c); void rush(int x, int y); int main(void) { rush(10, 10); return (0); }
the_stack_data/232957055.c
#include <stdint.h> typedef unsigned char u8; typedef unsigned long long u64; typedef struct { u64 x0, x1, x2, x3, x4; } state; static inline u64 ROTR64(u64 x, int n) { return (x << (64 - n)) | (x >> n); } static inline void ROUND(u8 C, state* p) { state s = *p; state t; // addition of round constant s.x2 ^= C; // substitution layer s.x0 ^= s.x4; s.x4 ^= s.x3; s.x2 ^= s.x1; // start of keccak s-box t.x0 = ~s.x0; t.x1 = ~s.x1; t.x2 = ~s.x2; t.x3 = ~s.x3; t.x4 = ~s.x4; t.x0 &= s.x1; t.x1 &= s.x2; t.x2 &= s.x3; t.x3 &= s.x4; t.x4 &= s.x0; s.x0 ^= t.x1; s.x1 ^= t.x2; s.x2 ^= t.x3; s.x3 ^= t.x4; s.x4 ^= t.x0; // end of keccak s-box s.x1 ^= s.x0; s.x0 ^= s.x4; s.x3 ^= s.x2; s.x2 = ~s.x2; // linear diffusion layer s.x0 ^= ROTR64(s.x0, 19) ^ ROTR64(s.x0, 28); s.x1 ^= ROTR64(s.x1, 61) ^ ROTR64(s.x1, 39); s.x2 ^= ROTR64(s.x2, 1) ^ ROTR64(s.x2, 6); s.x3 ^= ROTR64(s.x3, 10) ^ ROTR64(s.x3, 17); s.x4 ^= ROTR64(s.x4, 7) ^ ROTR64(s.x4, 41); //exit(1); *p = s; } void P12(state* s) { ROUND(0xf0, s); ROUND(0xe1, s); ROUND(0xd2, s); ROUND(0xc3, s); ROUND(0xb4, s); ROUND(0xa5, s); ROUND(0x96, s); ROUND(0x87, s); ROUND(0x78, s); ROUND(0x69, s); ROUND(0x5a, s); ROUND(0x4b, s); } /* Additional functions */ uint32_t bench_speed() { /* inputs */ state input = { 0 }; /* fun call */ P12(&input); /* Returning the number of encrypted bytes */ return 40; }
the_stack_data/92324451.c
/* * Copyright <2019> Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://www.apache.org/licenses/LICENSE-2.0 * * or in the "license" file accompanying this file. This file 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. * */ #ifdef UNICODE_SUPPORT #include <ctype.h> #include <stdlib.h> #include <string.h> #include "unicode_support.h" #ifdef WIN32 #define FORMAT_SIZE_T "%Iu" #else #define FORMAT_SIZE_T "%zu" #endif #if (defined(__STDC_ISO_10646__) && defined(HAVE_MBSTOWCS) \ && defined(HAVE_WCSTOMBS)) \ || defined(WIN32) #define __WCS_ISO10646__ static BOOL use_wcs = FALSE; #endif #if (defined(__STDC_UTF_16__) && defined(HAVE_UCHAR_H) \ && defined(HAVE_MBRTOC16) && defined(HAVE_C16RTOMB)) #define __CHAR16_UTF_16__ #include <uchar.h> static BOOL use_c16 = FALSE; #endif static int convtype = -1; int get_convtype(void) { const UCHAR *cdt; (void)(cdt); #if defined(__WCS_ISO10646__) if (convtype < 0) { wchar_t *wdt = L"a"; int sizeof_w = sizeof(wchar_t); cdt = (UCHAR *)wdt; switch (sizeof_w) { case 2: if ('a' == cdt[0] && '\0' == cdt[1] && '\0' == cdt[2] && '\0' == cdt[3]) { MYLOG(ES_DEBUG, " UTF-16LE detected\n"); convtype = WCSTYPE_UTF16_LE; use_wcs = TRUE; } break; case 4: if ('a' == cdt[0] && '\0' == cdt[1] && '\0' == cdt[2] && '\0' == cdt[3] && '\0' == cdt[4] && '\0' == cdt[5] && '\0' == cdt[6] && '\0' == cdt[7]) { MYLOG(ES_DEBUG, " UTF32-LE detected\n"); convtype = WCSTYPE_UTF32_LE; use_wcs = TRUE; } break; } } #endif /* __WCS_ISO10646__ */ #ifdef __CHAR16_UTF_16__ if (convtype < 0) { char16_t *c16dt = u"a"; cdt = (UCHAR *)c16dt; if ('a' == cdt[0] && '\0' == cdt[1] && '\0' == cdt[2] && '\0' == cdt[3]) { MYLOG(ES_DEBUG, " C16_UTF-16LE detected\n"); convtype = C16TYPE_UTF16_LE; use_c16 = TRUE; } } #endif /* __CHAR16_UTF_16__ */ if (convtype < 0) convtype = CONVTYPE_UNKNOWN; /* unknown */ return convtype; } #define byte3check 0xfffff800 #define byte2_base 0x80c0 #define byte2_mask1 0x07c0 #define byte2_mask2 0x003f #define byte3_base 0x8080e0 #define byte3_mask1 0xf000 #define byte3_mask2 0x0fc0 #define byte3_mask3 0x003f #define surrog_check 0xfc00 #define surrog1_bits 0xd800 #define surrog2_bits 0xdc00 #define byte4_base 0x808080f0 #define byte4_sr1_mask1 0x0700 #define byte4_sr1_mask2 0x00fc #define byte4_sr1_mask3 0x0003 #define byte4_sr2_mask1 0x03c0 #define byte4_sr2_mask2 0x003f #define surrogate_adjust (0x10000 >> 10) static int little_endian = -1; SQLULEN ucs2strlen(const SQLWCHAR *ucs2str) { SQLULEN len; for (len = 0; ucs2str[len]; len++) ; return len; } char *ucs2_to_utf8(const SQLWCHAR *ucs2str, SQLLEN ilen, SQLLEN *olen, BOOL lower_identifier) { char *utf8str; int len = 0; MYLOG(ES_DEBUG, "%p ilen=" FORMAT_LEN " ", ucs2str, ilen); if (!ucs2str) { if (olen) *olen = SQL_NULL_DATA; return NULL; } if (little_endian < 0) { int crt = 1; little_endian = (0 != ((char *)&crt)[0]); } if (ilen < 0) ilen = ucs2strlen(ucs2str); MYPRINTF(0, " newlen=" FORMAT_LEN, ilen); utf8str = (char *)malloc(ilen * 4 + 1); if (utf8str) { int i = 0; UInt2 byte2code; Int4 byte4code, surrd1, surrd2; const SQLWCHAR *wstr; for (i = 0, wstr = ucs2str; i < ilen; i++, wstr++) { if (!*wstr) break; else if (0 == (*wstr & 0xffffff80)) /* ASCII */ { if (lower_identifier) utf8str[len++] = (char)tolower(*wstr); else utf8str[len++] = (char)*wstr; } else if ((*wstr & byte3check) == 0) { byte2code = byte2_base | ((byte2_mask1 & *wstr) >> 6) | ((byte2_mask2 & *wstr) << 8); if (little_endian) memcpy(utf8str + len, (char *)&byte2code, sizeof(byte2code)); else { utf8str[len] = ((char *)&byte2code)[1]; utf8str[len + 1] = ((char *)&byte2code)[0]; } len += sizeof(byte2code); } /* surrogate pair check for non ucs-2 code */ else if (surrog1_bits == (*wstr & surrog_check)) { surrd1 = (*wstr & ~surrog_check) + surrogate_adjust; wstr++; i++; surrd2 = (*wstr & ~surrog_check); byte4code = byte4_base | ((byte4_sr1_mask1 & surrd1) >> 8) | ((byte4_sr1_mask2 & surrd1) << 6) | ((byte4_sr1_mask3 & surrd1) << 20) | ((byte4_sr2_mask1 & surrd2) << 10) | ((byte4_sr2_mask2 & surrd2) << 24); if (little_endian) memcpy(utf8str + len, (char *)&byte4code, sizeof(byte4code)); else { utf8str[len] = ((char *)&byte4code)[3]; utf8str[len + 1] = ((char *)&byte4code)[2]; utf8str[len + 2] = ((char *)&byte4code)[1]; utf8str[len + 3] = ((char *)&byte4code)[0]; } len += sizeof(byte4code); } else { byte4code = byte3_base | ((byte3_mask1 & *wstr) >> 12) | ((byte3_mask2 & *wstr) << 2) | ((byte3_mask3 & *wstr) << 16); if (little_endian) memcpy(utf8str + len, (char *)&byte4code, 3); else { utf8str[len] = ((char *)&byte4code)[3]; utf8str[len + 1] = ((char *)&byte4code)[2]; utf8str[len + 2] = ((char *)&byte4code)[1]; } len += 3; } } utf8str[len] = '\0'; if (olen) *olen = len; } return utf8str; } #define byte3_m1 0x0f #define byte3_m2 0x3f #define byte3_m3 0x3f #define byte2_m1 0x1f #define byte2_m2 0x3f #define byte4_m1 0x07 #define byte4_m2 0x3f #define byte4_m31 0x30 #define byte4_m32 0x0f #define byte4_m4 0x3f /* * Convert a string from UTF-8 encoding to UCS-2. * * utf8str - input string in UTF-8 * ilen - length of input string in bytes (or minus) * lfconv - TRUE if line feeds (LF) should be converted to CR + LF * ucs2str - output buffer * bufcount - size of output buffer * errcheck - if TRUE, check for invalidly encoded input characters * * Returns the number of SQLWCHARs copied to output buffer. If the output * buffer is too small, the output is truncated. The output string is * NULL-terminated, except when the output is truncated. */ SQLULEN utf8_to_ucs2_lf(const char *utf8str, SQLLEN ilen, BOOL lfconv, SQLWCHAR *ucs2str, SQLULEN bufcount, BOOL errcheck) { int i; SQLULEN rtn, ocount, wcode; const UCHAR *str; MYLOG(ES_DEBUG, "ilen=" FORMAT_LEN " bufcount=" FORMAT_ULEN, ilen, bufcount); if (!utf8str) return 0; if (!bufcount) ucs2str = NULL; else if (!ucs2str) bufcount = 0; if (ilen < 0) ilen = strlen(utf8str); for (i = 0, ocount = 0, str = (SQLCHAR *)utf8str; i < ilen && *str;) { if ((*str & 0x80) == 0) { if (lfconv && ES_LINEFEED == *str && (i == 0 || ES_CARRIAGE_RETURN != str[-1])) { if (ocount < bufcount) ucs2str[ocount] = ES_CARRIAGE_RETURN; ocount++; } if (ocount < bufcount) ucs2str[ocount] = *str; ocount++; i++; str++; } else if (0xf8 == (*str & 0xf8)) /* more than 5 byte code */ { ocount = (SQLULEN)-1; goto cleanup; } else if (0xf0 == (*str & 0xf8)) /* 4 byte code */ { if (errcheck) { if (i + 4 > ilen || 0 == (str[1] & 0x80) || 0 == (str[2] & 0x80) || 0 == (str[3] & 0x80)) { ocount = (SQLULEN)-1; goto cleanup; } } if (ocount < bufcount) { wcode = (surrog1_bits | ((((UInt4)*str) & byte4_m1) << 8) | ((((UInt4)str[1]) & byte4_m2) << 2) | ((((UInt4)str[2]) & byte4_m31) >> 4)) - surrogate_adjust; ucs2str[ocount] = (SQLWCHAR)wcode; } ocount++; if (ocount < bufcount) { wcode = surrog2_bits | ((((UInt4)str[2]) & byte4_m32) << 6) | (((UInt4)str[3]) & byte4_m4); ucs2str[ocount] = (SQLWCHAR)wcode; } ocount++; i += 4; str += 4; } else if (0xe0 == (*str & 0xf0)) /* 3 byte code */ { if (errcheck) { if (i + 3 > ilen || 0 == (str[1] & 0x80) || 0 == (str[2] & 0x80)) { ocount = (SQLULEN)-1; goto cleanup; } } if (ocount < bufcount) { wcode = ((((UInt4)*str) & byte3_m1) << 12) | ((((UInt4)str[1]) & byte3_m2) << 6) | (((UInt4)str[2]) & byte3_m3); ucs2str[ocount] = (SQLWCHAR)wcode; } ocount++; i += 3; str += 3; } else if (0xc0 == (*str & 0xe0)) /* 2 byte code */ { if (errcheck) { if (i + 2 > ilen || 0 == (str[1] & 0x80)) { ocount = (SQLULEN)-1; goto cleanup; } } if (ocount < bufcount) { wcode = ((((UInt4)*str) & byte2_m1) << 6) | (((UInt4)str[1]) & byte2_m2); ucs2str[ocount] = (SQLWCHAR)wcode; } ocount++; i += 2; str += 2; } else { ocount = (SQLULEN)-1; goto cleanup; } } cleanup: rtn = ocount; if (ocount == (SQLULEN)-1) { if (!errcheck) rtn = 0; ocount = 0; } if (ocount < bufcount && ucs2str) ucs2str[ocount] = 0; MYPRINTF(ES_ALL, " ocount=" FORMAT_ULEN "\n", ocount); return rtn; } #ifdef __WCS_ISO10646__ /* UCS4 => utf8 */ #define byte4check 0xffff0000 #define byte4_check 0x10000 #define byte4_mask1 0x1c0000 #define byte4_mask2 0x3f000 #define byte4_mask3 0x0fc0 #define byte4_mask4 0x003f #define byte4_m3 0x3f static SQLULEN ucs4strlen(const UInt4 *ucs4str) { SQLULEN len; for (len = 0; ucs4str[len]; len++) ; return len; } static char *ucs4_to_utf8(const UInt4 *ucs4str, SQLLEN ilen, SQLLEN *olen, BOOL lower_identifier) { char *utf8str; int len = 0; MYLOG(ES_DEBUG, " %p ilen=" FORMAT_LEN "\n", ucs4str, ilen); if (!ucs4str) { if (olen) *olen = SQL_NULL_DATA; return NULL; } if (little_endian < 0) { int crt = 1; little_endian = (0 != ((char *)&crt)[0]); } if (ilen < 0) ilen = ucs4strlen(ucs4str); MYLOG(ES_DEBUG, " newlen=" FORMAT_LEN "\n", ilen); utf8str = (char *)malloc(ilen * 4 + 1); if (utf8str) { int i; UInt2 byte2code; Int4 byte4code; const UInt4 *wstr; for (i = 0, wstr = ucs4str; i < ilen; i++, wstr++) { if (!*wstr) break; else if (0 == (*wstr & 0xffffff80)) /* ASCII */ { if (lower_identifier) utf8str[len++] = (char)tolower(*wstr); else utf8str[len++] = (char)*wstr; } else if ((*wstr & byte3check) == 0) { byte2code = byte2_base | ((byte2_mask1 & *wstr) >> 6) | ((byte2_mask2 & *wstr) << 8); if (little_endian) memcpy(utf8str + len, (char *)&byte2code, sizeof(byte2code)); else { utf8str[len] = ((char *)&byte2code)[1]; utf8str[len + 1] = ((char *)&byte2code)[0]; } len += sizeof(byte2code); } else if ((*wstr & byte4check) == 0) { byte4code = byte3_base | ((byte3_mask1 & *wstr) >> 12) | ((byte3_mask2 & *wstr) << 2) | ((byte3_mask3 & *wstr) << 16); if (little_endian) memcpy(utf8str + len, (char *)&byte4code, 3); else { utf8str[len] = ((char *)&byte4code)[3]; utf8str[len + 1] = ((char *)&byte4code)[2]; utf8str[len + 2] = ((char *)&byte4code)[1]; } len += 3; } else { byte4code = byte4_base | ((byte4_mask1 & *wstr) >> 18) | ((byte4_mask2 & *wstr) >> 4) | ((byte4_mask3 & *wstr) << 10) | ((byte4_mask4 & *wstr) << 24); /* MYLOG(ES_DEBUG, " %08x->%08x\n", *wstr, byte4code); */ if (little_endian) memcpy(utf8str + len, (char *)&byte4code, sizeof(byte4code)); else { utf8str[len] = ((char *)&byte4code)[3]; utf8str[len + 1] = ((char *)&byte4code)[2]; utf8str[len + 2] = ((char *)&byte4code)[1]; utf8str[len + 3] = ((char *)&byte4code)[0]; } len += sizeof(byte4code); } } utf8str[len] = '\0'; if (olen) *olen = len; } return utf8str; } /* * Convert a string from UTF-8 encoding to UTF-32. * * utf8str - input string in UTF-8 * ilen - length of input string in bytes (or minus) * lfconv - TRUE if line feeds (LF) should be converted to CR + LF * ucs4str - output buffer * bufcount - size of output buffer * errcheck - if TRUE, check for invalidly encoded input characters * * Returns the number of UInt4s copied to output buffer. If the output * buffer is too small, the output is truncated. The output string is * NULL-terminated, except when the output is truncated. */ static SQLULEN utf8_to_ucs4_lf(const char *utf8str, SQLLEN ilen, BOOL lfconv, UInt4 *ucs4str, SQLULEN bufcount, BOOL errcheck) { int i; SQLULEN rtn, ocount, wcode; const UCHAR *str; MYLOG(ES_DEBUG, " ilen=" FORMAT_LEN " bufcount=" FORMAT_ULEN "\n", ilen, bufcount); if (!utf8str) return 0; if (!bufcount) ucs4str = NULL; else if (!ucs4str) bufcount = 0; if (ilen < 0) ilen = strlen(utf8str); for (i = 0, ocount = 0, str = (SQLCHAR *)utf8str; i < ilen && *str;) { if ((*str & 0x80) == 0) { if (lfconv && ES_LINEFEED == *str && (i == 0 || ES_CARRIAGE_RETURN != str[-1])) { if (ocount < bufcount) ucs4str[ocount] = ES_CARRIAGE_RETURN; ocount++; } if (ocount < bufcount) ucs4str[ocount] = *str; ocount++; i++; str++; } else if (0xf8 == (*str & 0xf8)) /* more than 5 byte code */ { ocount = (SQLULEN)-1; goto cleanup; } else if (0xf0 == (*str & 0xf8)) /* 4 byte code */ { if (errcheck) { if (i + 4 > ilen || 0 == (str[1] & 0x80) || 0 == (str[2] & 0x80) || 0 == (str[3] & 0x80)) { ocount = (SQLULEN)-1; goto cleanup; } } if (ocount < bufcount) { wcode = (((((UInt4)*str) & byte4_m1) << 18) | ((((UInt4)str[1]) & byte4_m2) << 12) | ((((UInt4)str[2]) & byte4_m3) << 6)) | (((UInt4)str[3]) & byte4_m4); ucs4str[ocount] = (unsigned int)wcode; } ocount++; i += 4; str += 4; } else if (0xe0 == (*str & 0xf0)) /* 3 byte code */ { if (errcheck) { if (i + 3 > ilen || 0 == (str[1] & 0x80) || 0 == (str[2] & 0x80)) { ocount = (SQLULEN)-1; goto cleanup; } } if (ocount < bufcount) { wcode = ((((UInt4)*str) & byte3_m1) << 12) | ((((UInt4)str[1]) & byte3_m2) << 6) | (((UInt4)str[2]) & byte3_m3); ucs4str[ocount] = (unsigned int)wcode; } ocount++; i += 3; str += 3; } else if (0xc0 == (*str & 0xe0)) /* 2 byte code */ { if (errcheck) { if (i + 2 > ilen || 0 == (str[1] & 0x80)) { ocount = (SQLULEN)-1; goto cleanup; } } if (ocount < bufcount) { wcode = ((((UInt4)*str) & byte2_m1) << 6) | (((UInt4)str[1]) & byte2_m2); ucs4str[ocount] = (SQLWCHAR)wcode; } ocount++; i += 2; str += 2; } else { ocount = (SQLULEN)-1; goto cleanup; } } cleanup: rtn = ocount; if (ocount == (SQLULEN)-1) { if (!errcheck) rtn = 0; ocount = 0; } if (ocount < bufcount && ucs4str) ucs4str[ocount] = 0; MYLOG(ES_DEBUG, " ocount=" FORMAT_ULEN "\n", ocount); return rtn; } #define SURROGATE_CHECK 0xfc #define SURROG1_BYTE 0xd8 #define SURROG2_BYTE 0xdc static int ucs4_to_ucs2_lf(const unsigned int *ucs4str, SQLLEN ilen, SQLWCHAR *ucs2str, int bufcount, BOOL lfconv) { int outlen = 0, i; UCHAR *ucdt; SQLWCHAR *sqlwdt, dmy_wchar; UCHAR *const udt = (UCHAR *)&dmy_wchar; unsigned int uintdt; MYLOG(ES_DEBUG, " ilen=" FORMAT_LEN " bufcount=%d\n", ilen, bufcount); if (ilen < 0) ilen = ucs4strlen(ucs4str); for (i = 0; i < ilen && (uintdt = ucs4str[i], uintdt); i++) { sqlwdt = (SQLWCHAR *)&uintdt; ucdt = (UCHAR *)&uintdt; if (0 == sqlwdt[1]) { if (lfconv && ES_LINEFEED == ucdt[0] && (i == 0 || ES_CARRIAGE_RETURN != *((UCHAR *)&ucs4str[i - 1]))) { if (outlen < bufcount) { udt[0] = ES_CARRIAGE_RETURN; udt[1] = 0; ucs2str[outlen] = *((SQLWCHAR *)udt); } outlen++; } if (outlen < bufcount) ucs2str[outlen] = sqlwdt[0]; outlen++; continue; } sqlwdt[1]--; udt[0] = ((0xfc & ucdt[1]) >> 2) | ((0x3 & ucdt[2]) << 6); // printf("%02x", udt[0]); udt[1] = SURROG1_BYTE | ((0xc & ucdt[2]) >> 2); // printf("%02x", udt[1]); if (outlen < bufcount) ucs2str[outlen] = *((SQLWCHAR *)udt); outlen++; udt[0] = ucdt[0]; // printf("%02x", udt[0]); udt[1] = SURROG2_BYTE | (0x3 & ucdt[1]); // printf("%02x\n", udt[1]); if (outlen < bufcount) ucs2str[outlen] = *((SQLWCHAR *)udt); outlen++; } if (outlen < bufcount) ucs2str[outlen] = 0; return outlen; } static int ucs2_to_ucs4(const SQLWCHAR *ucs2str, SQLLEN ilen, unsigned int *ucs4str, int bufcount) { int outlen = 0, i; UCHAR *ucdt; SQLWCHAR sqlwdt; unsigned int dmy_uint; UCHAR *const udt = (UCHAR *)&dmy_uint; MYLOG(ES_DEBUG, " ilen=" FORMAT_LEN " bufcount=%d\n", ilen, bufcount); if (ilen < 0) ilen = ucs2strlen(ucs2str); udt[3] = 0; /* always */ for (i = 0; i < ilen && (sqlwdt = ucs2str[i], sqlwdt); i++) { ucdt = (UCHAR *)(ucs2str + i); // printf("IN=%x\n", sqlwdt); if ((ucdt[1] & SURROGATE_CHECK) != SURROG1_BYTE) { // printf("SURROG1=%2x\n", ucdt[1] & SURROG1_BYTE); if (outlen < bufcount) { udt[0] = ucdt[0]; udt[1] = ucdt[1]; udt[2] = 0; ucs4str[outlen] = *((unsigned int *)udt); } outlen++; continue; } /* surrogate pair */ udt[0] = ucdt[2]; udt[1] = (ucdt[3] & 0x3) | ((ucdt[0] & 0x3f) << 2); udt[2] = (((ucdt[0] & 0xc0) >> 6) | ((ucdt[1] & 0x3) << 2)) + 1; // udt[3] = 0; needless if (outlen < bufcount) ucs4str[outlen] = *((unsigned int *)udt); outlen++; i++; } if (outlen < bufcount) ucs4str[outlen] = 0; return outlen; } #endif /* __WCS_ISO10646__ */ #if defined(__WCS_ISO10646__) static SQLULEN utf8_to_wcs_lf(const char *utf8str, SQLLEN ilen, BOOL lfconv, wchar_t *wcsstr, SQLULEN bufcount, BOOL errcheck) { switch (get_convtype()) { case WCSTYPE_UTF16_LE: return utf8_to_ucs2_lf(utf8str, ilen, lfconv, (SQLWCHAR *)wcsstr, bufcount, errcheck); case WCSTYPE_UTF32_LE: return utf8_to_ucs4_lf(utf8str, ilen, lfconv, (UInt4 *)wcsstr, bufcount, errcheck); } return (SQLULEN)~0; } static char *wcs_to_utf8(const wchar_t *wcsstr, SQLLEN ilen, SQLLEN *olen, BOOL lower_identifier) { switch (get_convtype()) { case WCSTYPE_UTF16_LE: return ucs2_to_utf8((const SQLWCHAR *)wcsstr, ilen, olen, lower_identifier); case WCSTYPE_UTF32_LE: return ucs4_to_utf8((const UInt4 *)wcsstr, ilen, olen, lower_identifier); } return NULL; } /* * Input strings must be NULL terminated. * Output wide character strings would be NULL terminated. The result * outmsg would be truncated when the buflen is small. * * The output NULL terminator is counted as buflen. * if outmsg is NULL or buflen is 0, only output length is returned. * As for return values, NULL terminators aren't counted. */ static int msgtowstr(const char *inmsg, wchar_t *outmsg, int buflen) { int outlen = -1; MYLOG(ES_DEBUG, " inmsg=%p buflen=%d\n", inmsg, buflen); #ifdef WIN32 if (NULL == outmsg) buflen = 0; if ((outlen = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED | MB_ERR_INVALID_CHARS, inmsg, -1, outmsg, buflen)) > 0) outlen--; else if (ERROR_INSUFFICIENT_BUFFER == GetLastError()) outlen = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED | MB_ERR_INVALID_CHARS, inmsg, -1, NULL, 0) - 1; else outlen = -1; #else if (0 == buflen) outmsg = NULL; outlen = mbstowcs((wchar_t *)outmsg, inmsg, buflen); #endif /* WIN32 */ if (outmsg && outlen >= buflen) { outmsg[buflen - 1] = 0; MYLOG(ES_DEBUG, " out=%dchars truncated to %d\n", outlen, buflen - 1); } MYLOG(ES_DEBUG, " buf=%dchars out=%dchars\n", buflen, outlen); return outlen; } /* * Input wide character strings must be NULL terminated. * Output strings would be NULL terminated. The result outmsg would be * truncated when the buflen is small. * * The output NULL terminator is counted as buflen. * if outmsg is NULL or buflen is 0, only output length is returned. * As for return values, NULL terminators aren't counted. */ static int wstrtomsg(const wchar_t *wstr, char *outmsg, int buflen) { int outlen = -1; MYLOG(ES_DEBUG, " wstr=%p buflen=%d\n", wstr, buflen); #ifdef WIN32 if (NULL == outmsg) buflen = 0; if ((outlen = WideCharToMultiByte(CP_ACP, 0, wstr, -1, outmsg, buflen, NULL, NULL)) > 0) outlen--; else if (ERROR_INSUFFICIENT_BUFFER == GetLastError()) outlen = WideCharToMultiByte(CP_ACP, 0, wstr, -1, NULL, 0, NULL, NULL) - 1; else outlen = -1; #else if (0 == buflen) outmsg = NULL; outlen = wcstombs(outmsg, wstr, buflen); #endif /* WIN32 */ if (outmsg && outlen >= buflen) { outmsg[buflen - 1] = 0; MYLOG(ES_DEBUG, " out=%dbytes truncated to %d\n", outlen, buflen - 1); } MYLOG(ES_DEBUG, " buf=%dbytes outlen=%dbytes\n", buflen, outlen); return outlen; } #endif /* __WCS_ISO10646__ */ #if defined(__CHAR16_UTF_16__) static mbstate_t initial_state; static SQLLEN mbstoc16_lf(char16_t *c16dt, const char *c8dt, size_t n, BOOL lf_conv) { int i; size_t brtn; const char *cdt; mbstate_t mbst = initial_state; MYLOG(ES_DEBUG, " c16dt=%p size=" FORMAT_SIZE_T "\n", c16dt, n); for (i = 0, cdt = c8dt; i < n || (!c16dt); i++) { if (lf_conv && ES_LINEFEED == *cdt && i > 0 && ES_CARRIAGE_RETURN != cdt[-1]) { if (c16dt) c16dt[i] = ES_CARRIAGE_RETURN; i++; } brtn = mbrtoc16(c16dt ? c16dt + i : NULL, cdt, 4, &mbst); if (0 == brtn) break; if (brtn == (size_t)-1 || brtn == (size_t)-2) return -1; if (brtn == (size_t)-3) continue; cdt += brtn; } if (c16dt && i >= n) c16dt[n - 1] = 0; return i; } static SQLLEN c16tombs(char *c8dt, const char16_t *c16dt, size_t n) { int i; SQLLEN result = 0; size_t brtn; char *cdt, c4byte[4]; mbstate_t mbst = initial_state; MYLOG(ES_DEBUG, " c8dt=%p size=" FORMAT_SIZE_T "u\n", c8dt, n); if (!c8dt) n = 0; for (i = 0, cdt = c8dt; c16dt[i] && (result < n || (!cdt)); i++) { if (NULL != cdt && result + 4 < n) brtn = c16rtomb(cdt, c16dt[i], &mbst); else { brtn = c16rtomb(c4byte, c16dt[i], &mbst); if (brtn < 5) { SQLLEN result_n = result + brtn; if (result_n < n) memcpy(cdt, c4byte, brtn); else { if (cdt && n > 0) { c8dt[result] = '\0'; /* truncate */ return result_n; } } } } /* printf("c16dt=%04X brtn=%lu result=%ld cdt=%02X%02X%02X%02X\n", c16dt[i], brtn, result, (UCHAR) cdt[0], (UCHAR) cdt[1], (UCHAR) cdt[2], (UCHAR) cdt[3]); */ if (brtn == (size_t)-1) { if (n > 0) c8dt[n - 1] = '\0'; return -1; } if (cdt) cdt += brtn; result += brtn; } if (cdt) *cdt = '\0'; return result; } #endif /* __CHAR16_UTF_16__ */ // // SQLBindParameter SQL_C_CHAR to UTF-8 case // the current locale => UTF-8 // SQLLEN bindpara_msg_to_utf8(const char *ldt, char **wcsbuf, SQLLEN used) { SQLLEN l = (-2); char *utf8 = NULL, *ldt_nts, *alloc_nts = NULL, ntsbuf[128]; int count; if (SQL_NTS == used) { count = (int)strlen(ldt); ldt_nts = (char *)ldt; } else if (used < 0) { return -1; } else { count = (int)used; if (used < (SQLLEN)sizeof(ntsbuf)) ldt_nts = ntsbuf; else { if (NULL == (alloc_nts = malloc(used + 1))) return l; ldt_nts = alloc_nts; } memcpy(ldt_nts, ldt, used); ldt_nts[used] = '\0'; } get_convtype(); MYLOG(ES_DEBUG, " \n"); #if defined(__WCS_ISO10646__) if (use_wcs) { wchar_t *wcsdt = (wchar_t *)malloc((count + 1) * sizeof(wchar_t)); if ((l = msgtowstr(ldt_nts, (wchar_t *)wcsdt, count + 1)) >= 0) utf8 = wcs_to_utf8(wcsdt, -1, &l, FALSE); free(wcsdt); } #endif /* __WCS_ISO10646__ */ #ifdef __CHAR16_UTF_16__ if (use_c16) { SQLWCHAR *utf16 = (SQLWCHAR *)malloc((count + 1) * sizeof(SQLWCHAR)); if ((l = mbstoc16_lf((char16_t *)utf16, ldt_nts, count + 1, FALSE)) >= 0) utf8 = ucs2_to_utf8(utf16, -1, &l, FALSE); free(utf16); } #endif /* __CHAR16_UTF_16__ */ if (l < 0 && NULL != utf8) free(utf8); else *wcsbuf = (char *)utf8; if (NULL != alloc_nts) free(alloc_nts); return l; } // // SQLBindParameter hybrid case // SQLWCHAR(UTF-16) => the current locale // SQLLEN bindpara_wchar_to_msg(const SQLWCHAR *utf16, char **wcsbuf, SQLLEN used) { SQLLEN l = (-2); char *ldt = NULL; SQLWCHAR *utf16_nts, *alloc_nts = NULL, ntsbuf[128]; int count; if (SQL_NTS == used) { count = (int)ucs2strlen(utf16); utf16_nts = (SQLWCHAR *)utf16; } else if (used < 0) return -1; else { count = (int)(used / WCLEN); if (used + WCLEN <= sizeof(ntsbuf)) utf16_nts = ntsbuf; else { if (NULL == (alloc_nts = (SQLWCHAR *)malloc(used + WCLEN))) return l; utf16_nts = alloc_nts; } memcpy(utf16_nts, utf16, used); utf16_nts[count] = 0; } get_convtype(); MYLOG(ES_DEBUG, "\n"); #if defined(__WCS_ISO10646__) if (use_wcs) { #pragma warning(push) #pragma warning(disable : 4127) if (sizeof(SQLWCHAR) == sizeof(wchar_t)) #pragma warning(pop) { ldt = (char *)malloc(2 * count + 1); l = wstrtomsg((wchar_t *)utf16_nts, ldt, 2 * count + 1); } else { unsigned int *utf32 = (unsigned int *)malloc((count + 1) * sizeof(unsigned int)); l = ucs2_to_ucs4(utf16_nts, -1, utf32, count + 1); if ((l = wstrtomsg((wchar_t *)utf32, NULL, 0)) >= 0) { ldt = (char *)malloc(l + 1); l = wstrtomsg((wchar_t *)utf32, ldt, (int)l + 1); } free(utf32); } } #endif /* __WCS_ISO10646__ */ #ifdef __CHAR16_UTF_16__ if (use_c16) { ldt = (char *)malloc(4 * count + 1); l = c16tombs(ldt, (const char16_t *)utf16_nts, 4 * count + 1); } #endif /* __CHAR16_UTF_16__ */ if (l < 0 && NULL != ldt) free(ldt); else *wcsbuf = ldt; if (NULL != alloc_nts) free(alloc_nts); return l; } size_t convert_linefeeds(const char *s, char *dst, size_t max, BOOL convlf, BOOL *changed); // // SQLBindCol hybrid case // the current locale => SQLWCHAR(UTF-16) // SQLLEN bindcol_hybrid_estimate(const char *ldt, BOOL lf_conv, char **wcsbuf) { UNUSED(ldt, wcsbuf); SQLLEN l = (-2); get_convtype(); MYLOG(ES_DEBUG, " lf_conv=%d\n", lf_conv); #if defined(__WCS_ISO10646__) if (use_wcs) { unsigned int *utf32 = NULL; #pragma warning(push) #pragma warning(disable : 4127) if (sizeof(SQLWCHAR) == sizeof(wchar_t)) #pragma warning(pop) { l = msgtowstr(ldt, (wchar_t *)NULL, 0); if (l >= 0 && lf_conv) { BOOL changed; size_t len; len = convert_linefeeds(ldt, NULL, 0, TRUE, &changed); if (changed) { l += (len - strlen(ldt)); *wcsbuf = (char *)malloc(len + 1); convert_linefeeds(ldt, *wcsbuf, len + 1, TRUE, NULL); } } } else { int count = (int)strlen(ldt); utf32 = (unsigned int *)malloc((count + 1) * sizeof(unsigned int)); if ((l = msgtowstr(ldt, (wchar_t *)utf32, count + 1)) >= 0) { l = ucs4_to_ucs2_lf(utf32, -1, NULL, 0, lf_conv); *wcsbuf = (char *)utf32; } } if (l < 0 && NULL != utf32) free(utf32); } #endif /* __WCS_ISO10646__ */ #ifdef __CHAR16_UTF_16__ if (use_c16) l = mbstoc16_lf((char16_t *)NULL, ldt, 0, lf_conv); #endif /* __CHAR16_UTF_16__ */ return l; } SQLLEN bindcol_hybrid_exec(SQLWCHAR *utf16, const char *ldt, size_t n, BOOL lf_conv, char **wcsbuf) { UNUSED(ldt, utf16, wcsbuf); SQLLEN l = (-2); get_convtype(); MYLOG(ES_DEBUG, " size=" FORMAT_SIZE_T " lf_conv=%d\n", n, lf_conv); #if defined(__WCS_ISO10646__) if (use_wcs) { unsigned int *utf32 = NULL; BOOL midbuf = (wcsbuf && *wcsbuf); #pragma warning(push) #pragma warning(disable : 4127) if (sizeof(SQLWCHAR) == sizeof(wchar_t)) #pragma warning(pop) { if (midbuf) l = msgtowstr(*wcsbuf, (wchar_t *)utf16, (int)n); else l = msgtowstr(ldt, (wchar_t *)utf16, (int)n); } else if (midbuf) { utf32 = (unsigned int *)*wcsbuf; l = ucs4_to_ucs2_lf(utf32, -1, utf16, (int)n, lf_conv); } else { int count = (int)strlen(ldt); utf32 = (unsigned int *)malloc((count + 1) * sizeof(unsigned int)); if ((l = msgtowstr(ldt, (wchar_t *)utf32, count + 1)) >= 0) { l = ucs4_to_ucs2_lf(utf32, -1, utf16, (int)n, lf_conv); } free(utf32); } if (midbuf) { free(*wcsbuf); *wcsbuf = NULL; } } #endif /* __WCS_ISO10646__ */ #ifdef __CHAR16_UTF_16__ if (use_c16) { l = mbstoc16_lf((char16_t *)utf16, ldt, n, lf_conv); } #endif /* __CHAR16_UTF_16__ */ return l; } SQLLEN locale_to_sqlwchar(SQLWCHAR *utf16, const char *ldt, size_t n, BOOL lf_conv) { return bindcol_hybrid_exec(utf16, ldt, n, lf_conv, NULL); } // // SQLBindCol localize case // UTF-8 => the current locale // SQLLEN bindcol_localize_estimate(const char *utf8dt, BOOL lf_conv, char **wcsbuf) { UNUSED(utf8dt); SQLLEN l = (-2); char *convalc = NULL; get_convtype(); MYLOG(ES_DEBUG, " lf_conv=%d\n", lf_conv); #if defined(__WCS_ISO10646__) if (use_wcs) { wchar_t *wcsalc = NULL; l = utf8_to_wcs_lf(utf8dt, -1, lf_conv, NULL, 0, FALSE); wcsalc = (wchar_t *)malloc(sizeof(wchar_t) * (l + 1)); convalc = (char *)wcsalc; l = utf8_to_wcs_lf(utf8dt, -1, lf_conv, wcsalc, l + 1, FALSE); l = wstrtomsg(wcsalc, NULL, 0); } #endif /* __WCS_ISO10646__ */ #ifdef __CHAR16_UTF_16__ if (use_c16) { SQLWCHAR *wcsalc = NULL; l = utf8_to_ucs2_lf(utf8dt, -1, lf_conv, (SQLWCHAR *)NULL, 0, FALSE); wcsalc = (SQLWCHAR *)malloc(sizeof(SQLWCHAR) * (l + 1)); convalc = (char *)wcsalc; l = utf8_to_ucs2_lf(utf8dt, -1, lf_conv, wcsalc, l + 1, FALSE); l = c16tombs(NULL, (char16_t *)wcsalc, 0); } #endif /* __CHAR16_UTF_16__ */ if (l < 0 && NULL != convalc) free(convalc); else if (NULL != convalc) *wcsbuf = (char *)convalc; MYLOG(ES_DEBUG, " return=" FORMAT_LEN "\n", l); return l; } SQLLEN bindcol_localize_exec(char *ldt, size_t n, BOOL lf_conv, char **wcsbuf) { UNUSED(ldt, lf_conv); SQLLEN l = (-2); get_convtype(); MYLOG(ES_DEBUG, " size=" FORMAT_SIZE_T "\n", n); #if defined(__WCS_ISO10646__) if (use_wcs) { wchar_t *wcsalc = (wchar_t *)*wcsbuf; l = wstrtomsg(wcsalc, ldt, (int)n); } #endif /* __WCS_ISO10646__ */ #ifdef __CHAR16_UTF_16__ if (use_c16) { char16_t *wcsalc = (char16_t *)*wcsbuf; l = c16tombs(ldt, (char16_t *)wcsalc, n); } #endif /* __CHAR16_UTF_16__ */ free(*wcsbuf); *wcsbuf = NULL; MYLOG(ES_DEBUG, " return=" FORMAT_LEN "\n", l); return l; } #endif /* UNICODE_SUPPORT */
the_stack_data/100140433.c
// RUN: clang-cc -verify -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-store=region %s struct tea_cheese { unsigned magic; }; typedef struct tea_cheese kernel_tea_cheese_t; extern kernel_tea_cheese_t _wonky_gesticulate_cheese; // This test case exercises the ElementRegion::getRValueType() logic. void test1( void ) { kernel_tea_cheese_t *wonky = &_wonky_gesticulate_cheese; struct load_wine *cmd = (void*) &wonky[1]; cmd = cmd; char *p = (void*) &wonky[1]; kernel_tea_cheese_t *q = &wonky[1]; // This test case tests both the RegionStore logic (doesn't crash) and // the out-of-bounds checking. We don't expect the warning for now since // out-of-bound checking is temporarily disabled. kernel_tea_cheese_t r = *q; // expected-warning{{Access out-of-bound array element (buffer overflow)}} } void test1_b( void ) { kernel_tea_cheese_t *wonky = &_wonky_gesticulate_cheese; struct load_wine *cmd = (void*) &wonky[1]; cmd = cmd; char *p = (void*) &wonky[1]; *p = 1; // expected-warning{{Access out-of-bound array element (buffer overflow)}} }
the_stack_data/145453696.c
// Program to copy the contents of the file given by the // filename in first command line argument, to the file // given by the filename in the second command line argument #include <stdio.h> int main(int argc, char *argv[]) { // check number of command-line arguments = 2 if (argc != 3) { puts("Usage: mycopy infile outfile"); } else { FILE *inFilePtr; // input file pointer // try to open the input file in read mode if ((inFilePtr = fopen(argv[1], "r")) != NULL) { FILE *outFilePtr; // output file pointer // try to open the output file in write mode if ((outFilePtr = fopen(argv[2], "w")) != NULL) { int c; // holds characters read from source file // read from input and output characters to output file while ((c = fgetc(inFilePtr)) != EOF) { fputc(c, outFilePtr); } fclose(outFilePtr); // close the output file } else { // output file could not be opened printf("File \"%s\" could not be opened\n", argv[2]); } fclose(inFilePtr); // close the input file } else { // input file could not be opened printf("File \"%s\" could not be opened\n", argv[1]); } } } /************************************************************************** * (C) Copyright 1992-2015 by Deitel & Associates, Inc. and * * Pearson Education, Inc. All Rights Reserved. * * * * DISCLAIMER: The authors and publisher of this book have used their * * best efforts in preparing the book. These efforts include the * * development, research, and testing of the theories and programs * * to determine their effectiveness. The authors and publisher make * * no warranty of any kind, expressed or implied, with regard to these * * programs or to the documentation contained in these books. The authors * * and publisher shall not be liable in any event for incidental or * * consequential damages in connection with, or arising out of, the * * furnishing, performance, or use of these programs. * *************************************************************************/
the_stack_data/47848.c
#include <fcntl.h> #include <unistd.h> #include <stdio.h> int main() { return write (1, "TEST", 4); }
the_stack_data/126433.c
/* Copyright 2016 Samsung Electronics Co., Ltd. * * 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. */ #if defined(__NUTTX__) #include <uv.h> #include <nuttx/analog/adc.h> #include <stdlib.h> #include "iotjs_def.h" #include "iotjs_systemio-arm-nuttx.h" #include "module/iotjs_module_adc.h" #include "module/iotjs_module_pin.h" #define ADC_DEVICE_PATH_FORMAT "/dev/adc%d" #define ADC_DEVICE_PATH_BUFFER_SIZE 12 static void iotjs_adc_get_path(char* buffer, int32_t number) { // Create ADC device path snprintf(buffer, ADC_DEVICE_PATH_BUFFER_SIZE - 1, ADC_DEVICE_PATH_FORMAT, number); } #define ADC_WORKER_INIT_TEMPLATE \ iotjs_adc_reqwrap_t* req_wrap = iotjs_adc_reqwrap_from_request(work_req); \ iotjs_adc_reqdata_t* req_data = iotjs_adc_reqwrap_data(req_wrap); static bool iotjs_adc_read_data(int32_t pin, struct adc_msg_s* msg) { int32_t adc_number = ADC_GET_NUMBER(pin); char path[ADC_DEVICE_PATH_BUFFER_SIZE] = { 0 }; iotjs_adc_get_path(path, adc_number); const iotjs_environment_t* env = iotjs_environment_get(); uv_loop_t* loop = iotjs_environment_loop(env); int result, close_result; // Open file uv_fs_t open_req; result = uv_fs_open(loop, &open_req, path, O_RDONLY, 0666, NULL); uv_fs_req_cleanup(&open_req); if (result < 0) { return false; } // Read value uv_fs_t read_req; uv_buf_t uvbuf = uv_buf_init((char*)msg, sizeof(*msg)); result = uv_fs_read(loop, &read_req, open_req.result, &uvbuf, 1, 0, NULL); uv_fs_req_cleanup(&read_req); // Close file uv_fs_t close_req; close_result = uv_fs_close(loop, &close_req, open_req.result, NULL); uv_fs_req_cleanup(&close_req); if (result < 0 || close_result < 0) { return false; } DDLOG("ADC Read - path: %s, value: %d", path, msg->am_data); return true; } void iotjs_adc_export_worker(uv_work_t* work_req) { ADC_WORKER_INIT_TEMPLATE; int32_t pin = req_data->pin; int32_t adc_number = ADC_GET_NUMBER(pin); int32_t timer = SYSIO_GET_TIMER(pin); struct adc_dev_s* adc = iotjs_adc_config_nuttx(adc_number, timer, pin); char path[ADC_DEVICE_PATH_BUFFER_SIZE] = { 0 }; iotjs_adc_get_path(path, adc_number); if (adc_register(path, adc) != 0) { req_data->result = kAdcErrExport; return; } DDLOG("ADC Export - path: %s, number: %d, timer: %d", path, adc_number, timer); req_data->result = kAdcErrOk; } void iotjs_adc_read_worker(uv_work_t* work_req) { ADC_WORKER_INIT_TEMPLATE; struct adc_msg_s msg; if (!iotjs_adc_read_data(req_data->pin, &msg)) { req_data->result = kAdcErrRead; return; } req_data->value = msg.am_data; req_data->result = kAdcErrOk; } int32_t iotjs_adc_read_sync(int32_t pin) { struct adc_msg_s msg; if (!iotjs_adc_read_data(pin, &msg)) { return -1; } return msg.am_data; } void iotjs_adc_unexport_worker(uv_work_t* work_req) { ADC_WORKER_INIT_TEMPLATE; int32_t pin = req_data->pin; int32_t adc_number = ADC_GET_NUMBER(pin); char path[ADC_DEVICE_PATH_BUFFER_SIZE] = { 0 }; iotjs_adc_get_path(path, adc_number); // Release driver if (unregister_driver(path) < 0) { req_data->result = kAdcErrUnexport; return; } iotjs_gpio_unconfig_nuttx(pin); req_data->result = kAdcErrOk; } #endif // __NUTTX__
the_stack_data/101375.c
#include <stddef.h> #include <stdlib.h> int *mx_copy_int_arr(const int *src, int size); int *mx_copy_int_arr(const int *src, int size){ if(src == NULL) return NULL; int *array = (int *)(malloc(size * sizeof(int))); for(int i = 0; i < size; i++) array[i] = src[i]; return array; }
the_stack_data/32951304.c
/* -------------------------------------------------------------------------- * Name: tags-common.c * Purpose: Common tags behaviour * ----------------------------------------------------------------------- */ #ifdef EYE_TAGS #include <assert.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "fortify/fortify.h" #include "oslib/hourglass.h" #include "oslib/osfile.h" #include "oslib/osfscontrol.h" #include "databases/digest-db.h" #include "databases/filename-db.h" #include "databases/tag-db.h" #include "appengine/types.h" #include "appengine/base/errors.h" #include "appengine/datastruct/array.h" #include "appengine/gadgets/tag-cloud.h" #include "appengine/graphics/image.h" #include "appengine/io/md5.h" #include "privateeye.h" #include "tags-common.h" #define TAGS_DIR "<Choices$Write>." APPNAME ".Tags" #define TAGS_SECTION TAGS_DIR ".Default" #define TAGDB_FILE TAGS_SECTION ".Tags" #define FILENAMEDB_FILE TAGS_SECTION ".Filenames" #define TAGS_BACKUP_DIR TAGS_SECTION ".Backups" #define TAGDB_BACKUP_FILE TAGS_BACKUP_DIR ".Tags" #define FILENAMEDB_BACKUP_FILE TAGS_BACKUP_DIR ".Filenames" /* ----------------------------------------------------------------------- */ static struct { tagdb_t *db; /* maps digests to tags */ filenamedb_t *fdb; /* maps digests to filenames */ int backed_up; /* have we backed up during this session? */ } LOCALS; /* ----------------------------------------------------------------------- */ tagdb_t *tags_common_get_db(void) { return LOCALS.db; } filenamedb_t *tags_common_get_filename_db(void) { return LOCALS.fdb; } /* ----------------------------------------------------------------------- */ // unused /* FIXME: This is probably in the wrong place. */ void tags_common_choices_updated(const choices *cs) { NOT_USED(cs); /* for (each tag cloud) if (LOCALS.tc) set_config(LOCALS.tc); */ } /* ----------------------------------------------------------------------- */ static os_error *forcecopy(const char *src, const char *dst) { return xosfscontrol_copy(src, dst, osfscontrol_COPY_FORCE, 0, 0, 0, 0, NULL); } static void backup(void) { os_error *err; if (LOCALS.backed_up) return; hourglass_on(); /* backup the databases */ err = xosfile_create_dir(TAGS_BACKUP_DIR, 0); if (err) goto exit; err = forcecopy(TAGDB_FILE, TAGDB_BACKUP_FILE); if (err) goto exit; err = forcecopy(FILENAMEDB_FILE, FILENAMEDB_BACKUP_FILE); if (err) goto exit; hourglass_off(); LOCALS.backed_up = 1; exit: return; } /* ----------------------------------------------------------------------- */ result_t tags_common_add_tag(tag_cloud *tc, const char *name, int length, void *opaque) { result_t err; tags_common *common = opaque; NOT_USED(length); tagdb_add(common->db, name, NULL); err = tags_common_set_tags(tc, common); if (err) return err; return result_OK; } result_t tags_common_delete_tag(tag_cloud *tc, int index, void *opaque) { result_t err; tags_common *common = opaque; tagdb_remove(common->db, common->indextotag[index]); err = tags_common_set_tags(tc, common); if (err) return err; return result_OK; } result_t tags_common_rename_tag(tag_cloud *tc, int index, const char *name, int length, void *opaque) { result_t err; tags_common *common = opaque; NOT_USED(length); err = tagdb_rename(common->db, common->indextotag[index], name); if (err) return err; err = tags_common_set_tags(tc, common); if (err) return err; return result_OK; } result_t tags_common_tag(tag_cloud *tc, int index, const char *digest, const char *file_name, void *opaque) { result_t err; tags_common *common = opaque; err = tagdb_tagid(common->db, digest, common->indextotag[index]); if (err) return err; err = filenamedb_add(LOCALS.fdb, digest, file_name); if (err) return err; err = tags_common_set_tags(tc, common); if (err) return err; return result_OK; } result_t tags_common_detag(tag_cloud *tc, int index, const char *digest, void *opaque) { result_t err; tags_common *common = opaque; err = tagdb_untagid(common->db, digest, common->indextotag[index]); if (err) return err; /* We _don't_ remove from the filenamedb here, as there may be other tags * applied to the same file. */ err = tags_common_set_tags(tc, common); if (err) return err; return result_OK; } result_t tags_common_tagfile(tag_cloud *tc, const char *file_name, int index, void *opaque) { result_t err; tags_common *common = opaque; unsigned char digest[md5_DIGESTSZ]; assert(md5_DIGESTSZ == digestdb_DIGESTSZ); err = md5_from_file(file_name, digest); if (err) return err; err = tagdb_tagid(common->db, (char *) digest, common->indextotag[index]); if (err) return err; err = filenamedb_add(LOCALS.fdb, (char *) digest, file_name); if (err) return err; err = tags_common_set_tags(tc, common); if (err) return err; return result_OK; } result_t tags_common_detagfile(tag_cloud *tc, const char *file_name, int index, void *opaque) { result_t err; tags_common *common = opaque; unsigned char digest[md5_DIGESTSZ]; assert(md5_DIGESTSZ == digestdb_DIGESTSZ); err = md5_from_file(file_name, digest); if (err) return err; err = tagdb_untagid(common->db, (char *) digest, common->indextotag[index]); if (err) return err; err = tags_common_set_tags(tc, common); if (err) return err; return result_OK; } result_t tags_common_event(tag_cloud *tc, tag_cloud_event event, void *opaque) { NOT_USED(tc); NOT_USED(opaque); switch (event) { case tag_cloud_EVENT_COMMIT: /* Backup before we write out the databases. */ backup(); // would it be best to backup at start of session only? filenamedb_commit(LOCALS.fdb); tagdb_commit(LOCALS.db); break; } return result_OK; } /* ----------------------------------------------------------------------- */ #define BUFMIN 128 /* minimum size of name buffer */ #define TAGMIN 8 /* minimum size of tags array */ result_t tags_common_set_tags(tag_cloud *tc, tags_common *common) { result_t err; int tagsallocated; tag_cloud_tag *tags; int bufallocated; char *buf; char *bufp; char *bufend; int cont; int ntags; tag_cloud_tag *t; int ittallocated; tagdb_tag_t *indextotag; tagsallocated = 0; /* allocated */ tags = NULL; bufallocated = 0; buf = NULL; bufp = buf; bufend = buf; ittallocated = 0; indextotag = NULL; // free indextotag map free(common->indextotag); common->indextotag = NULL; cont = 0; ntags = 0; for (;;) { tagdb_tag_t tag; int count; size_t length; err = tagdb_enumerate_tags(common->db, &cont, &tag, &count); if (err) goto failure; if (cont == 0) break; /* none left */ do { err = tagdb_tagtoname(common->db, tag, bufp, &length, bufend - bufp); if (err == result_TAGDB_BUFF_OVERFLOW) { char *oldbuf; oldbuf = buf; if (array_grow((void **) &buf, sizeof(*buf), bufp - buf, /* used */ &bufallocated, length, BUFMIN)) { err = result_OOM; goto failure; } /* adjust buffer interior pointers */ bufp += buf - oldbuf; bufend = buf + bufallocated; } else if (err) { goto failure; } } while (err == result_TAGDB_BUFF_OVERFLOW); if (array_grow((void **) &tags, sizeof(*tags), ntags, /* used */ &tagsallocated, 1, /* need */ TAGMIN)) { err = result_OOM; goto failure; } if (array_grow((void **) &indextotag, sizeof(*indextotag), ntags, /* used */ &ittallocated, 1, /* need */ TAGMIN)) { err = result_OOM; goto failure; } assert(tagsallocated == ittallocated); length--; /* tagdb_tagtoname returns length inclusive of terminator. compensate. */ /* store as a delta now, fix up later */ tags[ntags].name = (void *) (bufp - buf); tags[ntags].length = length; tags[ntags].count = count; indextotag[ntags] = tag; ntags++; bufp += length; } /* We've stored the tag name pointers as deltas so we can cope when the * block moves. We now fix them all up. */ for (t = tags; t < tags + ntags; t++) t->name = buf + (int) t->name; err = tag_cloud_set_tags(tc, tags, ntags); if (err) goto failure; free(buf); free(tags); // store indextotag common->indextotag = indextotag; common->nindextotag = ntags; return result_OK; failure: return err; } /* ----------------------------------------------------------------------- */ #define HLMIN 8 /* minimum allocated size of tags array */ result_t tags_common_set_highlights(tag_cloud *tc, image_t *image, tags_common *common) { result_t err; unsigned char digest[image_DIGESTSZ]; int *indices; int nindices; int allocated; int cont; tagdb_tag_t tag; if (image == NULL) return result_OK; err = image_get_digest(image, digest); if (err) goto failure; indices = NULL; nindices = 0; allocated = 0; cont = 0; for (;;) { int i; err = tagdb_get_tags_for_id(common->db, (char *) digest, &cont, &tag); if (err == result_TAGDB_UNKNOWN_ID) break; else if (err) goto failure; if (cont == 0) break; /* none left */ if (array_grow((void **) &indices, sizeof(*indices), nindices, /* used */ &allocated, 1, HLMIN)) { err = result_OOM; goto failure; } /* search for index */ for (i = 0; i < common->nindextotag; i++) if (common->indextotag[i] == tag) break; indices[nindices++] = i; } err = tag_cloud_highlight(tc, indices, nindices); if (err) goto failure; free(indices); return result_OK; failure: return err; } result_t tags_common_clear_highlights(tag_cloud *tc) { return tag_cloud_highlight(tc, NULL, 0); } /* ----------------------------------------------------------------------- */ static int tags_common_refcount = 0; result_t tags_common_init(void) { result_t err; if (tags_common_refcount++ == 0) { /* dependencies */ err = tagdb_init(); if (err) goto failure; err = filenamedb_init(); if (err) { tagdb_fin(); goto failure; } err = tag_cloud_init(); if (err) { filenamedb_fin(); tagdb_fin(); goto failure; } } return result_OK; failure: return err; } void tags_common_fin(void) { if (--tags_common_refcount == 0) { tags_common_lazyfin(1); /* force shutdown */ tag_cloud_fin(); filenamedb_fin(); tagdb_fin(); } } /* ----------------------------------------------------------------------- */ /* The 'lazy' init/fin functions provide lazy initialisation. */ static unsigned int tags_common_lazyrefcount = 0; result_t tags_common_lazyinit(void) { result_t err; if (tags_common_lazyrefcount == 0) { os_error *oserr; tagdb_t *db = NULL; filenamedb_t *fdb = NULL; /* initialise */ hourglass_on(); oserr = xosfile_create_dir(TAGS_DIR, 0); if (oserr == NULL) oserr = xosfile_create_dir(TAGS_SECTION, 0); if (oserr) { err = result_OS; goto failure; } err = tagdb_open(TAGDB_FILE, &db); if (err) goto failure; err = filenamedb_open(FILENAMEDB_FILE, &fdb); if (err) goto failure; LOCALS.db = db; LOCALS.fdb = fdb; hourglass_off(); } tags_common_lazyrefcount++; return result_OK; failure: hourglass_off(); /* FIXME: Cleanup code is missing. */ return err; } void tags_common_lazyfin(int force) { /* allow a forced shutdown only if we're not at refcount zero */ if (tags_common_lazyrefcount == 0) return; if (force) tags_common_lazyrefcount = 1; if (--tags_common_lazyrefcount == 0) { /* backup before we write out the databases */ backup(); filenamedb_close(LOCALS.fdb); tagdb_close(LOCALS.db); } } /* ----------------------------------------------------------------------- */ #else extern int dummy; #endif /* EYE_TAGS */
the_stack_data/1000857.c
#include <stdio.h> int main(void) { printf("Hello! World!\n"); printf("哈囉!C 語言!\n"); return 0; }
the_stack_data/30346.c
/* Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at the Lawrence Livermore National Laboratory Written by Chunhua Liao, Pei-Hung Lin, Joshua Asplund, Markus Schordan, and Ian Karlin (email: [email protected], [email protected], [email protected], [email protected], [email protected]) LLNL-CODE-732144 All rights reserved. This file is part of DataRaceBench. For details, see https://github.com/LLNL/dataracebench. Please also see the LICENSE file for our additional BSD notice. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the disclaimer below. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the disclaimer (as noted below) in the documentation and/or other materials provided with the distribution. * Neither the name of the LLNS/LLNL nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* A linear expression is used as array subscription. Data race pair: a[2*i+1]@66:5 vs. a[i]@66:14 */ #include <stdlib.h> int main(int argc, char* argv[]) { int i; int len=2000; if (argc>1) len = atoi(argv[1]); int a[len]; #pragma omp parallel for private(i ) for (i=0; i<len; i++) a[i]=i; for (i=0;i<len/2;i++) a[2*i+1]=a[i]+1; for (i=0; i<len; i++) printf("%d\n", a[i]); return 0; }
the_stack_data/496560.c
/* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* * University Copyright- Copyright (c) 1982, 1986, 1988 * The Regents of the University of California * All Rights Reserved * * University Acknowledgment- Portions of this document are derived from * software developed by the University of California, Berkeley, and its * contributors. */ #pragma ident "%Z%%M% %I% %E% SMI" #include <sys/termios.h> #include <fcntl.h> /* * detach from tty */ void detachfromtty(void) { int tt; close(0); close(1); close(2); switch (fork1()) { case -1: perror("fork1"); break; case 0: break; default: exit(0); } /* become session leader, and disassociate from controlling tty */ (void) setsid(); (void) open("/dev/null", O_RDWR, 0); dup(0); dup(0); }