file
stringlengths
18
26
data
stringlengths
3
1.04M
the_stack_data/153268498.c
#define _GNU_SOURCE #include <stdint.h> #include <string.h> static char* twobyte_memmem(const unsigned char* h, size_t k, const unsigned char* n) { uint16_t nw = n[0] << 8 | n[1], hw = h[0] << 8 | h[1]; for (h += 2, k -= 2; k; k--, hw = hw << 8 | *h++) if (hw == nw) return (char*)h - 2; return hw == nw ? (char*)h - 2 : 0; } static char* threebyte_memmem(const unsigned char* h, size_t k, const unsigned char* n) { uint32_t nw = n[0] << 24 | n[1] << 16 | n[2] << 8; uint32_t hw = h[0] << 24 | h[1] << 16 | h[2] << 8; for (h += 3, k -= 3; k; k--, hw = (hw | *h++) << 8) if (hw == nw) return (char*)h - 3; return hw == nw ? (char*)h - 3 : 0; } static char* fourbyte_memmem(const unsigned char* h, size_t k, const unsigned char* n) { uint32_t nw = n[0] << 24 | n[1] << 16 | n[2] << 8 | n[3]; uint32_t hw = h[0] << 24 | h[1] << 16 | h[2] << 8 | h[3]; for (h += 4, k -= 4; k; k--, hw = hw << 8 | *h++) if (hw == nw) return (char*)h - 4; return hw == nw ? (char*)h - 4 : 0; } #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define MIN(a, b) ((a) < (b) ? (a) : (b)) #define BITOP(a, b, op) \ ((a)[(size_t)(b) / (8 * sizeof *(a))] op(size_t) 1 << ((size_t)(b) % (8 * sizeof *(a)))) static char* twoway_memmem(const unsigned char* h, const unsigned char* z, const unsigned char* n, size_t l) { size_t i, ip, jp, k, p, ms, p0, mem, mem0; size_t byteset[32 / sizeof(size_t)] = {}; size_t shift[256]; /* Computing length of needle and fill shift table */ for (i = 0; i < l; i++) BITOP(byteset, n[i], |=) , shift[n[i]] = i + 1; /* Compute maximal suffix */ ip = -1; jp = 0; k = p = 1; while (jp + k < l) { if (n[ip + k] == n[jp + k]) { if (k == p) { jp += p; k = 1; } else k++; } else if (n[ip + k] > n[jp + k]) { jp += k; k = 1; p = jp - ip; } else { ip = jp++; k = p = 1; } } ms = ip; p0 = p; /* And with the opposite comparison */ ip = -1; jp = 0; k = p = 1; while (jp + k < l) { if (n[ip + k] == n[jp + k]) { if (k == p) { jp += p; k = 1; } else k++; } else if (n[ip + k] < n[jp + k]) { jp += k; k = 1; p = jp - ip; } else { ip = jp++; k = p = 1; } } if (ip + 1 > ms + 1) ms = ip; else p = p0; /* Periodic needle? */ if (memcmp(n, n + p, ms + 1)) { mem0 = 0; p = MAX(ms, l - ms - 1) + 1; } else mem0 = l - p; mem = 0; /* Search loop */ for (;;) { /* If remainder of haystack is shorter than needle, done */ if (z - h < l) return 0; /* Check last byte first; advance by shift on mismatch */ if (BITOP(byteset, h[l - 1], &)) { k = l - shift[h[l - 1]]; if (k) { if (mem0 && mem && k < p) k = l - p; h += k; mem = 0; continue; } } else { h += l; mem = 0; continue; } /* Compare right half */ for (k = MAX(ms + 1, mem); k < l && n[k] == h[k]; k++) ; if (k < l) { h += k - ms; mem = 0; continue; } /* Compare left half */ for (k = ms + 1; k > mem && n[k - 1] == h[k - 1]; k--) ; if (k <= mem) return (char*)h; h += p; mem = mem0; } } void* memmem(const void* h0, size_t k, const void* n0, size_t l) { const unsigned char *h = h0, *n = n0; /* Return immediately on empty needle */ if (!l) return (void*)h; /* Return immediately when needle is longer than haystack */ if (k < l) return 0; /* Use faster algorithms for short needles */ h = memchr(h0, *n, k); if (!h || l == 1) return (void*)h; k -= h - (const unsigned char*)h0; if (k < l) return 0; if (l == 2) return twobyte_memmem(h, k, n); if (l == 3) return threebyte_memmem(h, k, n); if (l == 4) return fourbyte_memmem(h, k, n); return twoway_memmem(h, h + k, n, l); }
the_stack_data/86074410.c
#include <stdio.h> #include <stdlib.h> #include <string.h> int main (int argc, char** argv) { int d = -1, td, w, i, sat = 0; for (i = 1; i < argc; i++) { if (!strcmp (argv[i], "-h")) { printf ("usage: pjex [-h][-s|--sat] <num-bits>\n"); exit (0); } if (!strcmp (argv[i], "-s") || !strcmp (argv[i], "--sat")) sat = 1; else if (argv[i][0] == '-') { fprintf (stderr, "*** pjex: invalid option '%s'\n", argv[i]); printf ("usage: pjex [-h][-s|--sat] <num-bits>\n"); exit (1); } else if (d > 0) { fprintf (stderr, "*** pjex: multiple '<num-bits>' options\n"); printf ("usage: pjex [-h][-s|--sat] <num-bits>\n"); exit (1); } else if ((d = atoi (argv[i])) <= 1) { fprintf (stderr, "*** pjex: argument '%s' invalid\n", argv[i]); printf ("usage: pjex [-h][-s|--sat] <num-bits>\n"); exit (1); } } if (d < 0) { fprintf (stderr, "*** pjex: argument missing\n"); printf ("usage: pjex [-h][-s|--sat] <num-bits>\n"); exit (1); } printf ("; Pete Jeavons Example CSP example\n"); td = 2 * d; w = 1; while ((1 << (w - 1)) <= d) w++; printf ("; d = %d, 2d = %d, w = %d\n", d, td, w); printf ("(set-logic QF_BV)\n"); printf ("(declare-fun lb () (_ BitVec %d))\n", w); printf ("(declare-fun ub () (_ BitVec %d))\n", w); for (i = 1; i <= td; i++) printf ("(declare-fun x1a%d () (_ BitVec %d))\n", i, w), printf ("(declare-fun x2a%d () (_ BitVec %d))\n", i, w); printf ("(assert (= lb (_ bv1 %d)))\n", w); printf ("(assert (= ub (_ bv%d %d)))\n", d, w); for (i = 1; i <= td; i++) printf ("(assert (and (bvule lb x1a%d) (bvule x1a%d ub)))\n", i, i), printf ("(assert (and (bvule lb x2a%d) (bvule x2a%d ub)))\n", i, i); for (i = 1; i < td; i++) { if (i == td - 1 && sat) printf (";"); printf ("(assert (bvult (bvadd x1a%d x2a%d) (bvadd x1a%d x2a%d)))\n", i, i, i + 1, i + 1); } printf ("(check-sat)\n"); printf ("(exit)\n"); return 0; }
the_stack_data/38454.c
// RUN: env SOUPER_NO_EXTERNAL_CACHE=1 SOUPER_DYNAMIC_PROFILE=1 %sclang -O %s -o %t // RUN: env SOUPER_PROFILE_TO_STDOUT=1 %t 0 | %FileCheck %s -check-prefix=ARG0 // ARG0: count = 0 // RUN: env SOUPER_PROFILE_TO_STDOUT=1 %t 1 | %FileCheck %s -check-prefix=ARG1 // ARG1: count = 1 // RUN: env SOUPER_PROFILE_TO_STDOUT=1 %t 2 | %FileCheck %s -check-prefix=ARG2 // ARG2: count = 100 // RUN: env SOUPER_PROFILE_TO_STDOUT=1 %t 3 | %FileCheck %s -check-prefix=ARG3 // ARG3: count = 101 // RUN: env SOUPER_PROFILE_TO_STDOUT=1 %t 4 | %FileCheck %s -check-prefix=ARG4 // ARG4: count = 10000 // RUN: env SOUPER_PROFILE_TO_STDOUT=1 %t 5 | %FileCheck %s -check-prefix=ARG5 // ARG5: count = 10001 // RUN: env SOUPER_PROFILE_TO_STDOUT=1 %t 6 | %FileCheck %s -check-prefix=ARG6 // ARG6: count = 10100 // RUN: env SOUPER_PROFILE_TO_STDOUT=1 %t 7 | %FileCheck %s -check-prefix=ARG7 // ARG7: count = 10101 #include <stdlib.h> volatile unsigned opaque; // this is fragile: any code where Souper can find an optimization that LLVM // misses void souper_opt(void) { unsigned a = opaque & 0xf; if (__builtin_popcount(a) + __builtin_popcount(~a) == 32) ++opaque; } int main(int argc, char *argv[]) { if (argc != 2) abort(); long arg = strtol(argv[1], 0, 10); if (arg < 0 || arg > 7) abort(); if (arg & 1) souper_opt(); int i; for (i = 0; i < 100; ++i) { if (arg & 2) souper_opt(); int j; for (j = 0; j < 100; ++j) { if (arg & 4) souper_opt(); } } return 0; }
the_stack_data/778817.c
/* * SSD.c * * Created on: Aug 22, 2021 * Author: omar */
the_stack_data/154826984.c
#ifdef VULKAN_BACKEND #include "log/log.h" #include "../renderer_private.h" #include "vulkan_enum_translators.h" #include "vulkan_pass_hasher.h" struct VulkanPassHasher { const struct VulkanDevice* device; struct hashmap* render_passes; struct hashmap* framebuffers; }; static struct VulkanPassHasher hasher; struct RenderPassMapItem { struct RenderPassBeginInfo info; VkRenderPass render_pass; }; struct FramebufferMapItem { struct RenderPassBeginInfo info; VkFramebuffer framebuffer; }; static inline b32 has_depth_stencil( const struct RenderPassBeginInfo* info ) { return info->depth_attachment.image != NULL; } static inline i32 compare_attachments( const struct AttachmentInfo* a, const struct AttachmentInfo* b ) { const struct Image* ia = a->image; const struct Image* ib = b->image; if ( ia->format != ib->format ) { return 1; } if ( ia->sample_count != ib->sample_count ) { return 1; } if ( a->load_op != b->load_op ) { return 1; } return 0; } static b32 compare_pass_info( const void* a, const void* b, void* udata ) { FT_UNUSED( udata ); const struct RenderPassBeginInfo* rpa = a; const struct RenderPassBeginInfo* rpb = b; if ( rpa->color_attachment_count != rpb->color_attachment_count ) return 0; if ( has_depth_stencil( rpa ) != has_depth_stencil( rpb ) ) { return 1; } for ( u32 i = 0; i < rpa->color_attachment_count; ++i ) { if ( compare_attachments( &rpa->color_attachments[ i ], &rpb->color_attachments[ i ] ) ) { return 1; } } if ( has_depth_stencil( rpa ) ) { if ( compare_attachments( &rpa->depth_attachment, &rpb->depth_attachment ) ) { return 1; } } return 0; } static u64 hash_pass_info( const void* item, u64 seed0, u64 seed1 ) { FT_UNUSED( item ); FT_UNUSED( seed0 ); FT_UNUSED( seed1 ); // TODO: hash function return 0; } static b32 compare_framebuffer_info( const void* a, const void* b, void* udata ) { FT_UNUSED( udata ); const struct RenderPassBeginInfo* rpa = a; const struct RenderPassBeginInfo* rpb = b; if ( rpa->color_attachment_count != rpb->color_attachment_count ) { return 1; } for ( u32 i = 0; i < rpa->color_attachment_count; ++i ) { if ( rpa->color_attachments[ i ].image != rpb->color_attachments[ i ].image ) { return 1; } } if ( has_depth_stencil( rpa ) != has_depth_stencil( rpb ) ) { return 1; } if ( has_depth_stencil( rpa ) ) { if ( rpa->depth_attachment.image != rpb->depth_attachment.image ) { return 1; } } return 0; } static u64 hash_framebuffer_info( const void* item, u64 seed0, u64 seed1 ) { FT_UNUSED( item ); FT_UNUSED( seed0 ); FT_UNUSED( seed1 ); // TODO: hash function return 0; } void vk_create_render_pass( const struct VulkanDevice* device, const struct RenderPassBeginInfo* info, VkRenderPass* p ) { u32 attachments_count = info->color_attachment_count; VkAttachmentDescription attachments[ MAX_ATTACHMENTS_COUNT + 2 ]; VkAttachmentReference color_references[ MAX_ATTACHMENTS_COUNT ]; VkAttachmentReference depth_reference = { 0 }; for ( u32 i = 0; i < info->color_attachment_count; ++i ) { const struct AttachmentInfo* att = &info->color_attachments[ i ]; attachments[ i ] = ( VkAttachmentDescription ) { .flags = 0, .format = to_vk_format( att->image->format ), .samples = to_vk_sample_count( att->image->sample_count ), .loadOp = to_vk_load_op( att->load_op ), .storeOp = VK_ATTACHMENT_STORE_OP_STORE, .stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE, .stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE, .initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, .finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, }; color_references[ i ] = ( VkAttachmentReference ) { .attachment = i, .layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, }; } if ( has_depth_stencil( info ) ) { u32 i = attachments_count; const struct AttachmentInfo* att = &info->depth_attachment; attachments[ i ] = ( VkAttachmentDescription ) { .flags = 0, .format = to_vk_format( att->image->format ), .samples = to_vk_sample_count( att->image->sample_count ), .loadOp = to_vk_load_op( att->load_op ), .storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE, .stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE, .stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE, .initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, .finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, }; depth_reference = ( VkAttachmentReference ) { .attachment = i, .layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, }; attachments_count++; } VkSubpassDescription subpass = { .flags = 0, .pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS, .inputAttachmentCount = 0, .pInputAttachments = NULL, .colorAttachmentCount = info->color_attachment_count, .pColorAttachments = color_references, .pDepthStencilAttachment = has_depth_stencil( info ) ? &depth_reference : NULL, .pResolveAttachments = NULL, .preserveAttachmentCount = 0, .pPreserveAttachments = NULL, }; VkRenderPassCreateInfo render_pass_create_info = { .sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, .pNext = NULL, .flags = 0, .attachmentCount = attachments_count, .pAttachments = attachments, .subpassCount = 1, .pSubpasses = &subpass, .dependencyCount = 0, .pDependencies = NULL, }; VK_ASSERT( vkCreateRenderPass( device->logical_device, &render_pass_create_info, device->vulkan_allocator, p ) ); } static inline void vk_create_framebuffer( const struct VulkanDevice* device, const struct RenderPassBeginInfo* info, VkRenderPass render_pass, VkFramebuffer* p ) { u32 attachment_count = info->color_attachment_count; VkImageView image_views[ MAX_ATTACHMENTS_COUNT + 2 ]; for ( u32 i = 0; i < attachment_count; ++i ) { FT_FROM_HANDLE( image, info->color_attachments[ i ].image, VulkanImage ); image_views[ i ] = image->image_view; } if ( info->depth_attachment.image != NULL ) { FT_FROM_HANDLE( image, info->depth_attachment.image, VulkanImage ); image_views[ attachment_count++ ] = image->image_view; } VkFramebufferCreateInfo framebuffer_create_info = { .sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, .pNext = NULL, .flags = 0, .renderPass = render_pass, .attachmentCount = attachment_count, .pAttachments = image_views, .width = info->width, .height = info->height, .layers = 1, }; VK_ASSERT( vkCreateFramebuffer( device->logical_device, &framebuffer_create_info, device->vulkan_allocator, p ) ); } void vk_pass_hasher_init( const struct VulkanDevice* device ) { hasher.device = device; hasher.render_passes = hashmap_new( sizeof( struct RenderPassMapItem ), 0, 0, 0, hash_pass_info, compare_pass_info, NULL, NULL ); hasher.framebuffers = hashmap_new( sizeof( struct FramebufferMapItem ), 0, 0, 0, hash_framebuffer_info, compare_framebuffer_info, NULL, NULL ); } void vk_pass_hasher_shutdown() { size_t iter = 0; void* item; while ( hashmap_iter( hasher.framebuffers, &iter, &item ) ) { struct FramebufferMapItem* it = item; vkDestroyFramebuffer( hasher.device->logical_device, it->framebuffer, hasher.device->vulkan_allocator ); } hashmap_free( hasher.framebuffers ); iter = 0; while ( hashmap_iter( hasher.render_passes, &iter, &item ) ) { struct RenderPassMapItem* it = item; vkDestroyRenderPass( hasher.device->logical_device, it->render_pass, hasher.device->vulkan_allocator ); } hashmap_free( hasher.render_passes ); } void vk_pass_hasher_framebuffers_clear() { size_t iter = 0; void* item; while ( hashmap_iter( hasher.framebuffers, &iter, &item ) ) { struct FramebufferMapItem* info = item; vkDestroyFramebuffer( hasher.device->logical_device, info->framebuffer, hasher.device->vulkan_allocator ); } hashmap_clear( hasher.framebuffers, 0 ); } VkRenderPass vk_pass_hasher_get_render_pass( const struct RenderPassBeginInfo* info ) { struct RenderPassMapItem* it = hashmap_get( hasher.render_passes, &( struct RenderPassMapItem ) { .info = *info, } ); if ( it != NULL ) { return it->render_pass; } else { VkRenderPass render_pass; vk_create_render_pass( hasher.device, info, &render_pass ); hashmap_set( hasher.render_passes, &( struct RenderPassMapItem ) { .info = *info, .render_pass = render_pass, } ); return render_pass; } } VkFramebuffer vk_pass_hasher_get_framebuffer( VkRenderPass render_pass, const struct RenderPassBeginInfo* info ) { struct FramebufferMapItem* it = hashmap_get( hasher.framebuffers, &( struct FramebufferMapItem ) { .info = *info, } ); if ( it != NULL ) { return it->framebuffer; } else { VkFramebuffer framebuffer; vk_create_framebuffer( hasher.device, info, render_pass, &framebuffer ); hashmap_set( hasher.framebuffers, &( struct FramebufferMapItem ) { .info = *info, .framebuffer = framebuffer, } ); return framebuffer; } } #endif
the_stack_data/77950.c
/* Exercise 1 - Calculations Write a C program to input marks of two subjects. Calculate and print the average of the two marks. */ #include <stdio.h> int main() { int mark1,mark2; float average; printf("enter mark1 : \n"); scanf("%d",&mark1); printf("enter mark2 : \n"); scanf("%d",&mark2); average=(mark1+mark2)/2; printf("average = %.2f\n",average); return 0; }
the_stack_data/40763714.c
char foo_data __attribute__(( section("FOO") )) = { 0 }; void * __start_FOO; void * foo() { return __start_FOO; }
the_stack_data/1220755.c
#define _POSIX_C_SOURCE 200809L #include <unistd.h> #include <errno.h> #include <stdbool.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <time.h> #define UNUSED(x) ((void)(x)) #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) #define SWAP(x, y, t) \ do \ { \ t __temp_var = (x); \ (x) = (y); \ (y) = __temp_var; \ } while(0) #define STRIP_NEWLINE(s) \ do \ { \ char* ptr; \ if((ptr = strchr(s, '\n'))) \ *ptr = '\0'; \ } while(0) static struct { const char* argv0; const char* input; FILE* input_fh; unsigned int head; bool args : 1; bool zero : 1; } opt; static struct { const char** array; size_t len; size_t cap; } lines; static void resize_lines(size_t new_cap) { void* ptr; ptr = realloc(lines.array, new_cap * sizeof(const char*)); if(!ptr) { fprintf(stderr, "%s: %s\n", opt.argv0, strerror(errno)); exit(1); } lines.array = ptr; lines.cap = new_cap; } static void append_line(const char* line) { if(lines.len >= lines.cap) resize_lines(lines.cap * 2 + 1); lines.array[lines.len++] = line; } static void shuffle_lines(void) { size_t i, j; for(i = lines.len - 1; i >= 1; i--) { j = rand() % (i + 1); if(i != j) SWAP(lines.array[i], lines.array[j], const char*); } } static int print_null(const char* str) { return fwrite(str, strlen(str) + 1, 1, stdout) != 1; } static int print_newline(const char* str) { return puts(str) == EOF; } static void print_lines(void) { int (*print_func)(const char*); size_t i; print_func = (opt.zero) ? &print_null : &print_newline; for(i = 0; i < lines.len; i++) { if(print_func(lines.array[i])) { fprintf(stderr, "%s: unable to write\n", opt.argv0); exit(1); } } } static void read_lines(void) { char* line; size_t len; unsigned int i; for(i = 0; !opt.head || i < opt.head; i++) { line = NULL; len = 0; if(getline(&line, &len, opt.input_fh) < 0) { free(line); if(errno) { fprintf(stderr, "%s: %s: %s\n", opt.argv0, opt.input, strerror(errno)); exit(1); } break; } STRIP_NEWLINE(line); append_line(line); } } static int parse_uint(unsigned int* res, const char* str) { long val; char* ptr; val = strtol(str, &ptr, 10); if(!*str || *ptr || errno || val <= 0) return -1; *res = val; return 0; } /* Usage: shuf [-z] [FILE] */ /* Usage: shuf -e [-z] [ARG]... */ int main(int argc, char* argv[]) { int ch, i; opt.argv0 = argv[0]; resize_lines(32); srand(time(NULL)); /* Parse arguments */ while((ch = getopt(argc, argv, "ezn:")) != -1) { switch(ch) { case 'e': opt.args = 1; break; case 'z': opt.zero = 1; break; case 'n': if(parse_uint(&opt.head, optarg)) { fprintf(stderr, "%s: not a positive number: %s\n", argv[0], optarg); return 1; } case '?': return 1; default: abort(); } } /* Read lines */ if(opt.args) { for(i = optind; i < argc; i++) append_line(argv[i]); } else { switch(argc - optind) { case 0: opt.input = "<stdin>"; opt.input_fh = stdin; break; case 1: opt.input = argv[optind]; opt.input_fh = fopen(opt.input, "r"); if(!opt.input) { fprintf(stderr, "%s: %s: %s\n", argv[0], opt.input, strerror(errno)); return 1; } break; default: fprintf(stderr, "%s: at most one file may be listed\n", argv[0]); return 1; } read_lines(); } /* Shuffle and print */ shuffle_lines(); print_lines(); return 0; }
the_stack_data/212643179.c
/** ****************************************************************************** * @file ca_rng_mbed.c * @author MCD Application Team * @brief This file contains the RNG router implementation of * the Cryptographic API (CA) module to the MBED Cryptographic library. ****************************************************************************** * @attention * * Copyright (c) 2020 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file in * the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* CA sources are built by building ca_core.c giving it the proper ca_config.h */ /* This file can not be build alone */ #if defined(CA_CORE_C) /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef CA_RNG_MBED_C #define CA_RNG_MBED_C /* Includes ------------------------------------------------------------------*/ #include "ca_rng_mbed.h" /* Private defines -----------------------------------------------------------*/ /* Private typedef -----------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Functions Definition ------------------------------------------------------*/ #if defined(CA_ROUTE_RNG) && ((CA_ROUTE_RNG & CA_ROUTE_MASK) == CA_ROUTE_MBED) int32_t CA_RNGinit(const CA_RNGinitInput_stt *P_pInputData, CA_RNGstate_stt *P_pRandomState) { (void)P_pInputData; (void)P_pRandomState; return CA_RNG_SUCCESS; } int32_t CA_RNGfree(CA_RNGstate_stt *P_pRandomState) { (void)P_pRandomState; return CA_RNG_SUCCESS; } #endif /* (CA_ROUTE_RNG & CA_ROUTE_MASK) == CA_ROUTE_MBED */ #endif /* CA_RNG_MBED_C */ #endif /* CA_CORE_C */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
the_stack_data/550007.c
/* PR sanitizer/63316 */ /* { dg-do run } */ /* { dg-skip-if "" { *-*-* } { "*" } { "-O2" } } */ #ifdef __cplusplus extern "C" { #endif extern void *malloc (__SIZE_TYPE__); extern void free (void *); #ifdef __cplusplus } #endif int main () { int *p = (int *) malloc (sizeof (int)); *p = 3; asm volatile ("" : : "r" (p) : "memory"); free (p); return 0; }
the_stack_data/68888441.c
// Copyright (c) 2015 RV-Match Team. All Rights Reserved. int a = 1;
the_stack_data/198579806.c
//Implementing Sparse matrices in C #include <stdio.h> #include <stdlib.h> struct Element { int row; int col; int val; //data type of the matrix }; struct Sparse { int numRows; int numCols; int numNon0s; struct Element* arr; //pointer to heap }; void reader(int* n, char s[]) { int inp; while(1) { printf("Enter the number of %s: ", s); scanf("%d", &inp); if(inp > 0) break; printf("Invalid input, try again\n"); } *n = inp; } void allocator(struct Sparse* sp, int mag) { if(mag == 0) sp->arr = (struct Element*)malloc((sp->numRows*sp->numCols)*sizeof(struct Element)); //worst-case - no zeroes else if(mag == -1) sp->arr = (struct Element*)realloc(sp->arr, sp->numNon0s*sizeof(struct Element)); //preventing wastage else if(mag > 0) sp->arr = (struct Element*)malloc(mag*sizeof(struct Element)); } void create(struct Sparse* sp) { reader(&sp->numRows, "rows"); reader(&sp->numCols, "columns"); //illusion of 2D array printf("Enter the matrix elements:\n"); int temp, i, j; sp->numNon0s = 0; allocator(sp, 0); for(i = 0; i < sp->numRows; i++) { for(j = 0; j < sp->numCols; j++) { scanf("%d", &temp); if(temp != 0) { sp->arr[sp->numNon0s].col = j; sp->arr[sp->numNon0s].row = i; sp->arr[sp->numNon0s].val = temp; sp->numNon0s++; } } } allocator(sp, -1); } void display(struct Sparse sp) { int i, j, tracker = 0; printf("The matrix is:\n"); for(i = 0; i < sp.numRows; i++) { for(j = 0; j < sp.numCols; j++) { if(i == sp.arr[tracker].row && j == sp.arr[tracker].col) printf("%d ", sp.arr[tracker++].val); else printf("%d ", 0); } printf("\n"); } } void deallocate(struct Sparse* sp) { free(sp->arr); sp->numRows = sp->numCols = sp->numNon0s = 0; } struct Sparse* add(struct Sparse a, struct Sparse b) { if(a.numRows == b.numRows && a.numCols == b.numCols) { struct Sparse* c = (struct Sparse*)malloc(sizeof(struct Sparse)); c->numRows = a.numRows; c->numCols = a.numCols; allocator(c, a.numNon0s+b.numNon0s); c->numNon0s = 0; int i = 0, j = 0; while(i < a.numNon0s && j < b.numNon0s) { if(a.arr[i].row < b.arr[j].row) c->arr[c->numNon0s++] = a.arr[i++]; //sets c->arr[ind]'s row, col and val equal to the RHS's else if(a.arr[i].row > b.arr[j].row) c->arr[c->numNon0s++] = b.arr[j++]; else //both non-zero elements have the same row { if(a.arr[i].col < b.arr[j].col) c->arr[c->numNon0s++] = a.arr[i++]; else if(a.arr[i].col > b.arr[j].col) c->arr[c->numNon0s++] = b.arr[j++]; else //both row and column of the non-zero elements are same { c->arr[c->numNon0s] = a.arr[i++]; c->arr[c->numNon0s++].val += b.arr[j++].val; } } } //for remaining elements for(; i < a.numNon0s; i++) c->arr[c->numNon0s++] = a.arr[i]; for(; j < b.numNon0s; j++) c->arr[c->numNon0s++] = b.arr[j]; allocator(c, -1); //returning the answer return c; } else { printf("The two sparse matrices are not compatible for addition\n"); return NULL; } } int main() { struct Sparse S1, S2, *S3; printf("--------Matrix 1--------\n"); create(&S1); printf("--------Matrix 2--------\n"); create(&S2); printf("--------Matrix 1--------\n"); display(S1); printf("--------Matrix 2--------\n"); display(S2); printf("--------Adduct--------\n"); S3 = add(S1, S2); if(S3 != NULL) display(*S3); deallocate(&S1); deallocate(&S2); if(S3 != NULL) { deallocate(S3); free(S3); } printf("Program terminated\n"); return 0; }
the_stack_data/673531.c
int MAIN_FUNCTION_op_lshift() { return 20 << 3; }
the_stack_data/161080507.c
// Copyright IBM Inc. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 #ifdef AVX512_IFMA_SUPPORT # include "ntt_avx512_ifma.h" static inline void collect_roots_fwd1(mul_op_m512_t w1[5], const uint64_t w[], const uint64_t w_con[], size_t * idx) { w1[0].op = LOAD(&w[*idx]); w1[1].op = LOAD(&w[*idx + 8]); w1[2].op = LOAD(&w[*idx + 16]); w1[3].op = LOAD(&w[*idx + 24]); w1[4].op = LOAD(&w[*idx + 32]); w1[0].con = LOAD(&w_con[*idx]); w1[1].con = LOAD(&w_con[*idx + 8]); w1[2].con = LOAD(&w_con[*idx + 16]); w1[3].con = LOAD(&w_con[*idx + 24]); w1[4].con = LOAD(&w_con[*idx + 32]); *idx += 5 * 8; } static inline void collect_roots_fwd4(mul_op_m512_t w1[5], const uint64_t w[], const uint64_t w_con[], size_t * idx) { w1[0].op = BROADCAST2HALVES(w[*idx + 0], w[*idx + 1]); w1[1].op = BROADCAST2HALVES(w[*idx + 2], w[*idx + 3]); w1[2].op = BROADCAST2HALVES(w[*idx + 4], w[*idx + 5]); w1[3].op = BROADCAST2HALVES(w[*idx + 6], w[*idx + 7]); w1[4].op = BROADCAST2HALVES(w[*idx + 8], w[*idx + 9]); w1[0].con = BROADCAST2HALVES(w_con[*idx + 0], w_con[*idx + 1]); w1[1].con = BROADCAST2HALVES(w_con[*idx + 2], w_con[*idx + 3]); w1[2].con = BROADCAST2HALVES(w_con[*idx + 4], w_con[*idx + 5]); w1[3].con = BROADCAST2HALVES(w_con[*idx + 6], w_con[*idx + 7]); w1[4].con = BROADCAST2HALVES(w_con[*idx + 8], w_con[*idx + 9]); *idx += 10; } static inline void collect_roots_fwd8(mul_op_m512_t w1[5], const uint64_t w[], const uint64_t w_con[], size_t * idx) { w1[0].op = SET1(w[*idx]); w1[1].op = SET1(w[*idx + 1]); w1[2].op = SET1(w[*idx + 2]); w1[3].op = SET1(w[*idx + 3]); w1[4].op = SET1(w[*idx + 4]); w1[0].con = SET1(w_con[*idx]); w1[1].con = SET1(w_con[*idx + 1]); w1[2].con = SET1(w_con[*idx + 2]); w1[3].con = SET1(w_con[*idx + 3]); w1[4].con = SET1(w_con[*idx + 4]); *idx += 5; } static inline void fwd1(uint64_t *a, const mul_op_m512_t w[5], const uint64_t q_64) { const __m512i idx = _mm512_setr_epi64(0, 4, 8, 12, 16, 20, 24, 28); __m512i X = GATHER(idx, &a[0 + 0], 8); __m512i Y = GATHER(idx, &a[0 + 1], 8); __m512i Z = GATHER(idx, &a[0 + 2], 8); __m512i T = GATHER(idx, &a[0 + 3], 8); fwd_radix4_butterfly_m512(&X, &Y, &Z, &T, w, q_64); SCATTER(&a[0 + 0], idx, X, 8); SCATTER(&a[0 + 1], idx, Y, 8); SCATTER(&a[0 + 2], idx, Z, 8); SCATTER(&a[0 + 3], idx, T, 8); } static inline void fwd4(uint64_t *a, const mul_op_m512_t w[5], const uint64_t q_64) { __m512i X1 = LOAD(&a[0]); __m512i Y1 = LOAD(&a[8]); __m512i Z1 = LOAD(&a[16]); __m512i T1 = LOAD(&a[24]); __m512i X = SHUF(X1, Z1, 0x44); __m512i Y = SHUF(X1, Z1, 0xee); __m512i Z = SHUF(Y1, T1, 0x44); __m512i T = SHUF(Y1, T1, 0xee); fwd_radix4_butterfly_m512(&X, &Y, &Z, &T, w, q_64); X1 = SHUF(X, Y, 0x44); Z1 = SHUF(X, Y, 0xee); Y1 = SHUF(Z, T, 0x44); T1 = SHUF(Z, T, 0xee); STORE(&a[0], X1); STORE(&a[8], Y1); STORE(&a[16], Z1); STORE(&a[24], T1); } static inline void fwd8(uint64_t * X_64, uint64_t * Y_64, uint64_t * Z_64, uint64_t * T_64, const mul_op_m512_t w[5], const uint64_t q_64) { __m512i X = LOAD(X_64); __m512i Y = LOAD(Y_64); __m512i Z = LOAD(Z_64); __m512i T = LOAD(T_64); fwd_radix4_butterfly_m512(&X, &Y, &Z, &T, w, q_64); STORE(X_64, X); STORE(Y_64, Y); STORE(Z_64, Z); STORE(T_64, T); } void fwd_ntt_radix4_avx512_ifma_lazy(uint64_t a[], const uint64_t N, const uint64_t q, const uint64_t w[], const uint64_t w_con[]) { mul_op_m512_t roots[5]; size_t bound_r4 = N; size_t t = N >> 1; size_t m = 1; size_t idx = 1; // Check whether N=2^m where m is odd. // If not perform extra radix-2 iteration. if(!HAS_AN_EVEN_POWER(N)) { const mul_op_m512_t w1 = {SET1(w[1]), SET1(w_con[1])}; for(size_t j = 0; j < t; j += 8) { __m512i X = LOAD(&a[j]); __m512i Y = LOAD(&a[j + t]); fwd_radix2_butterfly_m512(&X, &Y, &w1, q); STORE(&a[j], X); STORE(&a[j + t], Y); } bound_r4 >>= 1; t >>= 1; m <<= 1; idx++; } // Adjust to radix-4 t >>= 1; for(; m < bound_r4; m <<= 2) { if(t >= 8) { for(size_t j = 0; j < m; j++) { const uint64_t k = 4 * t * j; collect_roots_fwd8(roots, w, w_con, &idx); for(size_t i = k; i < k + t; i += 8) { fwd8(&a[i], &a[i + t], &a[i + 2 * t], &a[i + 3 * t], roots, q); } } } else if(t == 4) { for(size_t j = 0; j < m; j += 2) { collect_roots_fwd4(roots, w, w_con, &idx); fwd4(&a[4 * 4 * j], roots, q); } } else { LOOP_UNROLL_4 for(size_t j = 0; j < m; j += 8) { collect_roots_fwd1(roots, w, w_con, &idx); fwd1(&a[4 * j], roots, q); } } t >>= 2; } } #endif
the_stack_data/220455764.c
#include <stdio.h> // Gives us printf #include <stdbool.h> // Gives us the bool type #include <stdlib.h> // Gives us dynamic memory functions #include <math.h> // Gives us math functions like sqrt static int* primeList; // Pointer variable accessible to anything in this file // Factor test by trial division using the 6k +- 1 optimisation, this // means that factors of factors will not be displayed, i.e. if the test // number is a factor of 2, it will not show 4, 6, 8 etc. // static bool findFactors(const int testNum, bool verbose) { int const testLimit = (int) floor(sqrt((double) testNum)); // Local constant variable bool isPrime = true; if (testNum <= 3) { isPrime = (testNum > 1); if (verbose) printf("Special case %d", testNum); // %d means print an integer } else { for (int i = 2; i <= 3; i++) // Test for divisibility by 2 and 3 { if ((testNum % i) == 0) { isPrime = false; if (verbose) printf("divides by %d", i); } } } for (int divisor = 5; divisor <= testLimit; divisor += 6) // Loop from divisor = 5 to testLimit (inclusive), increment by 6 { if ((testNum % divisor) == 0) // Test if it divides by the divisor (i.e. 6k - 1) { if (verbose) printf("divides by %d", divisor); isPrime = false; } if ((testNum % (divisor + 2)) == 0) // Test if it divides by the divisor + 2 (i.e. 6k + 1) { if (verbose) printf("divides by %d", divisor + 2); isPrime = false; } } return isPrime; } // Helper function for calculating all prime numbers up to maxNumber // static int primeListTest(const int maxNumber) { int numPrimes = 0; primeList = calloc(maxNumber, sizeof(int)); // Dynamic memory allocation & initialize to 0 #pragma omp parallel for schedule(guided) // Uses OpenMP to create multiple threads to run this loop in parallel for (int i = 1; i <= maxNumber; i++) // Loop from i = 1 to maxNumber (inclusive), increment by 1 { if (findFactors(i, false) == true) // Is this number (i) prime? { primeList[i - 1] = i; // Arrays start at 0 in C } } for (int i = 0; i < maxNumber; i++) // This loop essentially removes the blanks and bunches all the primes up next to eachother in primeList { if (primeList[i] != 0) { primeList[numPrimes] = primeList[i]; numPrimes++; // Count up the number of primes we found } } return numPrimes; } // main is the default name for the starting point of a program in C // int main(int argc, char *argv[]) { int maxNumber, numPrimes; // local variables only visible to this function maxNumber = atoi(argv[1]); // atoi = Ascii TO Integer, argv[0] will be the name of the executable, the first argument is argv[1] numPrimes = primeListTest(maxNumber); // Calculates all prime numbers up to maxNumber printf("Generated %d primes, Largest was: %d \n", numPrimes, primeList[numPrimes - 1]); free(primeList); }
the_stack_data/95145.c
#include "stdlib.h" #include "malloc.h" #include "stdio.h" int rand(); //@ requires true; //@ ensures true; int fac(int x) //@ requires true; //@ ensures true; { int result = 1; while (x > 1) //@ invariant true; { result = result * x; x = x - 1; } return result; } struct tree { struct tree *left; struct tree *right; int value; }; /*@ predicate tree(struct tree *t, int depth) = t == 0 ? depth == 0 : t->left |-> ?left &*& t->right |-> ?right &*& t->value |-> _ &*& malloc_block_tree(t) &*& tree(left, depth - 1) &*& tree(right, depth - 1); @*/ struct tree *make_tree(int depth) //@ requires true; //@ ensures tree(result, depth); { if (depth == 0) { //@ close tree(0, 0); return 0; } else { struct tree *left = make_tree(depth - 1); struct tree *right = make_tree(depth - 1); int value = rand(); struct tree *t = malloc(sizeof(struct tree)); if (t == 0) abort(); t->left = left; t->right = right; t->value = value % 2000; //@ close tree(t, depth); return t; } } int tree_compute_sum_facs(struct tree *tree) //@ requires tree(tree, ?depth); //@ ensures tree(tree, depth); { if (tree == 0) { return 1; } else { //@ open tree(tree, depth); int leftSum = tree_compute_sum_facs(tree->left); int rightSum = tree_compute_sum_facs(tree->right); int f = fac(tree->value); return leftSum + rightSum + f; //@ close tree(tree, depth); } } int main() //@ requires true; //@ ensures true; { struct tree *tree = make_tree(22); int sum = tree_compute_sum_facs(tree); //@ leak tree(tree, _); printf("%i", sum); return 0; }
the_stack_data/132953807.c
/***************************** * @Createdby likelove * @contact [email protected] * @date 2021/3/2 * @desc ${desc} ******************************/ #include <stdio.h> #include <stdbool.h> int main() { int arr[] = {1, 2, 3, 4, 5, 6, 7, 8}; size_t len = sizeof(arr) / sizeof arr[0]; int find = 1; // scanf("%d", &find); int l = 0, r = len; int mid; while (l <= r) { mid = (l + r) >> 1; if (find > arr[mid]) { l = mid + 1; } else if (find < arr[mid]) { r = mid; } else break; } printf("%d", mid); }
the_stack_data/1062854.c
/* Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ /* AIX requires this to be the first thing in the file. */ #if defined _AIX && !defined __GNUC__ #pragma alloca #endif #ifdef HAVE_CONFIG_H # include <config.h> #endif /* Enable GNU extensions in glob.h. */ #ifndef _GNU_SOURCE # define _GNU_SOURCE 1 #endif #include <errno.h> #include <sys/types.h> #include <sys/stat.h> /* Outcomment the following line for production quality code. */ /* #define NDEBUG 1 */ #include <assert.h> #include <stdio.h> /* Needed on stupid SunOS for assert. */ /* Comment out all this code if we are using the GNU C Library, and are not actually compiling the library itself. This code is part of the GNU C Library, but also included in many other GNU distributions. Compiling and linking in this code is a waste when using the GNU C library (especially if it is a shared library). Rather than having every GNU program understand `configure --with-gnu-libc' and omit the object files, it is simpler to just do this in the source for each such file. */ #define GLOB_INTERFACE_VERSION 1 #if !defined _LIBC && defined __GNU_LIBRARY__ && __GNU_LIBRARY__ > 1 # include <gnu-versions.h> # if _GNU_GLOB_INTERFACE_VERSION == GLOB_INTERFACE_VERSION # define ELIDE_CODE # endif #endif #ifndef ELIDE_CODE #if defined STDC_HEADERS || defined __GNU_LIBRARY__ # include <stddef.h> #endif #if defined HAVE_UNISTD_H || defined _LIBC # include <unistd.h> # ifndef POSIX # ifdef _POSIX_VERSION # define POSIX # endif # endif #endif #if !defined _AMIGA && !defined VMS && !defined WINDOWS32 # include <pwd.h> #endif #if !defined __GNU_LIBRARY__ && !defined STDC_HEADERS extern int errno; #endif #ifndef __set_errno # define __set_errno(val) errno = (val) #endif #ifndef NULL # define NULL 0 #endif #if defined HAVE_DIRENT_H || defined __GNU_LIBRARY__ # include <dirent.h> # define NAMLEN(dirent) strlen((dirent)->d_name) #else # define dirent direct # define NAMLEN(dirent) (dirent)->d_namlen # ifdef HAVE_SYS_NDIR_H # include <sys/ndir.h> # endif # ifdef HAVE_SYS_DIR_H # include <sys/dir.h> # endif # ifdef HAVE_NDIR_H # include <ndir.h> # endif # ifdef HAVE_VMSDIR_H # include "vmsdir.h" # endif /* HAVE_VMSDIR_H */ #endif /* In GNU systems, <dirent.h> defines this macro for us. */ #ifdef _D_NAMLEN # undef NAMLEN # define NAMLEN(d) _D_NAMLEN(d) #endif /* When used in the GNU libc the symbol _DIRENT_HAVE_D_TYPE is available if the `d_type' member for `struct dirent' is available. */ #ifdef _DIRENT_HAVE_D_TYPE # define HAVE_D_TYPE 1 #endif #if (defined POSIX || defined WINDOWS32) && !defined __GNU_LIBRARY__ /* Posix does not require that the d_ino field be present, and some systems do not provide it. */ # define REAL_DIR_ENTRY(dp) 1 #else # define REAL_DIR_ENTRY(dp) (dp->d_ino != 0) #endif /* POSIX */ #if defined STDC_HEADERS || defined __GNU_LIBRARY__ # include <stdlib.h> # include <string.h> # define ANSI_STRING #else /* No standard headers. */ extern char *getenv (); # ifdef HAVE_STRING_H # include <string.h> # define ANSI_STRING # else # include <strings.h> # endif # ifdef HAVE_MEMORY_H # include <memory.h> # endif extern char *malloc (), *realloc (); extern void free (); extern void qsort (); extern void abort (), exit (); #endif /* Standard headers. */ #ifndef ANSI_STRING # ifndef bzero extern void bzero (); # endif # ifndef bcopy extern void bcopy (); # endif # define memcpy(d, s, n) bcopy ((s), (d), (n)) # define strrchr rindex /* memset is only used for zero here, but let's be paranoid. */ # define memset(s, better_be_zero, n) \ ((void) ((better_be_zero) == 0 ? (bzero((s), (n)), 0) : (abort(), 0))) #endif /* Not ANSI_STRING. */ #if !defined HAVE_STRCOLL && !defined _LIBC # define strcoll strcmp #endif #if !defined HAVE_MEMPCPY && __GLIBC__ - 0 == 2 && __GLIBC_MINOR__ >= 1 # define HAVE_MEMPCPY 1 # undef mempcpy # define mempcpy(Dest, Src, Len) __mempcpy (Dest, Src, Len) #endif #if !defined __GNU_LIBRARY__ && !defined __DJGPP__ # ifdef __GNUC__ __inline # endif # ifndef __SASC # ifdef WINDOWS32 static void * my_realloc (void *p, unsigned int n) # else static char * my_realloc (p, n) char *p; unsigned int n; # endif { /* These casts are the for sake of the broken Ultrix compiler, which warns of illegal pointer combinations otherwise. */ if (p == NULL) return (char *) malloc (n); return (char *) realloc (p, n); } # define realloc my_realloc # endif /* __SASC */ #endif /* __GNU_LIBRARY__ || __DJGPP__ */ #if !defined __alloca && !defined __GNU_LIBRARY__ # ifdef __GNUC__ # undef alloca # define alloca(n) __builtin_alloca (n) # else /* Not GCC. */ # ifdef HAVE_ALLOCA_H # include <alloca.h> # else /* Not HAVE_ALLOCA_H. */ # ifndef _AIX # ifdef WINDOWS32 # include <malloc.h> # else extern char *alloca (); # endif /* WINDOWS32 */ # endif /* Not _AIX. */ # endif /* sparc or HAVE_ALLOCA_H. */ # endif /* GCC. */ # define __alloca alloca #endif #ifndef __GNU_LIBRARY__ # define __stat stat # ifdef STAT_MACROS_BROKEN # undef S_ISDIR # endif # ifndef S_ISDIR # define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) # endif #endif #ifdef _LIBC # undef strdup # define strdup(str) __strdup (str) # define sysconf(id) __sysconf (id) # define closedir(dir) __closedir (dir) # define opendir(name) __opendir (name) # define readdir(str) __readdir (str) # define getpwnam_r(name, bufp, buf, len, res) \ __getpwnam_r (name, bufp, buf, len, res) # ifndef __stat # define __stat(fname, buf) __xstat (_STAT_VER, fname, buf) # endif #endif #if !(defined STDC_HEADERS || defined __GNU_LIBRARY__) # undef size_t # define size_t unsigned int #endif /* Some system header files erroneously define these. We want our own definitions from <fnmatch.h> to take precedence. */ #ifndef __GNU_LIBRARY__ # undef FNM_PATHNAME # undef FNM_NOESCAPE # undef FNM_PERIOD #endif #include <fnmatch.h> /* Some system header files erroneously define these. We want our own definitions from <glob.h> to take precedence. */ #ifndef __GNU_LIBRARY__ # undef GLOB_ERR # undef GLOB_MARK # undef GLOB_NOSORT # undef GLOB_DOOFFS # undef GLOB_NOCHECK # undef GLOB_APPEND # undef GLOB_NOESCAPE # undef GLOB_PERIOD #endif #include <glob.h> #ifdef HAVE_GETLOGIN_R extern int getlogin_r __P ((char *, size_t)); #else extern char *getlogin __P ((void)); #endif static #if __GNUC__ - 0 >= 2 inline #endif const char *next_brace_sub __P ((const char *begin)); static int glob_in_dir __P ((const char *pattern, const char *directory, int flags, int (*errfunc) (const char *, int), glob_t *pglob)); static int prefix_array __P ((const char *prefix, char **array, size_t n)); static int collated_compare __P ((const __ptr_t, const __ptr_t)); #if !defined _LIBC || !defined NO_GLOB_PATTERN_P int __glob_pattern_p __P ((const char *pattern, int quote)); #endif /* Find the end of the sub-pattern in a brace expression. We define this as an inline function if the compiler permits. */ static #if __GNUC__ - 0 >= 2 inline #endif const char * next_brace_sub (begin) const char *begin; { unsigned int depth = 0; const char *cp = begin; while (1) { if (depth == 0) { if (*cp != ',' && *cp != '}' && *cp != '\0') { if (*cp == '{') ++depth; ++cp; continue; } } else { while (*cp != '\0' && (*cp != '}' || depth > 0)) { if (*cp == '}') --depth; ++cp; } if (*cp == '\0') /* An incorrectly terminated brace expression. */ return NULL; continue; } break; } return cp; } /* Do glob searching for PATTERN, placing results in PGLOB. The bits defined above may be set in FLAGS. If a directory cannot be opened or read and ERRFUNC is not nil, it is called with the pathname that caused the error, and the `errno' value from the failing call; if it returns non-zero `glob' returns GLOB_ABORTED; if it returns zero, the error is ignored. If memory cannot be allocated for PGLOB, GLOB_NOSPACE is returned. Otherwise, `glob' returns zero. */ int glob (pattern, flags, errfunc, pglob) const char *pattern; int flags; int (*errfunc) __P ((const char *, int)); glob_t *pglob; { const char *filename; const char *dirname; size_t dirlen; int status; int oldcount; if (pattern == NULL || pglob == NULL || (flags & ~__GLOB_FLAGS) != 0) { __set_errno (EINVAL); return -1; } /* POSIX requires all slashes to be matched. This means that with a trailing slash we must match only directories. */ if (pattern[0] && pattern[strlen (pattern) - 1] == '/') flags |= GLOB_ONLYDIR; if (flags & GLOB_BRACE) { const char *begin = strchr (pattern, '{'); if (begin != NULL) { /* Allocate working buffer large enough for our work. Note that we have at least an opening and closing brace. */ int firstc; char *alt_start; const char *p; const char *next; const char *rest; size_t rest_len; #ifdef __GNUC__ char onealt[strlen (pattern) - 1]; #else char *onealt = (char *) malloc (strlen (pattern) - 1); if (onealt == NULL) { if (!(flags & GLOB_APPEND)) globfree (pglob); return GLOB_NOSPACE; } #endif /* We know the prefix for all sub-patterns. */ #ifdef HAVE_MEMPCPY alt_start = mempcpy (onealt, pattern, begin - pattern); #else memcpy (onealt, pattern, begin - pattern); alt_start = &onealt[begin - pattern]; #endif /* Find the first sub-pattern and at the same time find the rest after the closing brace. */ next = next_brace_sub (begin + 1); if (next == NULL) { /* It is an illegal expression. */ #ifndef __GNUC__ free (onealt); #endif return glob (pattern, flags & ~GLOB_BRACE, errfunc, pglob); } /* Now find the end of the whole brace expression. */ rest = next; while (*rest != '}') { rest = next_brace_sub (rest + 1); if (rest == NULL) { /* It is an illegal expression. */ #ifndef __GNUC__ free (onealt); #endif return glob (pattern, flags & ~GLOB_BRACE, errfunc, pglob); } } /* Please note that we now can be sure the brace expression is well-formed. */ rest_len = strlen (++rest) + 1; /* We have a brace expression. BEGIN points to the opening {, NEXT points past the terminator of the first element, and END points past the final }. We will accumulate result names from recursive runs for each brace alternative in the buffer using GLOB_APPEND. */ if (!(flags & GLOB_APPEND)) { /* This call is to set a new vector, so clear out the vector so we can append to it. */ pglob->gl_pathc = 0; pglob->gl_pathv = NULL; } firstc = pglob->gl_pathc; p = begin + 1; while (1) { int result; /* Construct the new glob expression. */ #ifdef HAVE_MEMPCPY mempcpy (mempcpy (alt_start, p, next - p), rest, rest_len); #else memcpy (alt_start, p, next - p); memcpy (&alt_start[next - p], rest, rest_len); #endif result = glob (onealt, ((flags & ~(GLOB_NOCHECK|GLOB_NOMAGIC)) | GLOB_APPEND), errfunc, pglob); /* If we got an error, return it. */ if (result && result != GLOB_NOMATCH) { #ifndef __GNUC__ free (onealt); #endif if (!(flags & GLOB_APPEND)) globfree (pglob); return result; } if (*next == '}') /* We saw the last entry. */ break; p = next + 1; next = next_brace_sub (p); assert (next != NULL); } #ifndef __GNUC__ free (onealt); #endif if (pglob->gl_pathc != firstc) /* We found some entries. */ return 0; else if (!(flags & (GLOB_NOCHECK|GLOB_NOMAGIC))) return GLOB_NOMATCH; } } /* Find the filename. */ filename = strrchr (pattern, '/'); #if defined __MSDOS__ || defined WINDOWS32 /* The case of "d:pattern". Since `:' is not allowed in file names, we can safely assume that wherever it happens in pattern, it signals the filename part. This is so we could some day support patterns like "[a-z]:foo". */ if (filename == NULL) filename = strchr (pattern, ':'); #endif /* __MSDOS__ || WINDOWS32 */ if (filename == NULL) { /* This can mean two things: a simple name or "~name". The later case is nothing but a notation for a directory. */ if ((flags & (GLOB_TILDE|GLOB_TILDE_CHECK)) && pattern[0] == '~') { dirname = pattern; dirlen = strlen (pattern); /* Set FILENAME to NULL as a special flag. This is ugly but other solutions would require much more code. We test for this special case below. */ filename = NULL; } else { filename = pattern; #ifdef _AMIGA dirname = ""; #else dirname = "."; #endif dirlen = 0; } } else if (filename == pattern) { /* "/pattern". */ dirname = "/"; dirlen = 1; ++filename; } else { char *newp; dirlen = filename - pattern; #if defined __MSDOS__ || defined WINDOWS32 if (*filename == ':' || (filename > pattern + 1 && filename[-1] == ':')) { char *drive_spec; ++dirlen; drive_spec = (char *) __alloca (dirlen + 1); #ifdef HAVE_MEMPCPY *((char *) mempcpy (drive_spec, pattern, dirlen)) = '\0'; #else memcpy (drive_spec, pattern, dirlen); drive_spec[dirlen] = '\0'; #endif /* For now, disallow wildcards in the drive spec, to prevent infinite recursion in glob. */ if (__glob_pattern_p (drive_spec, !(flags & GLOB_NOESCAPE))) return GLOB_NOMATCH; /* If this is "d:pattern", we need to copy `:' to DIRNAME as well. If it's "d:/pattern", don't remove the slash from "d:/", since "d:" and "d:/" are not the same.*/ } #endif newp = (char *) __alloca (dirlen + 1); #ifdef HAVE_MEMPCPY *((char *) mempcpy (newp, pattern, dirlen)) = '\0'; #else memcpy (newp, pattern, dirlen); newp[dirlen] = '\0'; #endif dirname = newp; ++filename; if (filename[0] == '\0' #if defined __MSDOS__ || defined WINDOWS32 && dirname[dirlen - 1] != ':' && (dirlen < 3 || dirname[dirlen - 2] != ':' || dirname[dirlen - 1] != '/') #endif && dirlen > 1) /* "pattern/". Expand "pattern", appending slashes. */ { int val = glob (dirname, flags | GLOB_MARK, errfunc, pglob); if (val == 0) pglob->gl_flags = ((pglob->gl_flags & ~GLOB_MARK) | (flags & GLOB_MARK)); return val; } } if (!(flags & GLOB_APPEND)) { pglob->gl_pathc = 0; pglob->gl_pathv = NULL; } oldcount = pglob->gl_pathc; #ifndef VMS if ((flags & (GLOB_TILDE|GLOB_TILDE_CHECK)) && dirname[0] == '~') { if (dirname[1] == '\0' || dirname[1] == '/') { /* Look up home directory. */ #ifdef VMS /* This isn't obvious, RTLs of DECC and VAXC know about "HOME" */ const char *home_dir = getenv ("SYS$LOGIN"); #else const char *home_dir = getenv ("HOME"); #endif # ifdef _AMIGA if (home_dir == NULL || home_dir[0] == '\0') home_dir = "SYS:"; # else # ifdef WINDOWS32 if (home_dir == NULL || home_dir[0] == '\0') home_dir = "c:/users/default"; /* poor default */ # else # ifdef VMS /* Again, this isn't obvious, if "HOME" isn't known "SYS$LOGIN" should be set */ if (home_dir == NULL || home_dir[0] == '\0') home_dir = "SYS$DISK:[]"; # else if (home_dir == NULL || home_dir[0] == '\0') { int success; char *name; # if defined HAVE_GETLOGIN_R || defined _LIBC size_t buflen = sysconf (_SC_LOGIN_NAME_MAX) + 1; if (buflen == 0) /* `sysconf' does not support _SC_LOGIN_NAME_MAX. Try a moderate value. */ buflen = 20; name = (char *) __alloca (buflen); success = getlogin_r (name, buflen) >= 0; # else success = (name = getlogin ()) != NULL; # endif if (success) { struct passwd *p; # if defined HAVE_GETPWNAM_R || defined _LIBC size_t pwbuflen = sysconf (_SC_GETPW_R_SIZE_MAX); char *pwtmpbuf; struct passwd pwbuf; int save = errno; if (pwbuflen == -1) /* `sysconf' does not support _SC_GETPW_R_SIZE_MAX. Try a moderate value. */ pwbuflen = 1024; pwtmpbuf = (char *) __alloca (pwbuflen); while (getpwnam_r (name, &pwbuf, pwtmpbuf, pwbuflen, &p) != 0) { if (errno != ERANGE) { p = NULL; break; } pwbuflen *= 2; pwtmpbuf = (char *) __alloca (pwbuflen); __set_errno (save); } # else p = getpwnam (name); # endif if (p != NULL) home_dir = p->pw_dir; } } if (home_dir == NULL || home_dir[0] == '\0') { if (flags & GLOB_TILDE_CHECK) return GLOB_NOMATCH; else home_dir = "~"; /* No luck. */ } # endif /* VMS */ # endif /* WINDOWS32 */ # endif /* Now construct the full directory. */ if (dirname[1] == '\0') dirname = home_dir; else { char *newp; size_t home_len = strlen (home_dir); newp = (char *) __alloca (home_len + dirlen); # ifdef HAVE_MEMPCPY mempcpy (mempcpy (newp, home_dir, home_len), &dirname[1], dirlen); # else memcpy (newp, home_dir, home_len); memcpy (&newp[home_len], &dirname[1], dirlen); # endif dirname = newp; } } # if !defined _AMIGA && !defined WINDOWS32 && !defined VMS else { char *end_name = strchr (dirname, '/'); const char *user_name; const char *home_dir; if (end_name == NULL) user_name = dirname + 1; else { char *newp; newp = (char *) __alloca (end_name - dirname); # ifdef HAVE_MEMPCPY *((char *) mempcpy (newp, dirname + 1, end_name - dirname)) = '\0'; # else memcpy (newp, dirname + 1, end_name - dirname); newp[end_name - dirname - 1] = '\0'; # endif user_name = newp; } /* Look up specific user's home directory. */ { struct passwd *p; # if defined HAVE_GETPWNAM_R || defined _LIBC size_t buflen = sysconf (_SC_GETPW_R_SIZE_MAX); char *pwtmpbuf; struct passwd pwbuf; int save = errno; if (buflen == -1) /* `sysconf' does not support _SC_GETPW_R_SIZE_MAX. Try a moderate value. */ buflen = 1024; pwtmpbuf = (char *) __alloca (buflen); while (getpwnam_r (user_name, &pwbuf, pwtmpbuf, buflen, &p) != 0) { if (errno != ERANGE) { p = NULL; break; } buflen *= 2; pwtmpbuf = __alloca (buflen); __set_errno (save); } # else p = getpwnam (user_name); # endif if (p != NULL) home_dir = p->pw_dir; else home_dir = NULL; } /* If we found a home directory use this. */ if (home_dir != NULL) { char *newp; size_t home_len = strlen (home_dir); size_t rest_len = end_name == NULL ? 0 : strlen (end_name); newp = (char *) __alloca (home_len + rest_len + 1); # ifdef HAVE_MEMPCPY *((char *) mempcpy (mempcpy (newp, home_dir, home_len), end_name, rest_len)) = '\0'; # else memcpy (newp, home_dir, home_len); memcpy (&newp[home_len], end_name, rest_len); newp[home_len + rest_len] = '\0'; # endif dirname = newp; } else if (flags & GLOB_TILDE_CHECK) /* We have to regard it as an error if we cannot find the home directory. */ return GLOB_NOMATCH; } # endif /* Not Amiga && not WINDOWS32 && not VMS. */ } #endif /* Not VMS. */ /* Now test whether we looked for "~" or "~NAME". In this case we can give the answer now. */ if (filename == NULL) { struct stat st; /* Return the directory if we don't check for error or if it exists. */ if ((flags & GLOB_NOCHECK) || (((flags & GLOB_ALTDIRFUNC) ? (*pglob->gl_stat) (dirname, &st) : __stat (dirname, &st)) == 0 && S_ISDIR (st.st_mode))) { pglob->gl_pathv = (char **) realloc (pglob->gl_pathv, (pglob->gl_pathc + ((flags & GLOB_DOOFFS) ? pglob->gl_offs : 0) + 1 + 1) * sizeof (char *)); if (pglob->gl_pathv == NULL) return GLOB_NOSPACE; if (flags & GLOB_DOOFFS) while (pglob->gl_pathc < pglob->gl_offs) pglob->gl_pathv[pglob->gl_pathc++] = NULL; #if defined HAVE_STRDUP || defined _LIBC pglob->gl_pathv[pglob->gl_pathc] = strdup (dirname); #else { size_t len = strlen (dirname) + 1; char *dircopy = malloc (len); if (dircopy != NULL) pglob->gl_pathv[pglob->gl_pathc] = memcpy (dircopy, dirname, len); } #endif if (pglob->gl_pathv[pglob->gl_pathc] == NULL) { free (pglob->gl_pathv); return GLOB_NOSPACE; } pglob->gl_pathv[++pglob->gl_pathc] = NULL; pglob->gl_flags = flags; return 0; } /* Not found. */ return GLOB_NOMATCH; } if (__glob_pattern_p (dirname, !(flags & GLOB_NOESCAPE))) { /* The directory name contains metacharacters, so we have to glob for the directory, and then glob for the pattern in each directory found. */ glob_t dirs; register int i; status = glob (dirname, ((flags & (GLOB_ERR | GLOB_NOCHECK | GLOB_NOESCAPE)) | GLOB_NOSORT | GLOB_ONLYDIR), errfunc, &dirs); if (status != 0) return status; /* We have successfully globbed the preceding directory name. For each name we found, call glob_in_dir on it and FILENAME, appending the results to PGLOB. */ for (i = 0; i < dirs.gl_pathc; ++i) { int old_pathc; #ifdef SHELL { /* Make globbing interruptible in the bash shell. */ extern int interrupt_state; if (interrupt_state) { globfree (&dirs); globfree (&files); return GLOB_ABORTED; } } #endif /* SHELL. */ old_pathc = pglob->gl_pathc; status = glob_in_dir (filename, dirs.gl_pathv[i], ((flags | GLOB_APPEND) & ~(GLOB_NOCHECK | GLOB_ERR)), errfunc, pglob); if (status == GLOB_NOMATCH) /* No matches in this directory. Try the next. */ continue; if (status != 0) { globfree (&dirs); globfree (pglob); return status; } /* Stick the directory on the front of each name. */ if (prefix_array (dirs.gl_pathv[i], &pglob->gl_pathv[old_pathc], pglob->gl_pathc - old_pathc)) { globfree (&dirs); globfree (pglob); return GLOB_NOSPACE; } } flags |= GLOB_MAGCHAR; /* We have ignored the GLOB_NOCHECK flag in the `glob_in_dir' calls. But if we have not found any matching entry and thie GLOB_NOCHECK flag was set we must return the list consisting of the disrectory names followed by the filename. */ if (pglob->gl_pathc == oldcount) { /* No matches. */ if (flags & GLOB_NOCHECK) { size_t filename_len = strlen (filename) + 1; char **new_pathv; struct stat st; /* This is an pessimistic guess about the size. */ pglob->gl_pathv = (char **) realloc (pglob->gl_pathv, (pglob->gl_pathc + ((flags & GLOB_DOOFFS) ? pglob->gl_offs : 0) + dirs.gl_pathc + 1) * sizeof (char *)); if (pglob->gl_pathv == NULL) { globfree (&dirs); return GLOB_NOSPACE; } if (flags & GLOB_DOOFFS) while (pglob->gl_pathc < pglob->gl_offs) pglob->gl_pathv[pglob->gl_pathc++] = NULL; for (i = 0; i < dirs.gl_pathc; ++i) { const char *dir = dirs.gl_pathv[i]; size_t dir_len = strlen (dir); /* First check whether this really is a directory. */ if (((flags & GLOB_ALTDIRFUNC) ? (*pglob->gl_stat) (dir, &st) : __stat (dir, &st)) != 0 || !S_ISDIR (st.st_mode)) /* No directory, ignore this entry. */ continue; pglob->gl_pathv[pglob->gl_pathc] = malloc (dir_len + 1 + filename_len); if (pglob->gl_pathv[pglob->gl_pathc] == NULL) { globfree (&dirs); globfree (pglob); return GLOB_NOSPACE; } #ifdef HAVE_MEMPCPY mempcpy (mempcpy (mempcpy (pglob->gl_pathv[pglob->gl_pathc], dir, dir_len), "/", 1), filename, filename_len); #else memcpy (pglob->gl_pathv[pglob->gl_pathc], dir, dir_len); pglob->gl_pathv[pglob->gl_pathc][dir_len] = '/'; memcpy (&pglob->gl_pathv[pglob->gl_pathc][dir_len + 1], filename, filename_len); #endif ++pglob->gl_pathc; } pglob->gl_pathv[pglob->gl_pathc] = NULL; pglob->gl_flags = flags; /* Now we know how large the gl_pathv vector must be. */ new_pathv = (char **) realloc (pglob->gl_pathv, ((pglob->gl_pathc + 1) * sizeof (char *))); if (new_pathv != NULL) pglob->gl_pathv = new_pathv; } else return GLOB_NOMATCH; } globfree (&dirs); } else { status = glob_in_dir (filename, dirname, flags, errfunc, pglob); if (status != 0) return status; if (dirlen > 0) { /* Stick the directory on the front of each name. */ int ignore = oldcount; if ((flags & GLOB_DOOFFS) && ignore < pglob->gl_offs) ignore = pglob->gl_offs; if (prefix_array (dirname, &pglob->gl_pathv[ignore], pglob->gl_pathc - ignore)) { globfree (pglob); return GLOB_NOSPACE; } } } if (flags & GLOB_MARK) { /* Append slashes to directory names. */ int i; struct stat st; for (i = oldcount; i < pglob->gl_pathc; ++i) if (((flags & GLOB_ALTDIRFUNC) ? (*pglob->gl_stat) (pglob->gl_pathv[i], &st) : __stat (pglob->gl_pathv[i], &st)) == 0 && S_ISDIR (st.st_mode)) { size_t len = strlen (pglob->gl_pathv[i]) + 2; char *new = realloc (pglob->gl_pathv[i], len); if (new == NULL) { globfree (pglob); return GLOB_NOSPACE; } strcpy (&new[len - 2], "/"); pglob->gl_pathv[i] = new; } } if (!(flags & GLOB_NOSORT)) { /* Sort the vector. */ int non_sort = oldcount; if ((flags & GLOB_DOOFFS) && pglob->gl_offs > oldcount) non_sort = pglob->gl_offs; qsort ((__ptr_t) &pglob->gl_pathv[non_sort], pglob->gl_pathc - non_sort, sizeof (char *), collated_compare); } return 0; } /* Free storage allocated in PGLOB by a previous `glob' call. */ void globfree (pglob) register glob_t *pglob; { if (pglob->gl_pathv != NULL) { register int i; for (i = 0; i < pglob->gl_pathc; ++i) if (pglob->gl_pathv[i] != NULL) free ((__ptr_t) pglob->gl_pathv[i]); free ((__ptr_t) pglob->gl_pathv); } } /* Do a collated comparison of A and B. */ static int collated_compare (a, b) const __ptr_t a; const __ptr_t b; { const char *const s1 = *(const char *const * const) a; const char *const s2 = *(const char *const * const) b; if (s1 == s2) return 0; if (s1 == NULL) return 1; if (s2 == NULL) return -1; return strcoll (s1, s2); } /* Prepend DIRNAME to each of N members of ARRAY, replacing ARRAY's elements in place. Return nonzero if out of memory, zero if successful. A slash is inserted between DIRNAME and each elt of ARRAY, unless DIRNAME is just "/". Each old element of ARRAY is freed. */ static int prefix_array (dirname, array, n) const char *dirname; char **array; size_t n; { register size_t i; size_t dirlen = strlen (dirname); #if defined __MSDOS__ || defined WINDOWS32 int sep_char = '/'; # define DIRSEP_CHAR sep_char #else # define DIRSEP_CHAR '/' #endif if (dirlen == 1 && dirname[0] == '/') /* DIRNAME is just "/", so normal prepending would get us "//foo". We want "/foo" instead, so don't prepend any chars from DIRNAME. */ dirlen = 0; #if defined __MSDOS__ || defined WINDOWS32 else if (dirlen > 1) { if (dirname[dirlen - 1] == '/' && dirname[dirlen - 2] == ':') /* DIRNAME is "d:/". Don't prepend the slash from DIRNAME. */ --dirlen; else if (dirname[dirlen - 1] == ':') { /* DIRNAME is "d:". Use `:' instead of `/'. */ --dirlen; sep_char = ':'; } } #endif for (i = 0; i < n; ++i) { size_t eltlen = strlen (array[i]) + 1; char *new = (char *) malloc (dirlen + 1 + eltlen); if (new == NULL) { while (i > 0) free ((__ptr_t) array[--i]); return 1; } #ifdef HAVE_MEMPCPY { char *endp = (char *) mempcpy (new, dirname, dirlen); *endp++ = DIRSEP_CHAR; mempcpy (endp, array[i], eltlen); } #else memcpy (new, dirname, dirlen); new[dirlen] = DIRSEP_CHAR; memcpy (&new[dirlen + 1], array[i], eltlen); #endif free ((__ptr_t) array[i]); array[i] = new; } return 0; } /* We must not compile this function twice. */ #if !defined _LIBC || !defined NO_GLOB_PATTERN_P /* Return nonzero if PATTERN contains any metacharacters. Metacharacters can be quoted with backslashes if QUOTE is nonzero. */ int __glob_pattern_p (pattern, quote) const char *pattern; int quote; { register const char *p; int open = 0; for (p = pattern; *p != '\0'; ++p) switch (*p) { case '?': case '*': return 1; case '\\': if (quote && p[1] != '\0') ++p; break; case '[': open = 1; break; case ']': if (open) return 1; break; } return 0; } # ifdef _LIBC weak_alias (__glob_pattern_p, glob_pattern_p) # endif #endif /* Like `glob', but PATTERN is a final pathname component, and matches are searched for in DIRECTORY. The GLOB_NOSORT bit in FLAGS is ignored. No sorting is ever done. The GLOB_APPEND flag is assumed to be set (always appends). */ static int glob_in_dir (pattern, directory, flags, errfunc, pglob) const char *pattern; const char *directory; int flags; int (*errfunc) __P ((const char *, int)); glob_t *pglob; { __ptr_t stream = NULL; struct globlink { struct globlink *next; char *name; }; struct globlink *names = NULL; size_t nfound; int meta; int save; #ifdef VMS if (*directory == 0) directory = "[]"; #endif meta = __glob_pattern_p (pattern, !(flags & GLOB_NOESCAPE)); if (meta == 0) { if (flags & (GLOB_NOCHECK|GLOB_NOMAGIC)) /* We need not do any tests. The PATTERN contains no meta characters and we must not return an error therefore the result will always contain exactly one name. */ flags |= GLOB_NOCHECK; else { /* Since we use the normal file functions we can also use stat() to verify the file is there. */ struct stat st; size_t patlen = strlen (pattern); size_t dirlen = strlen (directory); char *fullname = (char *) __alloca (dirlen + 1 + patlen + 1); # ifdef HAVE_MEMPCPY mempcpy (mempcpy (mempcpy (fullname, directory, dirlen), "/", 1), pattern, patlen + 1); # else memcpy (fullname, directory, dirlen); fullname[dirlen] = '/'; memcpy (&fullname[dirlen + 1], pattern, patlen + 1); # endif if (((flags & GLOB_ALTDIRFUNC) ? (*pglob->gl_stat) (fullname, &st) : __stat (fullname, &st)) == 0) /* We found this file to be existing. Now tell the rest of the function to copy this name into the result. */ flags |= GLOB_NOCHECK; } nfound = 0; } else { if (pattern[0] == '\0') { /* This is a special case for matching directories like in "*a/". */ names = (struct globlink *) __alloca (sizeof (struct globlink)); names->name = (char *) malloc (1); if (names->name == NULL) goto memory_error; names->name[0] = '\0'; names->next = NULL; nfound = 1; meta = 0; } else { stream = ((flags & GLOB_ALTDIRFUNC) ? (*pglob->gl_opendir) (directory) : (__ptr_t) opendir (directory)); if (stream == NULL) { if (errno != ENOTDIR && ((errfunc != NULL && (*errfunc) (directory, errno)) || (flags & GLOB_ERR))) return GLOB_ABORTED; nfound = 0; meta = 0; } else { int fnm_flags = ((!(flags & GLOB_PERIOD) ? FNM_PERIOD : 0) | ((flags & GLOB_NOESCAPE) ? FNM_NOESCAPE : 0) #if defined HAVE_CASE_INSENSITIVE_FS | FNM_CASEFOLD #endif ); nfound = 0; flags |= GLOB_MAGCHAR; while (1) { const char *name; size_t len; struct dirent *d = ((flags & GLOB_ALTDIRFUNC) ? (*pglob->gl_readdir) (stream) : readdir ((DIR *) stream)); if (d == NULL) break; if (! REAL_DIR_ENTRY (d)) continue; #ifdef HAVE_D_TYPE /* If we shall match only directories use the information provided by the dirent call if possible. */ if ((flags & GLOB_ONLYDIR) && d->d_type != DT_UNKNOWN && d->d_type != DT_DIR) continue; #endif name = d->d_name; if (fnmatch (pattern, name, fnm_flags) == 0) { struct globlink *new = (struct globlink *) __alloca (sizeof (struct globlink)); len = NAMLEN (d); new->name = (char *) malloc (len + 1); if (new->name == NULL) goto memory_error; #ifdef HAVE_MEMPCPY *((char *) mempcpy ((__ptr_t) new->name, name, len)) = '\0'; #else memcpy ((__ptr_t) new->name, name, len); new->name[len] = '\0'; #endif new->next = names; names = new; ++nfound; } } } } } if (nfound == 0 && (flags & GLOB_NOCHECK)) { size_t len = strlen (pattern); nfound = 1; names = (struct globlink *) __alloca (sizeof (struct globlink)); names->next = NULL; names->name = (char *) malloc (len + 1); if (names->name == NULL) goto memory_error; #ifdef HAVE_MEMPCPY *((char *) mempcpy (names->name, pattern, len)) = '\0'; #else memcpy (names->name, pattern, len); names->name[len] = '\0'; #endif } if (nfound != 0) { pglob->gl_pathv = (char **) realloc (pglob->gl_pathv, (pglob->gl_pathc + ((flags & GLOB_DOOFFS) ? pglob->gl_offs : 0) + nfound + 1) * sizeof (char *)); if (pglob->gl_pathv == NULL) goto memory_error; if (flags & GLOB_DOOFFS) while (pglob->gl_pathc < pglob->gl_offs) pglob->gl_pathv[pglob->gl_pathc++] = NULL; for (; names != NULL; names = names->next) pglob->gl_pathv[pglob->gl_pathc++] = names->name; pglob->gl_pathv[pglob->gl_pathc] = NULL; pglob->gl_flags = flags; } save = errno; if (stream != NULL) { if (flags & GLOB_ALTDIRFUNC) (*pglob->gl_closedir) (stream); else closedir ((DIR *) stream); } __set_errno (save); return nfound == 0 ? GLOB_NOMATCH : 0; memory_error: { int save = errno; if (flags & GLOB_ALTDIRFUNC) (*pglob->gl_closedir) (stream); else closedir ((DIR *) stream); __set_errno (save); } while (names != NULL) { if (names->name != NULL) free ((__ptr_t) names->name); names = names->next; } return GLOB_NOSPACE; } #endif /* Not ELIDE_CODE. */
the_stack_data/64200964.c
/* $NetBSD: strrchr.c,v 1.6 2018/02/04 20:22:17 mrg Exp $ */ /* * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifdef _KERNEL #include <sys/libkern.h> #else #include <string.h> #endif char *strrchr(const char *p, int ch) { char *save; const char c = ch; for (save = NULL;; ++p) { if (*p == c) { /* LINTED const cast-away */ save = __UNCONST(p); } if (!*p) return (save); } /* NOTREACHED */ }
the_stack_data/114878.c
#include <stdio.h> main() { int a,i,b,c,n,sum; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d%d%d",&a,&b,&c); if(a>1 && b>=1 && c>=1) { sum=(b+c)%a; if(sum==0) { sum=a; } printf("Case %d: %d\n",i+1,sum); } } return 0; }
the_stack_data/693077.c
#include <stdio.h> #include <stdlib.h> #include <sys/wait.h> #include <unistd.h> void pr_exit(int); int main(void) { pid_t pid; int status; if ((pid = fork()) < 0) { puts("fork error"); exit(1); } else if (pid == 0) exit(7); if (wait(&status) != pid) { puts("wait error"); exit(1); } pr_exit(status); if ((pid = fork()) < 0) { puts("fork error"); exit(1); } else if (pid == 0) abort(); if (wait(&status) != pid) { puts("wait error"); exit(1); } pr_exit(status); if ((pid = fork()) < 0) { puts("fork error"); exit(1); } else if (pid == 0) status /= 0; if (wait(&status) != pid) { puts("wait error"); exit(1); } pr_exit(status); exit(0); } void pr_exit(int status) { if (WIFEXITED(status)) printf("normal termination, exit status = %d\n", WEXITSTATUS(status)); else if (WIFSIGNALED(status)) printf("abnormal termination, signal number = %d%s\n", WTERMSIG(status), #ifdef WCOREDUMP WCOREDUMP(status) ? " (core file generated)" : ""); #else ""); #endif else if (WIFSTOPPED(status)) printf("child stopped, signal number = %d\n", WSTOPSIG(status)); }
the_stack_data/52345.c
/* * Generated by util/mkerr.pl DO NOT EDIT * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html */ #include <openssl/err.h> #include <openssl/x509err.h> #ifndef OPENSSL_NO_ERR static const ERR_STRING_DATA X509_str_functs[] = { {ERR_PACK(ERR_LIB_X509, X509_F_ADD_CERT_DIR, 0), "add_cert_dir"}, {ERR_PACK(ERR_LIB_X509, X509_F_BUILD_CHAIN, 0), "build_chain"}, {ERR_PACK(ERR_LIB_X509, X509_F_BY_FILE_CTRL, 0), "by_file_ctrl"}, {ERR_PACK(ERR_LIB_X509, X509_F_CHECK_NAME_CONSTRAINTS, 0), "check_name_constraints"}, {ERR_PACK(ERR_LIB_X509, X509_F_CHECK_POLICY, 0), "check_policy"}, {ERR_PACK(ERR_LIB_X509, X509_F_COMMON_VERIFY_SM2, 0), "common_verify_sm2"}, {ERR_PACK(ERR_LIB_X509, X509_F_DANE_I2D, 0), "dane_i2d"}, {ERR_PACK(ERR_LIB_X509, X509_F_DIR_CTRL, 0), "dir_ctrl"}, {ERR_PACK(ERR_LIB_X509, X509_F_GET_CERT_BY_SUBJECT, 0), "get_cert_by_subject"}, {ERR_PACK(ERR_LIB_X509, X509_F_I2D_X509_AUX, 0), "i2d_X509_AUX"}, {ERR_PACK(ERR_LIB_X509, X509_F_LOOKUP_CERTS_SK, 0), "lookup_certs_sk"}, {ERR_PACK(ERR_LIB_X509, X509_F_NETSCAPE_SPKI_B64_DECODE, 0), "NETSCAPE_SPKI_b64_decode"}, {ERR_PACK(ERR_LIB_X509, X509_F_NETSCAPE_SPKI_B64_ENCODE, 0), "NETSCAPE_SPKI_b64_encode"}, {ERR_PACK(ERR_LIB_X509, X509_F_NEW_DIR, 0), "new_dir"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509AT_ADD1_ATTR, 0), "X509at_add1_attr"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509V3_ADD_EXT, 0), "X509v3_add_ext"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_ATTRIBUTE_CREATE_BY_NID, 0), "X509_ATTRIBUTE_create_by_NID"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_ATTRIBUTE_CREATE_BY_OBJ, 0), "X509_ATTRIBUTE_create_by_OBJ"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_ATTRIBUTE_CREATE_BY_TXT, 0), "X509_ATTRIBUTE_create_by_txt"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_ATTRIBUTE_GET0_DATA, 0), "X509_ATTRIBUTE_get0_data"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_ATTRIBUTE_SET1_DATA, 0), "X509_ATTRIBUTE_set1_data"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_CHECK_PRIVATE_KEY, 0), "X509_check_private_key"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_CRL_DIFF, 0), "X509_CRL_diff"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_CRL_METHOD_NEW, 0), "X509_CRL_METHOD_new"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_CRL_PRINT_FP, 0), "X509_CRL_print_fp"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_EXTENSION_CREATE_BY_NID, 0), "X509_EXTENSION_create_by_NID"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_EXTENSION_CREATE_BY_OBJ, 0), "X509_EXTENSION_create_by_OBJ"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_GET_PUBKEY_PARAMETERS, 0), "X509_get_pubkey_parameters"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_LOAD_CERT_CRL_FILE, 0), "X509_load_cert_crl_file"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_LOAD_CERT_FILE, 0), "X509_load_cert_file"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_LOAD_CRL_FILE, 0), "X509_load_crl_file"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_LOOKUP_METH_NEW, 0), "X509_LOOKUP_meth_new"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_LOOKUP_NEW, 0), "X509_LOOKUP_new"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_NAME_ADD_ENTRY, 0), "X509_NAME_add_entry"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_NAME_CANON, 0), "x509_name_canon"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_NAME_ENTRY_CREATE_BY_NID, 0), "X509_NAME_ENTRY_create_by_NID"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_NAME_ENTRY_CREATE_BY_TXT, 0), "X509_NAME_ENTRY_create_by_txt"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_NAME_ENTRY_SET_OBJECT, 0), "X509_NAME_ENTRY_set_object"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_NAME_ONELINE, 0), "X509_NAME_oneline"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_NAME_PRINT, 0), "X509_NAME_print"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_OBJECT_NEW, 0), "X509_OBJECT_new"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_PRINT_EX_FP, 0), "X509_print_ex_fp"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_PUBKEY_DECODE, 0), "x509_pubkey_decode"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_PUBKEY_GET0, 0), "X509_PUBKEY_get0"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_PUBKEY_SET, 0), "X509_PUBKEY_set"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_REQ_CHECK_PRIVATE_KEY, 0), "X509_REQ_check_private_key"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_REQ_PRINT_EX, 0), "X509_REQ_print_ex"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_REQ_PRINT_FP, 0), "X509_REQ_print_fp"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_REQ_TO_X509, 0), "X509_REQ_to_X509"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_REQ_VERIFY, 0), "X509_REQ_verify"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_REQ_VERIFY_SM2, 0), "x509_req_verify_sm2"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_STORE_ADD_CERT, 0), "X509_STORE_add_cert"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_STORE_ADD_CRL, 0), "X509_STORE_add_crl"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_STORE_ADD_LOOKUP, 0), "X509_STORE_add_lookup"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_STORE_CTX_GET1_ISSUER, 0), "X509_STORE_CTX_get1_issuer"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_STORE_CTX_INIT, 0), "X509_STORE_CTX_init"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_STORE_CTX_NEW, 0), "X509_STORE_CTX_new"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_STORE_CTX_PURPOSE_INHERIT, 0), "X509_STORE_CTX_purpose_inherit"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_STORE_NEW, 0), "X509_STORE_new"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_TO_X509_REQ, 0), "X509_to_X509_REQ"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_TRUST_ADD, 0), "X509_TRUST_add"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_TRUST_SET, 0), "X509_TRUST_set"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_VERIFY, 0), "X509_verify"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_VERIFY_CERT, 0), "X509_verify_cert"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_VERIFY_PARAM_NEW, 0), "X509_VERIFY_PARAM_new"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_VERIFY_SM2, 0), "x509_verify_sm2"}, {0, NULL} }; static const ERR_STRING_DATA X509_str_reasons[] = { {ERR_PACK(ERR_LIB_X509, 0, X509_R_AKID_MISMATCH), "akid mismatch"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_BAD_SELECTOR), "bad selector"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_BAD_X509_FILETYPE), "bad x509 filetype"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_BASE64_DECODE_ERROR), "base64 decode error"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_CANT_CHECK_DH_KEY), "cant check dh key"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_CERT_ALREADY_IN_HASH_TABLE), "cert already in hash table"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_CRL_ALREADY_DELTA), "crl already delta"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_CRL_VERIFY_FAILURE), "crl verify failure"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_IDP_MISMATCH), "idp mismatch"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_INVALID_ATTRIBUTES), "invalid attributes"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_INVALID_DIRECTORY), "invalid directory"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_INVALID_FIELD_NAME), "invalid field name"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_INVALID_TRUST), "invalid trust"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_ISSUER_MISMATCH), "issuer mismatch"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_KEY_TYPE_MISMATCH), "key type mismatch"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_KEY_VALUES_MISMATCH), "key values mismatch"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_LOADING_CERT_DIR), "loading cert dir"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_LOADING_DEFAULTS), "loading defaults"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_METHOD_NOT_SUPPORTED), "method not supported"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_NAME_TOO_LONG), "name too long"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_NEWER_CRL_NOT_NEWER), "newer crl not newer"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_NO_CERTIFICATE_FOUND), "no certificate found"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_NO_CERTIFICATE_OR_CRL_FOUND), "no certificate or crl found"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_NO_CERT_SET_FOR_US_TO_VERIFY), "no cert set for us to verify"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_NO_CRL_FOUND), "no crl found"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_NO_CRL_NUMBER), "no crl number"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_PUBLIC_KEY_DECODE_ERROR), "public key decode error"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_PUBLIC_KEY_ENCODE_ERROR), "public key encode error"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_SHOULD_RETRY), "should retry"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_UNABLE_TO_FIND_PARAMETERS_IN_CHAIN), "unable to find parameters in chain"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY), "unable to get certs public key"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_UNKNOWN_KEY_TYPE), "unknown key type"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_UNKNOWN_NID), "unknown nid"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_UNKNOWN_PURPOSE_ID), "unknown purpose id"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_UNKNOWN_TRUST_ID), "unknown trust id"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_UNSUPPORTED_ALGORITHM), "unsupported algorithm"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_WRONG_LOOKUP_TYPE), "wrong lookup type"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_WRONG_TYPE), "wrong type"}, {0, NULL} }; #endif int ERR_load_X509_strings(void) { #ifndef OPENSSL_NO_ERR if (ERR_func_error_string(X509_str_functs[0].error) == NULL) { ERR_load_strings_const(X509_str_functs); ERR_load_strings_const(X509_str_reasons); } #endif return 1; }
the_stack_data/179831546.c
int main() { unsigned long u; u = 1; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; if (!u) _exit(0); _exit(1); }
the_stack_data/218894617.c
/* * An implementation of key value pair (KVP) functionality for Linux. * * * Copyright (C) 2010, Novell, Inc. * Author : K. Y. Srinivasan <[email protected]> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or * NON INFRINGEMENT. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * */ #include <sys/poll.h> #include <sys/utsname.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <ctype.h> #include <errno.h> #include <arpa/inet.h> #include <linux/hyperv.h> #include <ifaddrs.h> #include <netdb.h> #include <syslog.h> #include <sys/stat.h> #include <fcntl.h> #include <dirent.h> #include <net/if.h> #include <limits.h> #include <getopt.h> /* * KVP protocol: The user mode component first registers with the * the kernel component. Subsequently, the kernel component requests, data * for the specified keys. In response to this message the user mode component * fills in the value corresponding to the specified key. We overload the * sequence field in the cn_msg header to define our KVP message types. * * We use this infrastructure for also supporting queries from user mode * application for state that may be maintained in the KVP kernel component. * */ enum key_index { FullyQualifiedDomainName = 0, IntegrationServicesVersion, /*This key is serviced in the kernel*/ NetworkAddressIPv4, NetworkAddressIPv6, OSBuildNumber, OSName, OSMajorVersion, OSMinorVersion, OSVersion, ProcessorArchitecture }; enum { IPADDR = 0, NETMASK, GATEWAY, DNS }; static int in_hand_shake; static char *os_name = ""; static char *os_major = ""; static char *os_minor = ""; static char *processor_arch; static char *os_build; static char *os_version; static char *lic_version = "Unknown version"; static char full_domain_name[HV_KVP_EXCHANGE_MAX_VALUE_SIZE]; static struct utsname uts_buf; /* * The location of the interface configuration file. */ #define KVP_CONFIG_LOC "/var/lib/hyperv" #ifndef KVP_SCRIPTS_PATH #define KVP_SCRIPTS_PATH "/usr/libexec/hypervkvpd/" #endif #define KVP_NET_DIR "/sys/class/net/" #define MAX_FILE_NAME 100 #define ENTRIES_PER_BLOCK 50 struct kvp_record { char key[HV_KVP_EXCHANGE_MAX_KEY_SIZE]; char value[HV_KVP_EXCHANGE_MAX_VALUE_SIZE]; }; struct kvp_file_state { int fd; int num_blocks; struct kvp_record *records; int num_records; char fname[MAX_FILE_NAME]; }; static struct kvp_file_state kvp_file_info[KVP_POOL_COUNT]; static void kvp_acquire_lock(int pool) { struct flock fl = {F_WRLCK, SEEK_SET, 0, 0, 0}; fl.l_pid = getpid(); if (fcntl(kvp_file_info[pool].fd, F_SETLKW, &fl) == -1) { syslog(LOG_ERR, "Failed to acquire the lock pool: %d; error: %d %s", pool, errno, strerror(errno)); exit(EXIT_FAILURE); } } static void kvp_release_lock(int pool) { struct flock fl = {F_UNLCK, SEEK_SET, 0, 0, 0}; fl.l_pid = getpid(); if (fcntl(kvp_file_info[pool].fd, F_SETLK, &fl) == -1) { syslog(LOG_ERR, "Failed to release the lock pool: %d; error: %d %s", pool, errno, strerror(errno)); exit(EXIT_FAILURE); } } static void kvp_update_file(int pool) { FILE *filep; /* * We are going to write our in-memory registry out to * disk; acquire the lock first. */ kvp_acquire_lock(pool); filep = fopen(kvp_file_info[pool].fname, "we"); if (!filep) { syslog(LOG_ERR, "Failed to open file, pool: %d; error: %d %s", pool, errno, strerror(errno)); kvp_release_lock(pool); exit(EXIT_FAILURE); } fwrite(kvp_file_info[pool].records, sizeof(struct kvp_record), kvp_file_info[pool].num_records, filep); if (ferror(filep) || fclose(filep)) { kvp_release_lock(pool); syslog(LOG_ERR, "Failed to write file, pool: %d", pool); exit(EXIT_FAILURE); } kvp_release_lock(pool); } static void kvp_update_mem_state(int pool) { FILE *filep; size_t records_read = 0; struct kvp_record *record = kvp_file_info[pool].records; struct kvp_record *readp; int num_blocks = kvp_file_info[pool].num_blocks; int alloc_unit = sizeof(struct kvp_record) * ENTRIES_PER_BLOCK; kvp_acquire_lock(pool); filep = fopen(kvp_file_info[pool].fname, "re"); if (!filep) { syslog(LOG_ERR, "Failed to open file, pool: %d; error: %d %s", pool, errno, strerror(errno)); kvp_release_lock(pool); exit(EXIT_FAILURE); } for (;;) { readp = &record[records_read]; records_read += fread(readp, sizeof(struct kvp_record), ENTRIES_PER_BLOCK * num_blocks - records_read, filep); if (ferror(filep)) { syslog(LOG_ERR, "Failed to read file, pool: %d; error: %d %s", pool, errno, strerror(errno)); kvp_release_lock(pool); exit(EXIT_FAILURE); } if (!feof(filep)) { /* * We have more data to read. */ num_blocks++; record = realloc(record, alloc_unit * num_blocks); if (record == NULL) { syslog(LOG_ERR, "malloc failed"); kvp_release_lock(pool); exit(EXIT_FAILURE); } continue; } break; } kvp_file_info[pool].num_blocks = num_blocks; kvp_file_info[pool].records = record; kvp_file_info[pool].num_records = records_read; fclose(filep); kvp_release_lock(pool); } static int kvp_file_init(void) { int fd; char *fname; int i; int alloc_unit = sizeof(struct kvp_record) * ENTRIES_PER_BLOCK; if (access(KVP_CONFIG_LOC, F_OK)) { if (mkdir(KVP_CONFIG_LOC, 0755 /* rwxr-xr-x */)) { syslog(LOG_ERR, "Failed to create '%s'; error: %d %s", KVP_CONFIG_LOC, errno, strerror(errno)); exit(EXIT_FAILURE); } } for (i = 0; i < KVP_POOL_COUNT; i++) { fname = kvp_file_info[i].fname; sprintf(fname, "%s/.kvp_pool_%d", KVP_CONFIG_LOC, i); fd = open(fname, O_RDWR | O_CREAT | O_CLOEXEC, 0644 /* rw-r--r-- */); if (fd == -1) return 1; kvp_file_info[i].fd = fd; kvp_file_info[i].num_blocks = 1; kvp_file_info[i].records = malloc(alloc_unit); if (kvp_file_info[i].records == NULL) return 1; kvp_file_info[i].num_records = 0; kvp_update_mem_state(i); } return 0; } static int kvp_key_delete(int pool, const __u8 *key, int key_size) { int i; int j, k; int num_records; struct kvp_record *record; /* * First update the in-memory state. */ kvp_update_mem_state(pool); num_records = kvp_file_info[pool].num_records; record = kvp_file_info[pool].records; for (i = 0; i < num_records; i++) { if (memcmp(key, record[i].key, key_size)) continue; /* * Found a match; just move the remaining * entries up. */ if (i == (num_records - 1)) { kvp_file_info[pool].num_records--; kvp_update_file(pool); return 0; } j = i; k = j + 1; for (; k < num_records; k++) { strcpy(record[j].key, record[k].key); strcpy(record[j].value, record[k].value); j++; } kvp_file_info[pool].num_records--; kvp_update_file(pool); return 0; } return 1; } static int kvp_key_add_or_modify(int pool, const __u8 *key, int key_size, const __u8 *value, int value_size) { int i; int num_records; struct kvp_record *record; int num_blocks; if ((key_size > HV_KVP_EXCHANGE_MAX_KEY_SIZE) || (value_size > HV_KVP_EXCHANGE_MAX_VALUE_SIZE)) return 1; /* * First update the in-memory state. */ kvp_update_mem_state(pool); num_records = kvp_file_info[pool].num_records; record = kvp_file_info[pool].records; num_blocks = kvp_file_info[pool].num_blocks; for (i = 0; i < num_records; i++) { if (memcmp(key, record[i].key, key_size)) continue; /* * Found a match; just update the value - * this is the modify case. */ memcpy(record[i].value, value, value_size); kvp_update_file(pool); return 0; } /* * Need to add a new entry; */ if (num_records == (ENTRIES_PER_BLOCK * num_blocks)) { /* Need to allocate a larger array for reg entries. */ record = realloc(record, sizeof(struct kvp_record) * ENTRIES_PER_BLOCK * (num_blocks + 1)); if (record == NULL) return 1; kvp_file_info[pool].num_blocks++; } memcpy(record[i].value, value, value_size); memcpy(record[i].key, key, key_size); kvp_file_info[pool].records = record; kvp_file_info[pool].num_records++; kvp_update_file(pool); return 0; } static int kvp_get_value(int pool, const __u8 *key, int key_size, __u8 *value, int value_size) { int i; int num_records; struct kvp_record *record; if ((key_size > HV_KVP_EXCHANGE_MAX_KEY_SIZE) || (value_size > HV_KVP_EXCHANGE_MAX_VALUE_SIZE)) return 1; /* * First update the in-memory state. */ kvp_update_mem_state(pool); num_records = kvp_file_info[pool].num_records; record = kvp_file_info[pool].records; for (i = 0; i < num_records; i++) { if (memcmp(key, record[i].key, key_size)) continue; /* * Found a match; just copy the value out. */ memcpy(value, record[i].value, value_size); return 0; } return 1; } static int kvp_pool_enumerate(int pool, int index, __u8 *key, int key_size, __u8 *value, int value_size) { struct kvp_record *record; /* * First update our in-memory database. */ kvp_update_mem_state(pool); record = kvp_file_info[pool].records; if (index >= kvp_file_info[pool].num_records) { return 1; } memcpy(key, record[index].key, key_size); memcpy(value, record[index].value, value_size); return 0; } void kvp_get_os_info(void) { FILE *file; char *p, buf[512]; uname(&uts_buf); os_version = uts_buf.release; os_build = strdup(uts_buf.release); os_name = uts_buf.sysname; processor_arch = uts_buf.machine; /* * The current windows host (win7) expects the build * string to be of the form: x.y.z * Strip additional information we may have. */ p = strchr(os_version, '-'); if (p) *p = '\0'; /* * Parse the /etc/os-release file if present: * http://www.freedesktop.org/software/systemd/man/os-release.html */ file = fopen("/etc/os-release", "r"); if (file != NULL) { while (fgets(buf, sizeof(buf), file)) { char *value, *q; /* Ignore comments */ if (buf[0] == '#') continue; /* Split into name=value */ p = strchr(buf, '='); if (!p) continue; *p++ = 0; /* Remove quotes and newline; un-escape */ value = p; q = p; while (*p) { if (*p == '\\') { ++p; if (!*p) break; *q++ = *p++; } else if (*p == '\'' || *p == '"' || *p == '\n') { ++p; } else { *q++ = *p++; } } *q = 0; if (!strcmp(buf, "NAME")) { p = strdup(value); if (!p) break; os_name = p; } else if (!strcmp(buf, "VERSION_ID")) { p = strdup(value); if (!p) break; os_major = p; } } fclose(file); return; } /* Fallback for older RH/SUSE releases */ file = fopen("/etc/SuSE-release", "r"); if (file != NULL) goto kvp_osinfo_found; file = fopen("/etc/redhat-release", "r"); if (file != NULL) goto kvp_osinfo_found; /* * We don't have information about the os. */ return; kvp_osinfo_found: /* up to three lines */ p = fgets(buf, sizeof(buf), file); if (p) { p = strchr(buf, '\n'); if (p) *p = '\0'; p = strdup(buf); if (!p) goto done; os_name = p; /* second line */ p = fgets(buf, sizeof(buf), file); if (p) { p = strchr(buf, '\n'); if (p) *p = '\0'; p = strdup(buf); if (!p) goto done; os_major = p; /* third line */ p = fgets(buf, sizeof(buf), file); if (p) { p = strchr(buf, '\n'); if (p) *p = '\0'; p = strdup(buf); if (p) os_minor = p; } } } done: fclose(file); return; } /* * Retrieve an interface name corresponding to the specified guid. * If there is a match, the function returns a pointer * to the interface name and if not, a NULL is returned. * If a match is found, the caller is responsible for * freeing the memory. */ static char *kvp_get_if_name(char *guid) { DIR *dir; struct dirent *entry; FILE *file; char *p, *x; char *if_name = NULL; char buf[256]; char dev_id[PATH_MAX]; dir = opendir(KVP_NET_DIR); if (dir == NULL) return NULL; while ((entry = readdir(dir)) != NULL) { /* * Set the state for the next pass. */ snprintf(dev_id, sizeof(dev_id), "%s%s/device/device_id", KVP_NET_DIR, entry->d_name); file = fopen(dev_id, "r"); if (file == NULL) continue; p = fgets(buf, sizeof(buf), file); if (p) { x = strchr(p, '\n'); if (x) *x = '\0'; if (!strcmp(p, guid)) { /* * Found the guid match; return the interface * name. The caller will free the memory. */ if_name = strdup(entry->d_name); fclose(file); break; } } fclose(file); } closedir(dir); return if_name; } /* * Retrieve the MAC address given the interface name. */ static char *kvp_if_name_to_mac(char *if_name) { FILE *file; char *p, *x; char buf[256]; char addr_file[PATH_MAX]; unsigned int i; char *mac_addr = NULL; snprintf(addr_file, sizeof(addr_file), "%s%s%s", KVP_NET_DIR, if_name, "/address"); file = fopen(addr_file, "r"); if (file == NULL) return NULL; p = fgets(buf, sizeof(buf), file); if (p) { x = strchr(p, '\n'); if (x) *x = '\0'; for (i = 0; i < strlen(p); i++) p[i] = toupper(p[i]); mac_addr = strdup(p); } fclose(file); return mac_addr; } static void kvp_process_ipconfig_file(char *cmd, char *config_buf, unsigned int len, int element_size, int offset) { char buf[256]; char *p; char *x; FILE *file; /* * First execute the command. */ file = popen(cmd, "r"); if (file == NULL) return; if (offset == 0) memset(config_buf, 0, len); while ((p = fgets(buf, sizeof(buf), file)) != NULL) { if (len < strlen(config_buf) + element_size + 1) break; x = strchr(p, '\n'); if (x) *x = '\0'; strcat(config_buf, p); strcat(config_buf, ";"); } pclose(file); } static void kvp_get_ipconfig_info(char *if_name, struct hv_kvp_ipaddr_value *buffer) { char cmd[512]; char dhcp_info[128]; char *p; FILE *file; /* * Get the address of default gateway (ipv4). */ sprintf(cmd, "%s %s", "ip route show dev", if_name); strcat(cmd, " | awk '/default/ {print $3 }'"); /* * Execute the command to gather gateway info. */ kvp_process_ipconfig_file(cmd, (char *)buffer->gate_way, (MAX_GATEWAY_SIZE * 2), INET_ADDRSTRLEN, 0); /* * Get the address of default gateway (ipv6). */ sprintf(cmd, "%s %s", "ip -f inet6 route show dev", if_name); strcat(cmd, " | awk '/default/ {print $3 }'"); /* * Execute the command to gather gateway info (ipv6). */ kvp_process_ipconfig_file(cmd, (char *)buffer->gate_way, (MAX_GATEWAY_SIZE * 2), INET6_ADDRSTRLEN, 1); /* * Gather the DNS state. * Since there is no standard way to get this information * across various distributions of interest; we just invoke * an external script that needs to be ported across distros * of interest. * * Following is the expected format of the information from the script: * * ipaddr1 (nameserver1) * ipaddr2 (nameserver2) * . * . */ sprintf(cmd, KVP_SCRIPTS_PATH "%s", "hv_get_dns_info"); /* * Execute the command to gather DNS info. */ kvp_process_ipconfig_file(cmd, (char *)buffer->dns_addr, (MAX_IP_ADDR_SIZE * 2), INET_ADDRSTRLEN, 0); /* * Gather the DHCP state. * We will gather this state by invoking an external script. * The parameter to the script is the interface name. * Here is the expected output: * * Enabled: DHCP enabled. */ sprintf(cmd, KVP_SCRIPTS_PATH "%s %s", "hv_get_dhcp_info", if_name); file = popen(cmd, "r"); if (file == NULL) return; p = fgets(dhcp_info, sizeof(dhcp_info), file); if (p == NULL) { pclose(file); return; } if (!strncmp(p, "Enabled", 7)) buffer->dhcp_enabled = 1; else buffer->dhcp_enabled = 0; pclose(file); } static unsigned int hweight32(unsigned int *w) { unsigned int res = *w - ((*w >> 1) & 0x55555555); res = (res & 0x33333333) + ((res >> 2) & 0x33333333); res = (res + (res >> 4)) & 0x0F0F0F0F; res = res + (res >> 8); return (res + (res >> 16)) & 0x000000FF; } static int kvp_process_ip_address(void *addrp, int family, char *buffer, int length, int *offset) { struct sockaddr_in *addr; struct sockaddr_in6 *addr6; int addr_length; char tmp[50]; const char *str; if (family == AF_INET) { addr = (struct sockaddr_in *)addrp; str = inet_ntop(family, &addr->sin_addr, tmp, 50); addr_length = INET_ADDRSTRLEN; } else { addr6 = (struct sockaddr_in6 *)addrp; str = inet_ntop(family, &addr6->sin6_addr.s6_addr, tmp, 50); addr_length = INET6_ADDRSTRLEN; } if ((length - *offset) < addr_length + 2) return HV_E_FAIL; if (str == NULL) { strcpy(buffer, "inet_ntop failed\n"); return HV_E_FAIL; } if (*offset == 0) strcpy(buffer, tmp); else { strcat(buffer, ";"); strcat(buffer, tmp); } *offset += strlen(str) + 1; return 0; } static int kvp_get_ip_info(int family, char *if_name, int op, void *out_buffer, unsigned int length) { struct ifaddrs *ifap; struct ifaddrs *curp; int offset = 0; int sn_offset = 0; int error = 0; char *buffer; struct hv_kvp_ipaddr_value *ip_buffer = NULL; char cidr_mask[5]; /* /xyz */ int weight; int i; unsigned int *w; char *sn_str; struct sockaddr_in6 *addr6; if (op == KVP_OP_ENUMERATE) { buffer = out_buffer; } else { ip_buffer = out_buffer; buffer = (char *)ip_buffer->ip_addr; ip_buffer->addr_family = 0; } /* * On entry into this function, the buffer is capable of holding the * maximum key value. */ if (getifaddrs(&ifap)) { strcpy(buffer, "getifaddrs failed\n"); return HV_E_FAIL; } curp = ifap; while (curp != NULL) { if (curp->ifa_addr == NULL) { curp = curp->ifa_next; continue; } if ((if_name != NULL) && (strncmp(curp->ifa_name, if_name, strlen(if_name)))) { /* * We want info about a specific interface; * just continue. */ curp = curp->ifa_next; continue; } /* * We only support two address families: AF_INET and AF_INET6. * If a family value of 0 is specified, we collect both * supported address families; if not we gather info on * the specified address family. */ if ((((family != 0) && (curp->ifa_addr->sa_family != family))) || (curp->ifa_flags & IFF_LOOPBACK)) { curp = curp->ifa_next; continue; } if ((curp->ifa_addr->sa_family != AF_INET) && (curp->ifa_addr->sa_family != AF_INET6)) { curp = curp->ifa_next; continue; } if (op == KVP_OP_GET_IP_INFO) { /* * Gather info other than the IP address. * IP address info will be gathered later. */ if (curp->ifa_addr->sa_family == AF_INET) { ip_buffer->addr_family |= ADDR_FAMILY_IPV4; /* * Get subnet info. */ error = kvp_process_ip_address( curp->ifa_netmask, AF_INET, (char *) ip_buffer->sub_net, length, &sn_offset); if (error) goto gather_ipaddr; } else { ip_buffer->addr_family |= ADDR_FAMILY_IPV6; /* * Get subnet info in CIDR format. */ weight = 0; sn_str = (char *)ip_buffer->sub_net; addr6 = (struct sockaddr_in6 *) curp->ifa_netmask; w = addr6->sin6_addr.s6_addr32; for (i = 0; i < 4; i++) weight += hweight32(&w[i]); sprintf(cidr_mask, "/%d", weight); if (length < sn_offset + strlen(cidr_mask) + 1) goto gather_ipaddr; if (sn_offset == 0) strcpy(sn_str, cidr_mask); else { strcat((char *)ip_buffer->sub_net, ";"); strcat(sn_str, cidr_mask); } sn_offset += strlen(sn_str) + 1; } /* * Collect other ip related configuration info. */ kvp_get_ipconfig_info(if_name, ip_buffer); } gather_ipaddr: error = kvp_process_ip_address(curp->ifa_addr, curp->ifa_addr->sa_family, buffer, length, &offset); if (error) goto getaddr_done; curp = curp->ifa_next; } getaddr_done: freeifaddrs(ifap); return error; } /* * Retrieve the IP given the MAC address. */ static int kvp_mac_to_ip(struct hv_kvp_ipaddr_value *kvp_ip_val) { char *mac = (char *)kvp_ip_val->adapter_id; DIR *dir; struct dirent *entry; FILE *file; char *p, *x; char *if_name = NULL; char buf[256]; char dev_id[PATH_MAX]; unsigned int i; int error = HV_E_FAIL; dir = opendir(KVP_NET_DIR); if (dir == NULL) return HV_E_FAIL; while ((entry = readdir(dir)) != NULL) { /* * Set the state for the next pass. */ snprintf(dev_id, sizeof(dev_id), "%s%s/address", KVP_NET_DIR, entry->d_name); file = fopen(dev_id, "r"); if (file == NULL) continue; p = fgets(buf, sizeof(buf), file); fclose(file); if (!p) continue; x = strchr(p, '\n'); if (x) *x = '\0'; for (i = 0; i < strlen(p); i++) p[i] = toupper(p[i]); if (strcmp(p, mac)) continue; /* * Found the MAC match. * A NIC (e.g. VF) matching the MAC, but without IP, is skipped. */ if_name = entry->d_name; if (!if_name) continue; error = kvp_get_ip_info(0, if_name, KVP_OP_GET_IP_INFO, kvp_ip_val, MAX_IP_ADDR_SIZE * 2); if (!error && strlen((char *)kvp_ip_val->ip_addr)) break; } closedir(dir); return error; } static int expand_ipv6(char *addr, int type) { int ret; struct in6_addr v6_addr; ret = inet_pton(AF_INET6, addr, &v6_addr); if (ret != 1) { if (type == NETMASK) return 1; return 0; } sprintf(addr, "%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:" "%02x%02x:%02x%02x:%02x%02x", (int)v6_addr.s6_addr[0], (int)v6_addr.s6_addr[1], (int)v6_addr.s6_addr[2], (int)v6_addr.s6_addr[3], (int)v6_addr.s6_addr[4], (int)v6_addr.s6_addr[5], (int)v6_addr.s6_addr[6], (int)v6_addr.s6_addr[7], (int)v6_addr.s6_addr[8], (int)v6_addr.s6_addr[9], (int)v6_addr.s6_addr[10], (int)v6_addr.s6_addr[11], (int)v6_addr.s6_addr[12], (int)v6_addr.s6_addr[13], (int)v6_addr.s6_addr[14], (int)v6_addr.s6_addr[15]); return 1; } static int is_ipv4(char *addr) { int ret; struct in_addr ipv4_addr; ret = inet_pton(AF_INET, addr, &ipv4_addr); if (ret == 1) return 1; return 0; } static int parse_ip_val_buffer(char *in_buf, int *offset, char *out_buf, int out_len) { char *x; char *start; /* * in_buf has sequence of characters that are separated by * the character ';'. The last sequence does not have the * terminating ";" character. */ start = in_buf + *offset; x = strchr(start, ';'); if (x) *x = 0; else x = start + strlen(start); if (strlen(start) != 0) { int i = 0; /* * Get rid of leading spaces. */ while (start[i] == ' ') i++; if ((x - start) <= out_len) { strcpy(out_buf, (start + i)); *offset += (x - start) + 1; return 1; } } return 0; } static int kvp_write_file(FILE *f, char *s1, char *s2, char *s3) { int ret; ret = fprintf(f, "%s%s%s%s\n", s1, s2, "=", s3); if (ret < 0) return HV_E_FAIL; return 0; } static int process_ip_string(FILE *f, char *ip_string, int type) { int error = 0; char addr[INET6_ADDRSTRLEN]; int i = 0; int j = 0; char str[256]; char sub_str[13]; int offset = 0; memset(addr, 0, sizeof(addr)); while (parse_ip_val_buffer(ip_string, &offset, addr, (MAX_IP_ADDR_SIZE * 2))) { sub_str[0] = 0; if (is_ipv4(addr)) { switch (type) { case IPADDR: snprintf(str, sizeof(str), "%s", "IPADDR"); break; case NETMASK: snprintf(str, sizeof(str), "%s", "NETMASK"); break; case GATEWAY: snprintf(str, sizeof(str), "%s", "GATEWAY"); break; case DNS: snprintf(str, sizeof(str), "%s", "DNS"); break; } if (type == DNS) { snprintf(sub_str, sizeof(sub_str), "%d", ++i); } else if (type == GATEWAY && i == 0) { ++i; } else { snprintf(sub_str, sizeof(sub_str), "%d", i++); } } else if (expand_ipv6(addr, type)) { switch (type) { case IPADDR: snprintf(str, sizeof(str), "%s", "IPV6ADDR"); break; case NETMASK: snprintf(str, sizeof(str), "%s", "IPV6NETMASK"); break; case GATEWAY: snprintf(str, sizeof(str), "%s", "IPV6_DEFAULTGW"); break; case DNS: snprintf(str, sizeof(str), "%s", "DNS"); break; } if (type == DNS) { snprintf(sub_str, sizeof(sub_str), "%d", ++i); } else if (j == 0) { ++j; } else { snprintf(sub_str, sizeof(sub_str), "_%d", j++); } } else { return HV_INVALIDARG; } error = kvp_write_file(f, str, sub_str, addr); if (error) return error; memset(addr, 0, sizeof(addr)); } return 0; } static int kvp_set_ip_info(char *if_name, struct hv_kvp_ipaddr_value *new_val) { int error = 0; char if_file[PATH_MAX]; FILE *file; char cmd[PATH_MAX]; char *mac_addr; int str_len; /* * Set the configuration for the specified interface with * the information provided. Since there is no standard * way to configure an interface, we will have an external * script that does the job of configuring the interface and * flushing the configuration. * * The parameters passed to this external script are: * 1. A configuration file that has the specified configuration. * * We will embed the name of the interface in the configuration * file: ifcfg-ethx (where ethx is the interface name). * * The information provided here may be more than what is needed * in a given distro to configure the interface and so are free * ignore information that may not be relevant. * * Here is the format of the ip configuration file: * * HWADDR=macaddr * DEVICE=interface name * BOOTPROTO=<protocol> (where <protocol> is "dhcp" if DHCP is configured * or "none" if no boot-time protocol should be used) * * IPADDR0=ipaddr1 * IPADDR1=ipaddr2 * IPADDRx=ipaddry (where y = x + 1) * * NETMASK0=netmask1 * NETMASKx=netmasky (where y = x + 1) * * GATEWAY=ipaddr1 * GATEWAYx=ipaddry (where y = x + 1) * * DNSx=ipaddrx (where first DNS address is tagged as DNS1 etc) * * IPV6 addresses will be tagged as IPV6ADDR, IPV6 gateway will be * tagged as IPV6_DEFAULTGW and IPV6 NETMASK will be tagged as * IPV6NETMASK. * * The host can specify multiple ipv4 and ipv6 addresses to be * configured for the interface. Furthermore, the configuration * needs to be persistent. A subsequent GET call on the interface * is expected to return the configuration that is set via the SET * call. */ snprintf(if_file, sizeof(if_file), "%s%s%s", KVP_CONFIG_LOC, "/ifcfg-", if_name); file = fopen(if_file, "w"); if (file == NULL) { syslog(LOG_ERR, "Failed to open config file; error: %d %s", errno, strerror(errno)); return HV_E_FAIL; } /* * First write out the MAC address. */ mac_addr = kvp_if_name_to_mac(if_name); if (mac_addr == NULL) { error = HV_E_FAIL; goto setval_error; } error = kvp_write_file(file, "HWADDR", "", mac_addr); free(mac_addr); if (error) goto setval_error; error = kvp_write_file(file, "DEVICE", "", if_name); if (error) goto setval_error; /* * The dhcp_enabled flag is only for IPv4. In the case the host only * injects an IPv6 address, the flag is true, but we still need to * proceed to parse and pass the IPv6 information to the * disto-specific script hv_set_ifconfig. */ if (new_val->dhcp_enabled) { error = kvp_write_file(file, "BOOTPROTO", "", "dhcp"); if (error) goto setval_error; } else { error = kvp_write_file(file, "BOOTPROTO", "", "none"); if (error) goto setval_error; } /* * Write the configuration for ipaddress, netmask, gateway and * name servers. */ error = process_ip_string(file, (char *)new_val->ip_addr, IPADDR); if (error) goto setval_error; error = process_ip_string(file, (char *)new_val->sub_net, NETMASK); if (error) goto setval_error; error = process_ip_string(file, (char *)new_val->gate_way, GATEWAY); if (error) goto setval_error; error = process_ip_string(file, (char *)new_val->dns_addr, DNS); if (error) goto setval_error; fclose(file); /* * Now that we have populated the configuration file, * invoke the external script to do its magic. */ str_len = snprintf(cmd, sizeof(cmd), KVP_SCRIPTS_PATH "%s %s", "hv_set_ifconfig", if_file); /* * This is a little overcautious, but it's necessary to suppress some * false warnings from gcc 8.0.1. */ if (str_len <= 0 || (unsigned int)str_len >= sizeof(cmd)) { syslog(LOG_ERR, "Cmd '%s' (len=%d) may be too long", cmd, str_len); return HV_E_FAIL; } if (system(cmd)) { syslog(LOG_ERR, "Failed to execute cmd '%s'; error: %d %s", cmd, errno, strerror(errno)); return HV_E_FAIL; } return 0; setval_error: syslog(LOG_ERR, "Failed to write config file"); fclose(file); return error; } static void kvp_get_domain_name(char *buffer, int length) { struct addrinfo hints, *info ; int error = 0; gethostname(buffer, length); memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_INET; /*Get only ipv4 addrinfo. */ hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_CANONNAME; error = getaddrinfo(buffer, NULL, &hints, &info); if (error != 0) { snprintf(buffer, length, "getaddrinfo failed: 0x%x %s", error, gai_strerror(error)); return; } snprintf(buffer, length, "%s", info->ai_canonname); freeaddrinfo(info); } void print_usage(char *argv[]) { fprintf(stderr, "Usage: %s [options]\n" "Options are:\n" " -n, --no-daemon stay in foreground, don't daemonize\n" " -h, --help print this help\n", argv[0]); } int main(int argc, char *argv[]) { int kvp_fd = -1, len; int error; struct pollfd pfd; char *p; struct hv_kvp_msg hv_msg[1]; char *key_value; char *key_name; int op; int pool; char *if_name; struct hv_kvp_ipaddr_value *kvp_ip_val; int daemonize = 1, long_index = 0, opt; static struct option long_options[] = { {"help", no_argument, 0, 'h' }, {"no-daemon", no_argument, 0, 'n' }, {0, 0, 0, 0 } }; while ((opt = getopt_long(argc, argv, "hn", long_options, &long_index)) != -1) { switch (opt) { case 'n': daemonize = 0; break; case 'h': print_usage(argv); exit(0); default: print_usage(argv); exit(EXIT_FAILURE); } } if (daemonize && daemon(1, 0)) return 1; openlog("KVP", 0, LOG_USER); syslog(LOG_INFO, "KVP starting; pid is:%d", getpid()); /* * Retrieve OS release information. */ kvp_get_os_info(); /* * Cache Fully Qualified Domain Name because getaddrinfo takes an * unpredictable amount of time to finish. */ kvp_get_domain_name(full_domain_name, sizeof(full_domain_name)); if (kvp_file_init()) { syslog(LOG_ERR, "Failed to initialize the pools"); exit(EXIT_FAILURE); } reopen_kvp_fd: if (kvp_fd != -1) close(kvp_fd); in_hand_shake = 1; kvp_fd = open("/dev/vmbus/hv_kvp", O_RDWR | O_CLOEXEC); if (kvp_fd < 0) { syslog(LOG_ERR, "open /dev/vmbus/hv_kvp failed; error: %d %s", errno, strerror(errno)); exit(EXIT_FAILURE); } /* * Register ourselves with the kernel. */ hv_msg->kvp_hdr.operation = KVP_OP_REGISTER1; len = write(kvp_fd, hv_msg, sizeof(struct hv_kvp_msg)); if (len != sizeof(struct hv_kvp_msg)) { syslog(LOG_ERR, "registration to kernel failed; error: %d %s", errno, strerror(errno)); close(kvp_fd); exit(EXIT_FAILURE); } pfd.fd = kvp_fd; while (1) { pfd.events = POLLIN; pfd.revents = 0; if (poll(&pfd, 1, -1) < 0) { syslog(LOG_ERR, "poll failed; error: %d %s", errno, strerror(errno)); if (errno == EINVAL) { close(kvp_fd); exit(EXIT_FAILURE); } else continue; } len = read(kvp_fd, hv_msg, sizeof(struct hv_kvp_msg)); if (len != sizeof(struct hv_kvp_msg)) { syslog(LOG_ERR, "read failed; error:%d %s", errno, strerror(errno)); goto reopen_kvp_fd; } /* * We will use the KVP header information to pass back * the error from this daemon. So, first copy the state * and set the error code to success. */ op = hv_msg->kvp_hdr.operation; pool = hv_msg->kvp_hdr.pool; hv_msg->error = HV_S_OK; if ((in_hand_shake) && (op == KVP_OP_REGISTER1)) { /* * Driver is registering with us; stash away the version * information. */ in_hand_shake = 0; p = (char *)hv_msg->body.kvp_register.version; lic_version = malloc(strlen(p) + 1); if (lic_version) { strcpy(lic_version, p); syslog(LOG_INFO, "KVP LIC Version: %s", lic_version); } else { syslog(LOG_ERR, "malloc failed"); } continue; } switch (op) { case KVP_OP_GET_IP_INFO: kvp_ip_val = &hv_msg->body.kvp_ip_val; error = kvp_mac_to_ip(kvp_ip_val); if (error) hv_msg->error = error; break; case KVP_OP_SET_IP_INFO: kvp_ip_val = &hv_msg->body.kvp_ip_val; if_name = kvp_get_if_name( (char *)kvp_ip_val->adapter_id); if (if_name == NULL) { /* * We could not map the guid to an * interface name; return error. */ hv_msg->error = HV_GUID_NOTFOUND; break; } error = kvp_set_ip_info(if_name, kvp_ip_val); if (error) hv_msg->error = error; free(if_name); break; case KVP_OP_SET: if (kvp_key_add_or_modify(pool, hv_msg->body.kvp_set.data.key, hv_msg->body.kvp_set.data.key_size, hv_msg->body.kvp_set.data.value, hv_msg->body.kvp_set.data.value_size)) hv_msg->error = HV_S_CONT; break; case KVP_OP_GET: if (kvp_get_value(pool, hv_msg->body.kvp_set.data.key, hv_msg->body.kvp_set.data.key_size, hv_msg->body.kvp_set.data.value, hv_msg->body.kvp_set.data.value_size)) hv_msg->error = HV_S_CONT; break; case KVP_OP_DELETE: if (kvp_key_delete(pool, hv_msg->body.kvp_delete.key, hv_msg->body.kvp_delete.key_size)) hv_msg->error = HV_S_CONT; break; default: break; } if (op != KVP_OP_ENUMERATE) goto kvp_done; /* * If the pool is KVP_POOL_AUTO, dynamically generate * both the key and the value; if not read from the * appropriate pool. */ if (pool != KVP_POOL_AUTO) { if (kvp_pool_enumerate(pool, hv_msg->body.kvp_enum_data.index, hv_msg->body.kvp_enum_data.data.key, HV_KVP_EXCHANGE_MAX_KEY_SIZE, hv_msg->body.kvp_enum_data.data.value, HV_KVP_EXCHANGE_MAX_VALUE_SIZE)) hv_msg->error = HV_S_CONT; goto kvp_done; } key_name = (char *)hv_msg->body.kvp_enum_data.data.key; key_value = (char *)hv_msg->body.kvp_enum_data.data.value; switch (hv_msg->body.kvp_enum_data.index) { case FullyQualifiedDomainName: strcpy(key_value, full_domain_name); strcpy(key_name, "FullyQualifiedDomainName"); break; case IntegrationServicesVersion: strcpy(key_name, "IntegrationServicesVersion"); strcpy(key_value, lic_version); break; case NetworkAddressIPv4: kvp_get_ip_info(AF_INET, NULL, KVP_OP_ENUMERATE, key_value, HV_KVP_EXCHANGE_MAX_VALUE_SIZE); strcpy(key_name, "NetworkAddressIPv4"); break; case NetworkAddressIPv6: kvp_get_ip_info(AF_INET6, NULL, KVP_OP_ENUMERATE, key_value, HV_KVP_EXCHANGE_MAX_VALUE_SIZE); strcpy(key_name, "NetworkAddressIPv6"); break; case OSBuildNumber: strcpy(key_value, os_build); strcpy(key_name, "OSBuildNumber"); break; case OSName: strcpy(key_value, os_name); strcpy(key_name, "OSName"); break; case OSMajorVersion: strcpy(key_value, os_major); strcpy(key_name, "OSMajorVersion"); break; case OSMinorVersion: strcpy(key_value, os_minor); strcpy(key_name, "OSMinorVersion"); break; case OSVersion: strcpy(key_value, os_version); strcpy(key_name, "OSVersion"); break; case ProcessorArchitecture: strcpy(key_value, processor_arch); strcpy(key_name, "ProcessorArchitecture"); break; default: hv_msg->error = HV_S_CONT; break; } /* * Send the value back to the kernel. Note: the write() may * return an error due to hibernation; we can ignore the error * by resetting the dev file, i.e. closing and re-opening it. */ kvp_done: len = write(kvp_fd, hv_msg, sizeof(struct hv_kvp_msg)); if (len != sizeof(struct hv_kvp_msg)) { syslog(LOG_ERR, "write failed; error: %d %s", errno, strerror(errno)); goto reopen_kvp_fd; } } close(kvp_fd); exit(0); }
the_stack_data/75403.c
#include <stdio.h> int i; typedef struct data{ int dia; char mes[15]; int ano; }data; typedef struct nota{ char niver[30]; }nota; void preenchedata(data x[],int y,nota a[]) { for(i=0;i<y;i++){ printf("digite o dia: "); scanf("%d",&x[i].dia); printf("\ndigite o mes: "); scanf("%s",&x[i].mes); printf("\ndigite o ano: "); scanf("%d",&x[i].ano); printf("digite o acontecimento: "); scanf("%s",&a[i].niver); printf("\n\n"); } } void imprimedata(data x[],int y,nota a[]) { for(i=0;i<y;i++){ printf("%d:%s:%d",x[i].dia,x[i].mes,x[i].ano); printf("\n\n"); printf("\nacontecimento: %s\n",a[i].niver); } } main() { data hoje[2]; nota aniversario[2]; preenchedata(hoje,2,aniversario); printf("\n\n"); imprimedata(hoje,2,aniversario); }
the_stack_data/144430.c
/* Really stupid get-file-over-http program/function * * Copyright (c) 2019 Joachim Nilsson <[email protected]> * * 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.a */ #include <err.h> #include <errno.h> #include <netdb.h> #include <poll.h> #include <string.h> #include <stdlib.h> #include <stdint.h> #include <stdio.h> #include <unistd.h> #include <arpa/inet.h> #include <sys/types.h> #include <sys/socket.h> static void split(char *url, char **server, uint16_t *port, char **location) { char *ptr, *pptr; if (!url) return; ptr = strstr(url, "://"); if (!ptr) ptr = url; else ptr += 3; *server = ptr; ptr = strchr(ptr, ':'); if (ptr) { *ptr++ = 0; pptr = ptr; } else { ptr = *server; if (!strncmp(url, "http://", 7)) pptr = "80"; else pptr = "443"; } ptr = strchr(ptr, '/'); if (!ptr) return; *ptr++ = 0; *location = ptr; if (pptr) *port = atoi(pptr); } static int nslookup(char *server, uint16_t port, struct addrinfo **result) { struct addrinfo hints; char service[10]; int rc; snprintf(service, sizeof(service), "%d", port); memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_family = AF_INET; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = 0; hints.ai_protocol = 0; rc = getaddrinfo(server, service, &hints, result); if (rc) { warnx("Failed looking up %s:%s: %s\n", server, service, gai_strerror(rc)); return -1; } return 0; } static int get(int sd, struct addrinfo *ai, char *host, uint16_t port, char *location) { struct pollfd pfd; ssize_t num; size_t len; char buf[256]; len = snprintf(buf, sizeof(buf), "GET /%s HTTP/1.1\r\n" "Host: %s:%d\r\n" "Cache-Control: no-cache\r\n" "Connection: close\r\n" "Pragma: no-cache\r\n" "Accept: text/xml, application/xml\r\n" "User-Agent: ssdp-scan/1.0 UPnP/1.0\r\n" "\r\n", location, host, port); num = sendto(sd, buf, len, 0, ai->ai_addr, ai->ai_addrlen); if (num < 0) { warn("Failed sending HTTP GET /%s to %s:%d", location, host, port); close(sd); return -1; } pfd.fd = sd; pfd.events = POLLIN; if (poll(&pfd, 1, 1000) < 0) { warn("Server %s: %s", host, strerror(errno)); freeaddrinfo(ai); close(sd); return -1; } return sd; } static int hello(struct addrinfo *ai, uint16_t port, char *location) { struct sockaddr_in *sin; struct addrinfo *rp; char host[20]; int sd; for (rp = ai; rp != NULL; rp = rp->ai_next) { sd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol); if (sd == -1) continue; if (connect(sd, rp->ai_addr, rp->ai_addrlen) != -1) break; /* Success */ close(sd); } if (rp == NULL) return -1; sin = (struct sockaddr_in *)rp->ai_addr; inet_ntop(AF_INET, &sin->sin_addr, host, sizeof(host)); return get(sd, rp, host, port, location); } FILE *uget(char *url) { struct addrinfo *ai; ssize_t num; uint16_t port = 80; FILE *fp; char *server = NULL, *location = NULL; char *ptr; char buf[256]; int header = 1; int sd; split(url, &server, &port, &location); if (!server || !location) return NULL; if (nslookup(server, port, &ai)) return NULL; sd = hello(ai, port, location); if (-1 == sd) { warn("Failed connecting to %s:%d", server, port); return NULL; } fp = tmpfile(); while ((num = recv(sd, buf, sizeof(buf) - 1, 0)) > 0) { buf[num] = 0; if (header) { if (!strstr(buf, "200 OK")) break; ptr = strstr(buf, "\r\n\r\n"); if (!ptr) break; ptr += 4; fputs(ptr, fp); header = 0; continue; } fputs(buf, fp); } shutdown(sd, SHUT_RDWR); close(sd); rewind(fp); return fp; } #ifndef LOCALSTATEDIR static int usage(void) { printf("Usage: uget URL\n"); return 0; } int main(int argc, char *argv[]) { FILE *fp; char buf[256]; if (argc < 2) return usage(); fp = uget(argv[1]); if (!fp) return 1; while (fgets(buf, sizeof(buf), fp)) fputs(buf, stdout); fclose(fp); return 0; } #endif
the_stack_data/117328155.c
#include <sys/types.h> #include <sys/socket.h> #include <sys/epoll.h> #include <netinet/in.h> #include <arpa/inet.h> #include <errno.h> #include <stdio.h> #include <string.h> #define N_CHILD 32 #define PORT 8888 static void epoll_multiprocess_thundering_herd_test(void) { pid_t pid = -1; int r, i, epfd; int server, client; struct sockaddr_in in; memset(&in, 0, sizeof(in)); in.sin_family = AF_INET; in.sin_port = htons(PORT); in.sin_addr.s_addr = INADDR_ANY; server = socket(AF_INET, SOCK_STREAM, 0); r = bind(server, (struct sockaddr*)&in, sizeof(in)); r = listen(server, 64); epfd = epoll_create(64); for (i = 0; i < N_CHILD && 0 != pid; i++) { pid = fork(); if (pid < 0) { printf("fork(%d) error: %d\n", i, errno); } if (0 == pid) { // child process struct epoll_event event; struct sockaddr_storage storage; socklen_t socklen = sizeof(storage); memset(&event, 0, sizeof(event)); event.events = EPOLLIN; r = epoll_ctl(epfd, EPOLL_CTL_ADD, server, &event); memset(&event, 0, sizeof(event)); r = epoll_wait(epfd, &event, 1, -1); //r = accept(server, (struct sockaddr*)&storage, &socklen); printf("[%d] epoll_wait: %d, event: %u\n", getpid(), r, event.events); close(epfd); } else { // parent process // DO NOTHING printf("child(%d) launch\n", pid); } } if (0 != pid) { r = getchar(); memset(&in, 0, sizeof(in)); in.sin_family = AF_INET; in.sin_port = htons(PORT); in.sin_addr.s_addr = inet_addr("127.0.0.1"); client = socket(AF_INET, SOCK_STREAM, 0); r = connect(client, (struct sockaddr*)&in, sizeof(in)); printf("client connect: %d\n", r); for (i = 0; i < N_CHILD; i++) { wait(); } printf("%s exit\n", __FUNCTION__); } } int main(int argc, char* argv[]) { epoll_multiprocess_thundering_herd_test(); return 0; }
the_stack_data/165768462.c
//===-- X86IntelInstPrinter.cpp - Intel assembly instruction printing -----===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file includes code for rendering MCInst instances as Intel-style // assembly. // //===----------------------------------------------------------------------===// /* Capstone Disassembly Engine */ /* By Nguyen Anh Quynh <[email protected]>, 2013-2014 */ #ifdef CAPSTONE_HAS_X86 #if !defined(CAPSTONE_HAS_OSXKERNEL) #include <ctype.h> #endif #include <platform.h> #if defined(CAPSTONE_HAS_OSXKERNEL) #include <libkern/libkern.h> #else #include <stdio.h> #include <stdlib.h> #endif #include <string.h> #include "../../utils.h" #include "../../MCInst.h" #include "../../SStream.h" #include "../../MCRegisterInfo.h" #include "X86Mapping.h" #define GET_INSTRINFO_ENUM #ifdef CAPSTONE_X86_REDUCE #include "X86GenInstrInfo_reduce.inc" #else #include "X86GenInstrInfo.inc" #endif #include "X86BaseInfo.h" static void printMemReference(MCInst *MI, unsigned Op, SStream *O); static void printOperand(MCInst *MI, unsigned OpNo, SStream *O); static void set_mem_access(MCInst *MI, bool status) { if (MI->csh->detail != CS_OPT_ON) return; MI->csh->doing_mem = status; if (!status) // done, create the next operand slot MI->flat_insn->detail->x86.op_count++; } static void printopaquemem(MCInst *MI, unsigned OpNo, SStream *O) { SStream_concat0(O, "ptr "); switch(MI->csh->mode) { case CS_MODE_16: if (MI->flat_insn->id == X86_INS_LJMP || MI->flat_insn->id == X86_INS_LCALL) MI->x86opsize = 4; else MI->x86opsize = 2; break; case CS_MODE_32: if (MI->flat_insn->id == X86_INS_LJMP || MI->flat_insn->id == X86_INS_LCALL) MI->x86opsize = 6; else MI->x86opsize = 4; break; case CS_MODE_64: if (MI->flat_insn->id == X86_INS_LJMP || MI->flat_insn->id == X86_INS_LCALL) MI->x86opsize = 10; else MI->x86opsize = 8; break; default: // never reach break; } printMemReference(MI, OpNo, O); } static void printi8mem(MCInst *MI, unsigned OpNo, SStream *O) { SStream_concat0(O, "byte ptr "); MI->x86opsize = 1; printMemReference(MI, OpNo, O); } static void printi16mem(MCInst *MI, unsigned OpNo, SStream *O) { MI->x86opsize = 2; SStream_concat0(O, "word ptr "); printMemReference(MI, OpNo, O); } static void printi32mem(MCInst *MI, unsigned OpNo, SStream *O) { MI->x86opsize = 4; SStream_concat0(O, "dword ptr "); printMemReference(MI, OpNo, O); } static void printi64mem(MCInst *MI, unsigned OpNo, SStream *O) { SStream_concat0(O, "qword ptr "); MI->x86opsize = 8; printMemReference(MI, OpNo, O); } static void printi128mem(MCInst *MI, unsigned OpNo, SStream *O) { SStream_concat0(O, "xmmword ptr "); MI->x86opsize = 16; printMemReference(MI, OpNo, O); } #ifndef CAPSTONE_X86_REDUCE static void printi256mem(MCInst *MI, unsigned OpNo, SStream *O) { SStream_concat0(O, "ymmword ptr "); MI->x86opsize = 32; printMemReference(MI, OpNo, O); } static void printi512mem(MCInst *MI, unsigned OpNo, SStream *O) { SStream_concat0(O, "zmmword ptr "); MI->x86opsize = 64; printMemReference(MI, OpNo, O); } static void printf32mem(MCInst *MI, unsigned OpNo, SStream *O) { SStream_concat0(O, "dword ptr "); MI->x86opsize = 4; printMemReference(MI, OpNo, O); } static void printf64mem(MCInst *MI, unsigned OpNo, SStream *O) { SStream_concat0(O, "qword ptr "); MI->x86opsize = 8; printMemReference(MI, OpNo, O); } static void printf80mem(MCInst *MI, unsigned OpNo, SStream *O) { SStream_concat0(O, "xword ptr "); MI->x86opsize = 10; printMemReference(MI, OpNo, O); } static void printf128mem(MCInst *MI, unsigned OpNo, SStream *O) { SStream_concat0(O, "xmmword ptr "); MI->x86opsize = 16; printMemReference(MI, OpNo, O); } static void printf256mem(MCInst *MI, unsigned OpNo, SStream *O) { SStream_concat0(O, "ymmword ptr "); MI->x86opsize = 32; printMemReference(MI, OpNo, O); } static void printf512mem(MCInst *MI, unsigned OpNo, SStream *O) { SStream_concat0(O, "zmmword ptr "); MI->x86opsize = 64; printMemReference(MI, OpNo, O); } static void printSSECC(MCInst *MI, unsigned Op, SStream *OS) { int64_t Imm = MCOperand_getImm(MCInst_getOperand(MI, Op)) & 7; switch (Imm) { default: break; // never reach case 0: SStream_concat0(OS, "eq"); op_addSseCC(MI, X86_SSE_CC_EQ); break; case 1: SStream_concat0(OS, "lt"); op_addSseCC(MI, X86_SSE_CC_LT); break; case 2: SStream_concat0(OS, "le"); op_addSseCC(MI, X86_SSE_CC_LE); break; case 3: SStream_concat0(OS, "unord"); op_addSseCC(MI, X86_SSE_CC_UNORD); break; case 4: SStream_concat0(OS, "neq"); op_addSseCC(MI, X86_SSE_CC_NEQ); break; case 5: SStream_concat0(OS, "nlt"); op_addSseCC(MI, X86_SSE_CC_NLT); break; case 6: SStream_concat0(OS, "nle"); op_addSseCC(MI, X86_SSE_CC_NLE); break; case 7: SStream_concat0(OS, "ord"); op_addSseCC(MI, X86_SSE_CC_ORD); break; case 8: SStream_concat0(OS, "eq_uq"); op_addSseCC(MI, X86_SSE_CC_EQ_UQ); break; case 9: SStream_concat0(OS, "nge"); op_addSseCC(MI, X86_SSE_CC_NGE); break; case 0xa: SStream_concat0(OS, "ngt"); op_addSseCC(MI, X86_SSE_CC_NGT); break; case 0xb: SStream_concat0(OS, "false"); op_addSseCC(MI, X86_SSE_CC_FALSE); break; case 0xc: SStream_concat0(OS, "neq_oq"); op_addSseCC(MI, X86_SSE_CC_NEQ_OQ); break; case 0xd: SStream_concat0(OS, "ge"); op_addSseCC(MI, X86_SSE_CC_GE); break; case 0xe: SStream_concat0(OS, "gt"); op_addSseCC(MI, X86_SSE_CC_GT); break; case 0xf: SStream_concat0(OS, "true"); op_addSseCC(MI, X86_SSE_CC_TRUE); break; } } static void printAVXCC(MCInst *MI, unsigned Op, SStream *O) { int64_t Imm = MCOperand_getImm(MCInst_getOperand(MI, Op)) & 0x1f; switch (Imm) { default: break;//printf("Invalid avxcc argument!\n"); break; case 0: SStream_concat0(O, "eq"); op_addAvxCC(MI, X86_AVX_CC_EQ); break; case 1: SStream_concat0(O, "lt"); op_addAvxCC(MI, X86_AVX_CC_LT); break; case 2: SStream_concat0(O, "le"); op_addAvxCC(MI, X86_AVX_CC_LE); break; case 3: SStream_concat0(O, "unord"); op_addAvxCC(MI, X86_AVX_CC_UNORD); break; case 4: SStream_concat0(O, "neq"); op_addAvxCC(MI, X86_AVX_CC_NEQ); break; case 5: SStream_concat0(O, "nlt"); op_addAvxCC(MI, X86_AVX_CC_NLT); break; case 6: SStream_concat0(O, "nle"); op_addAvxCC(MI, X86_AVX_CC_NLE); break; case 7: SStream_concat0(O, "ord"); op_addAvxCC(MI, X86_AVX_CC_ORD); break; case 8: SStream_concat0(O, "eq_uq"); op_addAvxCC(MI, X86_AVX_CC_EQ_UQ); break; case 9: SStream_concat0(O, "nge"); op_addAvxCC(MI, X86_AVX_CC_NGE); break; case 0xa: SStream_concat0(O, "ngt"); op_addAvxCC(MI, X86_AVX_CC_NGT); break; case 0xb: SStream_concat0(O, "false"); op_addAvxCC(MI, X86_AVX_CC_FALSE); break; case 0xc: SStream_concat0(O, "neq_oq"); op_addAvxCC(MI, X86_AVX_CC_NEQ_OQ); break; case 0xd: SStream_concat0(O, "ge"); op_addAvxCC(MI, X86_AVX_CC_GE); break; case 0xe: SStream_concat0(O, "gt"); op_addAvxCC(MI, X86_AVX_CC_GT); break; case 0xf: SStream_concat0(O, "true"); op_addAvxCC(MI, X86_AVX_CC_TRUE); break; case 0x10: SStream_concat0(O, "eq_os"); op_addAvxCC(MI, X86_AVX_CC_EQ_OS); break; case 0x11: SStream_concat0(O, "lt_oq"); op_addAvxCC(MI, X86_AVX_CC_LT_OQ); break; case 0x12: SStream_concat0(O, "le_oq"); op_addAvxCC(MI, X86_AVX_CC_LE_OQ); break; case 0x13: SStream_concat0(O, "unord_s"); op_addAvxCC(MI, X86_AVX_CC_UNORD_S); break; case 0x14: SStream_concat0(O, "neq_us"); op_addAvxCC(MI, X86_AVX_CC_NEQ_US); break; case 0x15: SStream_concat0(O, "nlt_uq"); op_addAvxCC(MI, X86_AVX_CC_NLT_UQ); break; case 0x16: SStream_concat0(O, "nle_uq"); op_addAvxCC(MI, X86_AVX_CC_NLE_UQ); break; case 0x17: SStream_concat0(O, "ord_s"); op_addAvxCC(MI, X86_AVX_CC_ORD_S); break; case 0x18: SStream_concat0(O, "eq_us"); op_addAvxCC(MI, X86_AVX_CC_EQ_US); break; case 0x19: SStream_concat0(O, "nge_uq"); op_addAvxCC(MI, X86_AVX_CC_NGE_UQ); break; case 0x1a: SStream_concat0(O, "ngt_uq"); op_addAvxCC(MI, X86_AVX_CC_NGT_UQ); break; case 0x1b: SStream_concat0(O, "false_os"); op_addAvxCC(MI, X86_AVX_CC_FALSE_OS); break; case 0x1c: SStream_concat0(O, "neq_os"); op_addAvxCC(MI, X86_AVX_CC_NEQ_OS); break; case 0x1d: SStream_concat0(O, "ge_oq"); op_addAvxCC(MI, X86_AVX_CC_GE_OQ); break; case 0x1e: SStream_concat0(O, "gt_oq"); op_addAvxCC(MI, X86_AVX_CC_GT_OQ); break; case 0x1f: SStream_concat0(O, "true_us"); op_addAvxCC(MI, X86_AVX_CC_TRUE_US); break; } } static void printRoundingControl(MCInst *MI, unsigned Op, SStream *O) { int64_t Imm = MCOperand_getImm(MCInst_getOperand(MI, Op)) & 0x3; switch (Imm) { case 0: SStream_concat0(O, "{rn-sae}"); op_addAvxSae(MI); op_addAvxRoundingMode(MI, X86_AVX_RM_RN); break; case 1: SStream_concat0(O, "{rd-sae}"); op_addAvxSae(MI); op_addAvxRoundingMode(MI, X86_AVX_RM_RD); break; case 2: SStream_concat0(O, "{ru-sae}"); op_addAvxSae(MI); op_addAvxRoundingMode(MI, X86_AVX_RM_RU); break; case 3: SStream_concat0(O, "{rz-sae}"); op_addAvxSae(MI); op_addAvxRoundingMode(MI, X86_AVX_RM_RZ); break; default: break; // never reach } } #endif static char *getRegisterName(unsigned RegNo); static void printRegName(SStream *OS, unsigned RegNo) { SStream_concat0(OS, getRegisterName(RegNo)); } // local printOperand, without updating public operands static void _printOperand(MCInst *MI, unsigned OpNo, SStream *O) { MCOperand *Op = MCInst_getOperand(MI, OpNo); if (MCOperand_isReg(Op)) { printRegName(O, MCOperand_getReg(Op)); } else if (MCOperand_isImm(Op)) { int64_t imm = MCOperand_getImm(Op); if (imm < 0) { if (imm < -HEX_THRESHOLD) SStream_concat(O, "-0x%"PRIx64, -imm); else SStream_concat(O, "-%"PRIu64, -imm); } else { if (imm > HEX_THRESHOLD) SStream_concat(O, "0x%"PRIx64, imm); else SStream_concat(O, "%"PRIu64, imm); } } } static void printSrcIdx(MCInst *MI, unsigned Op, SStream *O) { MCOperand *SegReg; int reg; if (MI->csh->detail) { MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].type = X86_OP_MEM; MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].size = MI->x86opsize; MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.segment = X86_REG_INVALID; MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.base = X86_REG_INVALID; MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.index = X86_REG_INVALID; MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.scale = 1; MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.disp = 0; } SegReg = MCInst_getOperand(MI, Op+1); reg = MCOperand_getReg(SegReg); // If this has a segment register, print it. if (reg) { _printOperand(MI, Op+1, O); if (MI->csh->detail) { MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.segment = reg; } SStream_concat0(O, ":"); } SStream_concat0(O, "["); set_mem_access(MI, true); printOperand(MI, Op, O); SStream_concat0(O, "]"); set_mem_access(MI, false); } static void printDstIdx(MCInst *MI, unsigned Op, SStream *O) { if (MI->csh->detail) { MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].type = X86_OP_MEM; MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].size = MI->x86opsize; MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.segment = X86_REG_INVALID; MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.base = X86_REG_INVALID; MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.index = X86_REG_INVALID; MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.scale = 1; MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.disp = 0; } // DI accesses are always ES-based on non-64bit mode if (MI->csh->mode != CS_MODE_64) { SStream_concat(O, "es:["); if (MI->csh->detail) { MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.segment = X86_REG_ES; } } else SStream_concat(O, "["); set_mem_access(MI, true); printOperand(MI, Op, O); SStream_concat0(O, "]"); set_mem_access(MI, false); } void printSrcIdx8(MCInst *MI, unsigned OpNo, SStream *O) { SStream_concat0(O, "byte ptr "); MI->x86opsize = 1; printSrcIdx(MI, OpNo, O); } void printSrcIdx16(MCInst *MI, unsigned OpNo, SStream *O) { SStream_concat0(O, "word ptr "); MI->x86opsize = 2; printSrcIdx(MI, OpNo, O); } void printSrcIdx32(MCInst *MI, unsigned OpNo, SStream *O) { SStream_concat0(O, "dword ptr "); MI->x86opsize = 4; printSrcIdx(MI, OpNo, O); } void printSrcIdx64(MCInst *MI, unsigned OpNo, SStream *O) { SStream_concat0(O, "qword ptr "); MI->x86opsize = 8; printSrcIdx(MI, OpNo, O); } void printDstIdx8(MCInst *MI, unsigned OpNo, SStream *O) { SStream_concat0(O, "byte ptr "); MI->x86opsize = 1; printDstIdx(MI, OpNo, O); } void printDstIdx16(MCInst *MI, unsigned OpNo, SStream *O) { SStream_concat0(O, "word ptr "); MI->x86opsize = 2; printDstIdx(MI, OpNo, O); } void printDstIdx32(MCInst *MI, unsigned OpNo, SStream *O) { SStream_concat0(O, "dword ptr "); MI->x86opsize = 4; printDstIdx(MI, OpNo, O); } void printDstIdx64(MCInst *MI, unsigned OpNo, SStream *O) { SStream_concat0(O, "qword ptr "); MI->x86opsize = 8; printDstIdx(MI, OpNo, O); } static void printMemOffset(MCInst *MI, unsigned Op, SStream *O) { MCOperand *DispSpec = MCInst_getOperand(MI, Op); MCOperand *SegReg = MCInst_getOperand(MI, Op + 1); int reg; if (MI->csh->detail) { MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].type = X86_OP_MEM; MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].size = MI->x86opsize; MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.segment = X86_REG_INVALID; MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.base = X86_REG_INVALID; MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.index = X86_REG_INVALID; MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.scale = 1; MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.disp = 0; } // If this has a segment register, print it. reg = MCOperand_getReg(SegReg); if (reg) { _printOperand(MI, Op + 1, O); SStream_concat0(O, ":"); if (MI->csh->detail) { MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.segment = reg; } } SStream_concat0(O, "["); if (MCOperand_isImm(DispSpec)) { int64_t imm = MCOperand_getImm(DispSpec); if (MI->csh->detail) MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.disp = imm; if (imm < 0) { SStream_concat(O, "0x%"PRIx64, arch_masks[MI->csh->mode] & imm); } else { if (imm > HEX_THRESHOLD) SStream_concat(O, "0x%"PRIx64, imm); else SStream_concat(O, "%"PRIu64, imm); } } SStream_concat0(O, "]"); if (MI->csh->detail) MI->flat_insn->detail->x86.op_count++; if (MI->op1_size == 0) MI->op1_size = MI->x86opsize; } static void printMemOffs8(MCInst *MI, unsigned OpNo, SStream *O) { SStream_concat0(O, "byte ptr "); MI->x86opsize = 1; printMemOffset(MI, OpNo, O); } static void printMemOffs16(MCInst *MI, unsigned OpNo, SStream *O) { SStream_concat0(O, "word ptr "); MI->x86opsize = 2; printMemOffset(MI, OpNo, O); } static void printMemOffs32(MCInst *MI, unsigned OpNo, SStream *O) { SStream_concat0(O, "dword ptr "); MI->x86opsize = 4; printMemOffset(MI, OpNo, O); } static void printMemOffs64(MCInst *MI, unsigned OpNo, SStream *O) { SStream_concat0(O, "qword ptr "); MI->x86opsize = 8; printMemOffset(MI, OpNo, O); } static char *printAliasInstr(MCInst *MI, SStream *OS, void *info); static void printInstruction(MCInst *MI, SStream *O, MCRegisterInfo *MRI); void X86_Intel_printInst(MCInst *MI, SStream *O, void *Info) { char *mnem; x86_reg reg, reg2; // Try to print any aliases first. mnem = printAliasInstr(MI, O, Info); if (mnem) cs_mem_free(mnem); else printInstruction(MI, O, Info); reg = X86_insn_reg_intel(MCInst_getOpcode(MI)); if (MI->csh->detail) { // first op can be embedded in the asm by llvm. // so we have to add the missing register as the first operand if (reg) { // shift all the ops right to leave 1st slot for this new register op memmove(&(MI->flat_insn->detail->x86.operands[1]), &(MI->flat_insn->detail->x86.operands[0]), sizeof(MI->flat_insn->detail->x86.operands[0]) * (ARR_SIZE(MI->flat_insn->detail->x86.operands) - 1)); MI->flat_insn->detail->x86.operands[0].type = X86_OP_REG; MI->flat_insn->detail->x86.operands[0].reg = reg; MI->flat_insn->detail->x86.operands[0].size = MI->csh->regsize_map[reg]; MI->flat_insn->detail->x86.operands[1].size = MI->csh->regsize_map[reg]; MI->flat_insn->detail->x86.op_count++; } else { if (X86_insn_reg_intel2(MCInst_getOpcode(MI), &reg, &reg2)) { MI->flat_insn->detail->x86.operands[0].type = X86_OP_REG; MI->flat_insn->detail->x86.operands[0].reg = reg; MI->flat_insn->detail->x86.operands[0].size = MI->csh->regsize_map[reg]; MI->flat_insn->detail->x86.operands[1].type = X86_OP_REG; MI->flat_insn->detail->x86.operands[1].reg = reg2; MI->flat_insn->detail->x86.operands[1].size = MI->csh->regsize_map[reg2]; MI->flat_insn->detail->x86.op_count = 2; } } } if (MI->op1_size == 0 && reg) MI->op1_size = MI->csh->regsize_map[reg]; } /// printPCRelImm - This is used to print an immediate value that ends up /// being encoded as a pc-relative value. static void printPCRelImm(MCInst *MI, unsigned OpNo, SStream *O) { MCOperand *Op = MCInst_getOperand(MI, OpNo); if (MCOperand_isImm(Op)) { int64_t imm = MCOperand_getImm(Op) + MI->flat_insn->size + MI->address; // truncat imm for non-64bit if (MI->csh->mode != CS_MODE_64) { imm = imm & 0xffffffff; } if (MI->csh->mode == CS_MODE_16 && (MI->Opcode != X86_JMP_4 && MI->Opcode != X86_CALLpcrel32)) imm = imm & 0xffff; // Hack: X86 16bit with opcode X86_JMP_4 if (MI->csh->mode == CS_MODE_16 && (MI->Opcode == X86_JMP_4 && MI->x86_prefix[2] != 0x66)) imm = imm & 0xffff; // CALL/JMP rel16 is special if (MI->Opcode == X86_CALLpcrel16 || MI->Opcode == X86_JMP_2) imm = imm & 0xffff; if (imm < 0) { SStream_concat(O, "0x%"PRIx64, imm); } else { if (imm > HEX_THRESHOLD) SStream_concat(O, "0x%"PRIx64, imm); else SStream_concat(O, "%"PRIu64, imm); } if (MI->csh->detail) { MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].type = X86_OP_IMM; // if op_count > 0, then this operand's size is taken from the destination op if (MI->flat_insn->detail->x86.op_count > 0) MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].size = MI->flat_insn->detail->x86.operands[0].size; else MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].size = MI->imm_size; MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].imm = imm; MI->flat_insn->detail->x86.op_count++; } if (MI->op1_size == 0) MI->op1_size = MI->imm_size; } } static void printOperand(MCInst *MI, unsigned OpNo, SStream *O) { uint8_t opsize = 0; MCOperand *Op = MCInst_getOperand(MI, OpNo); if (MCOperand_isReg(Op)) { unsigned int reg = MCOperand_getReg(Op); printRegName(O, reg); if (MI->csh->detail) { if (MI->csh->doing_mem) { MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.base = reg; } else { MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].type = X86_OP_REG; MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].reg = reg; MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].size = MI->csh->regsize_map[reg]; MI->flat_insn->detail->x86.op_count++; } } if (MI->op1_size == 0) MI->op1_size = MI->csh->regsize_map[reg]; } else if (MCOperand_isImm(Op)) { int64_t imm = MCOperand_getImm(Op); switch(MCInst_getOpcode(MI)) { default: break; case X86_AAD8i8: case X86_AAM8i8: case X86_ADC8i8: case X86_ADD8i8: case X86_AND8i8: case X86_CMP8i8: case X86_OR8i8: case X86_SBB8i8: case X86_SUB8i8: case X86_TEST8i8: case X86_XOR8i8: case X86_ROL8ri: case X86_ADC8ri: case X86_ADD8ri: case X86_ADD8ri8: case X86_AND8ri: case X86_AND8ri8: case X86_CMP8ri: case X86_MOV8ri: case X86_MOV8ri_alt: case X86_OR8ri: case X86_OR8ri8: case X86_RCL8ri: case X86_RCR8ri: case X86_ROR8ri: case X86_SAL8ri: case X86_SAR8ri: case X86_SBB8ri: case X86_SHL8ri: case X86_SHR8ri: case X86_SUB8ri: case X86_SUB8ri8: case X86_TEST8ri: case X86_TEST8ri_NOREX: case X86_TEST8ri_alt: case X86_XOR8ri: case X86_XOR8ri8: case X86_OUT8ir: case X86_ADC8mi: case X86_ADD8mi: case X86_AND8mi: case X86_CMP8mi: case X86_LOCK_ADD8mi: case X86_LOCK_AND8mi: case X86_LOCK_OR8mi: case X86_LOCK_SUB8mi: case X86_LOCK_XOR8mi: case X86_MOV8mi: case X86_OR8mi: case X86_RCL8mi: case X86_RCR8mi: case X86_ROL8mi: case X86_ROR8mi: case X86_SAL8mi: case X86_SAR8mi: case X86_SBB8mi: case X86_SHL8mi: case X86_SHR8mi: case X86_SUB8mi: case X86_TEST8mi: case X86_TEST8mi_alt: case X86_XOR8mi: case X86_PUSH64i8: case X86_CMP32ri8: case X86_CMP64ri8: imm = imm & 0xff; opsize = 1; // immediate of 1 byte break; } switch(MI->flat_insn->id) { default: if (imm >= 0) { if (imm > HEX_THRESHOLD) SStream_concat(O, "0x%"PRIx64, imm); else SStream_concat(O, "%"PRIu64, imm); } else { if (imm < -HEX_THRESHOLD) SStream_concat(O, "-0x%"PRIx64, -imm); else SStream_concat(O, "-%"PRIu64, -imm); } break; case X86_INS_LCALL: case X86_INS_LJMP: // always print address in positive form if (OpNo == 1) { // selector is ptr16 imm = imm & 0xffff; opsize = 2; } if (imm > HEX_THRESHOLD) SStream_concat(O, "0x%"PRIx64, imm); else SStream_concat(O, "%"PRIu64, imm); break; case X86_INS_AND: case X86_INS_OR: case X86_INS_XOR: // do not print number in negative form if (imm >= 0 && imm <= HEX_THRESHOLD) SStream_concat(O, "%u", imm); else { imm = arch_masks[MI->op1_size? MI->op1_size : MI->imm_size] & imm; SStream_concat(O, "0x%"PRIx64, imm); } break; case X86_INS_RET: // RET imm16 if (imm >= 0 && imm <= HEX_THRESHOLD) SStream_concat(O, "%u", imm); else { imm = 0xffff & imm; SStream_concat(O, "0x%x", 0xffff & imm); } break; } if (MI->csh->detail) { if (MI->csh->doing_mem) { MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.disp = imm; } else { MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].type = X86_OP_IMM; if (opsize > 0) MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].size = opsize; else if (MI->flat_insn->detail->x86.op_count > 0) { if (MI->flat_insn->id != X86_INS_LCALL && MI->flat_insn->id != X86_INS_LJMP) { MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].size = MI->flat_insn->detail->x86.operands[0].size; } else MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].size = MI->imm_size; } else MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].size = MI->imm_size; MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].imm = imm; MI->flat_insn->detail->x86.op_count++; } } //if (MI->op1_size == 0) // MI->op1_size = MI->imm_size; } } static void printMemReference(MCInst *MI, unsigned Op, SStream *O) { bool NeedPlus = false; MCOperand *BaseReg = MCInst_getOperand(MI, Op + X86_AddrBaseReg); uint64_t ScaleVal = MCOperand_getImm(MCInst_getOperand(MI, Op + X86_AddrScaleAmt)); MCOperand *IndexReg = MCInst_getOperand(MI, Op + X86_AddrIndexReg); MCOperand *DispSpec = MCInst_getOperand(MI, Op + X86_AddrDisp); MCOperand *SegReg = MCInst_getOperand(MI, Op + X86_AddrSegmentReg); int reg; if (MI->csh->detail) { MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].type = X86_OP_MEM; MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].size = MI->x86opsize; MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.segment = X86_REG_INVALID; MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.base = MCOperand_getReg(BaseReg); MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.index = MCOperand_getReg(IndexReg); MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.scale = (int)ScaleVal; MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.disp = 0; } // If this has a segment register, print it. reg = MCOperand_getReg(SegReg); if (reg) { _printOperand(MI, Op + X86_AddrSegmentReg, O); if (MI->csh->detail) { MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.segment = reg; } SStream_concat0(O, ":"); } SStream_concat0(O, "["); if (MCOperand_getReg(BaseReg)) { _printOperand(MI, Op + X86_AddrBaseReg, O); NeedPlus = true; } if (MCOperand_getReg(IndexReg)) { if (NeedPlus) SStream_concat0(O, " + "); _printOperand(MI, Op + X86_AddrIndexReg, O); if (ScaleVal != 1) SStream_concat(O, "*%u", ScaleVal); NeedPlus = true; } if (MCOperand_isImm(DispSpec)) { int64_t DispVal = MCOperand_getImm(DispSpec); if (MI->csh->detail) MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.disp = DispVal; if (DispVal) { if (NeedPlus) { if (DispVal < 0) { if (DispVal < -HEX_THRESHOLD) SStream_concat(O, " - 0x%"PRIx64, -DispVal); else SStream_concat(O, " - %"PRIu64, -DispVal); } else { if (DispVal > HEX_THRESHOLD) SStream_concat(O, " + 0x%"PRIx64, DispVal); else SStream_concat(O, " + %"PRIu64, DispVal); } } else { // memory reference to an immediate address if (DispVal < 0) { SStream_concat(O, "0x%"PRIx64, arch_masks[MI->csh->mode] & DispVal); } else { if (DispVal > HEX_THRESHOLD) SStream_concat(O, "0x%"PRIx64, DispVal); else SStream_concat(O, "%"PRIu64, DispVal); } } } else { // DispVal = 0 if (!NeedPlus) // [0] SStream_concat0(O, "0"); } } SStream_concat0(O, "]"); if (MI->csh->detail) MI->flat_insn->detail->x86.op_count++; if (MI->op1_size == 0) MI->op1_size = MI->x86opsize; } #define GET_REGINFO_ENUM #include "X86GenRegisterInfo.inc" #define PRINT_ALIAS_INSTR #ifdef CAPSTONE_X86_REDUCE #include "X86GenAsmWriter1_reduce.inc" #else #include "X86GenAsmWriter1.inc" #endif #endif
the_stack_data/183630.c
#include <stdio.h> int main(int argc, char * argv[]) { int a,b, res; scanf("%d %d", &a, &b); //res = !(a%b==0 || b%a==0) if(a%b==0 || b%a==0) res = 1; else res = 0; printf("%d\n", res); return 0; }
the_stack_data/26701426.c
#include <stdio.h> int main() { int i, n; printf("Chegara sonni kiriting: "); scanf("%d", &n); printf("%d gacha bo'lgan toq sonlar: \n", n); for(i=n; i>=1; i--) { if(i %2!= 0) { printf("%d\n", i); } } return 0; }
the_stack_data/117327143.c
#include <stdio.h> #include <stdlib.h> typedef struct smd_node { struct smd_node *priv; void *data; struct smd_node *next; } smd_node; typedef struct smd_list { smd_node *head; smd_node *tail; int length; } smd_list; smd_list* smd_create_list() { smd_list *list = (smd_list*)malloc(sizeof(smd_list)); list->head = NULL; list->tail = NULL; list->length = 0; return list; } void smd_add_node(smd_list *list, void *data) { smd_node *new_node = (smd_node*)malloc(sizeof(smd_node)); if (!new_node) { printf("Alloc memory error\n"); return; } new_node->priv = NULL; new_node->next = NULL; // XXXX: alloc data ??? new_node->data = data; // first node if (list->head == NULL) { list->head = new_node; list->tail = new_node; list->length++; return; } smd_node *cur_node = list->head; while (cur_node->next) { cur_node = cur_node->next; } cur_node->next = new_node; new_node->priv = cur_node; list->tail = new_node; list->length++; } void smd_delete_first_node(smd_list *list) { smd_node *cur_node = list->head; if (cur_node == NULL) { return; } smd_node *next_node = cur_node->next; free(cur_node); if (next_node == NULL) { list->head = NULL; list->tail = NULL; return; } list->head = next_node; } void smd_print_all_nodes(smd_list *list) { smd_node *cur_node = list->head; while (cur_node) { printf("data: %s\n", cur_node->data); cur_node = cur_node->next; } printf("\n"); } int main() { smd_list *list; list = smd_create_list(); smd_add_node(list, "1"); smd_add_node(list, "2"); smd_add_node(list, "3"); smd_print_all_nodes(list); smd_delete_first_node(list); smd_print_all_nodes(list); smd_delete_first_node(list); smd_print_all_nodes(list); smd_add_node(list, "1"); smd_print_all_nodes(list); smd_delete_first_node(list); smd_delete_first_node(list); smd_print_all_nodes(list); smd_add_node(list, "5"); smd_print_all_nodes(list); return 0; }
the_stack_data/165767474.c
#include <stdio.h> char *chsearch(char *p, char ch) { char *r; r = NULL; while (*p) { if (*p == ch) { r = p; } p++; } return r; } int main(void) { char words[100]; char ch; char *p; puts("Enter some words. (max 100 characters)"); while (1) { gets(words); puts("Enter a character to search in these words."); ch = getchar(); p = chsearch(words, ch); if (p == NULL) printf("Not found: %c\n", ch); else printf("Search result:\nwords[%d] = %c\n", p - words, *p); puts("Enter some words. (max 100 characters)"); } return 0; }
the_stack_data/65559.c
/* Test that the signals below are supported. */ #include <signal.h> int dummy1 = SIGABRT; int dummy2 = SIGALRM; int dummy3 = SIGBUS; int dummy4 = SIGCHLD; int dummy5 = SIGCONT; int dummy6 = SIGFPE; int dummy7 = SIGHUP; int dummy8 = SIGILL; int dummy9 = SIGINT; int dummy10 = SIGKILL; int dummy11 = SIGPIPE; int dummy12 = SIGQUIT; int dummy13 = SIGSEGV; int dummy14 = SIGSTOP; int dummy15 = SIGTERM; int dummy16 = SIGTSTP; int dummy17 = SIGTTIN; int dummy18 = SIGTTOU; int dummy19 = SIGUSR1; int dummy20 = SIGUSR2; int dummy21 = SIGPOLL; int dummy22 = SIGPROF; int dummy23 = SIGSYS; int dummy24 = SIGTRAP; int dummy25 = SIGURG; int dummy26 = SIGVTALRM; int dummy27 = SIGXCPU; int dummy28 = SIGXFSZ;
the_stack_data/48574879.c
/* ** 2015 February 16 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* */ #include "sqlite3.h" #if defined(SQLITE_TEST) #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_RBU) #include "sqlite3rbu.h" #if defined(INCLUDE_SQLITE_TCL_H) # include "sqlite_tcl.h" #else # include "tcl.h" # ifndef SQLITE_TCLAPI # define SQLITE_TCLAPI # endif #endif #include <assert.h> /* From main.c */ extern const char *sqlite3ErrName(int); extern int sqlite3TestMakePointerStr(Tcl_Interp*, char*, void*); void test_rbu_delta(sqlite3_context *pCtx, int nArg, sqlite3_value **apVal){ Tcl_Interp *interp = (Tcl_Interp*)sqlite3_user_data(pCtx); Tcl_Obj *pScript; int i; pScript = Tcl_NewObj(); Tcl_IncrRefCount(pScript); Tcl_ListObjAppendElement(0, pScript, Tcl_NewStringObj("rbu_delta", -1)); for(i=0; i<nArg; i++){ sqlite3_value *pIn = apVal[i]; const char *z = (const char*)sqlite3_value_text(pIn); Tcl_ListObjAppendElement(0, pScript, Tcl_NewStringObj(z, -1)); } if( TCL_OK==Tcl_EvalObjEx(interp, pScript, TCL_GLOBAL_ONLY) ){ const char *z = Tcl_GetStringResult(interp); sqlite3_result_text(pCtx, z, -1, SQLITE_TRANSIENT); }else{ Tcl_BackgroundError(interp); } Tcl_DecrRefCount(pScript); } static int SQLITE_TCLAPI test_sqlite3rbu_cmd( ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ int ret = TCL_OK; sqlite3rbu *pRbu = (sqlite3rbu*)clientData; struct RbuCmd { const char *zName; int nArg; const char *zUsage; } aCmd[] = { {"step", 2, ""}, /* 0 */ {"close", 2, ""}, /* 1 */ {"create_rbu_delta", 2, ""}, /* 2 */ {"savestate", 2, ""}, /* 3 */ {"dbMain_eval", 3, "SQL"}, /* 4 */ {"bp_progress", 2, ""}, /* 5 */ {"db", 3, "RBU"}, /* 6 */ {"state", 2, ""}, /* 7 */ {"progress", 2, ""}, /* 8 */ {0,0,0} }; int iCmd; if( objc<2 ){ Tcl_WrongNumArgs(interp, 1, objv, "METHOD"); return TCL_ERROR; } ret = Tcl_GetIndexFromObjStruct( interp, objv[1], aCmd, sizeof(aCmd[0]), "method", 0, &iCmd ); if( ret ) return TCL_ERROR; if( objc!=aCmd[iCmd].nArg ){ Tcl_WrongNumArgs(interp, 1, objv, aCmd[iCmd].zUsage); return TCL_ERROR; } switch( iCmd ){ case 0: /* step */ { int rc = sqlite3rbu_step(pRbu); Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1)); break; } case 1: /* close */ { char *zErrmsg = 0; int rc; Tcl_DeleteCommand(interp, Tcl_GetString(objv[0])); rc = sqlite3rbu_close(pRbu, &zErrmsg); if( rc==SQLITE_OK || rc==SQLITE_DONE ){ Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1)); assert( zErrmsg==0 ); }else{ Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1)); if( zErrmsg ){ Tcl_AppendResult(interp, " - ", zErrmsg, 0); sqlite3_free(zErrmsg); } ret = TCL_ERROR; } break; } case 2: /* create_rbu_delta */ { sqlite3 *db = sqlite3rbu_db(pRbu, 0); int rc = sqlite3_create_function( db, "rbu_delta", -1, SQLITE_UTF8, (void*)interp, test_rbu_delta, 0, 0 ); Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1)); ret = (rc==SQLITE_OK ? TCL_OK : TCL_ERROR); break; } case 3: /* savestate */ { int rc = sqlite3rbu_savestate(pRbu); Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1)); ret = (rc==SQLITE_OK ? TCL_OK : TCL_ERROR); break; } case 4: /* dbMain_eval */ { sqlite3 *db = sqlite3rbu_db(pRbu, 0); int rc = sqlite3_exec(db, Tcl_GetString(objv[2]), 0, 0, 0); if( rc!=SQLITE_OK ){ Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3_errmsg(db), -1)); ret = TCL_ERROR; } break; } case 5: /* bp_progress */ { int one, two; Tcl_Obj *pObj; sqlite3rbu_bp_progress(pRbu, &one, &two); pObj = Tcl_NewObj(); Tcl_ListObjAppendElement(interp, pObj, Tcl_NewIntObj(one)); Tcl_ListObjAppendElement(interp, pObj, Tcl_NewIntObj(two)); Tcl_SetObjResult(interp, pObj); break; } case 6: /* db */ { int bArg; if( Tcl_GetBooleanFromObj(interp, objv[2], &bArg) ){ ret = TCL_ERROR; }else{ char zBuf[50]; sqlite3 *db = sqlite3rbu_db(pRbu, bArg); if( sqlite3TestMakePointerStr(interp, zBuf, (void*)db) ){ ret = TCL_ERROR; }else{ Tcl_SetResult(interp, zBuf, TCL_VOLATILE); } } break; } case 7: /* state */ { const char *aRes[] = { 0, "oal", "move", "checkpoint", "done", "error" }; int eState = sqlite3rbu_state(pRbu); assert( eState>0 && eState<=5 ); Tcl_SetResult(interp, (char*)aRes[eState], TCL_STATIC); break; } case 8: /* progress */ { sqlite3_int64 nStep = sqlite3rbu_progress(pRbu); Tcl_SetObjResult(interp, Tcl_NewWideIntObj(nStep)); break; } default: /* seems unlikely */ assert( !"cannot happen" ); break; } return ret; } /* ** Tclcmd: sqlite3rbu CMD <target-db> <rbu-db> ?<state-db>? */ static int SQLITE_TCLAPI test_sqlite3rbu( ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ sqlite3rbu *pRbu = 0; const char *zCmd; const char *zTarget; const char *zRbu; const char *zStateDb = 0; if( objc!=4 && objc!=5 ){ Tcl_WrongNumArgs(interp, 1, objv, "NAME TARGET-DB RBU-DB ?STATE-DB?"); return TCL_ERROR; } zCmd = Tcl_GetString(objv[1]); zTarget = Tcl_GetString(objv[2]); zRbu = Tcl_GetString(objv[3]); if( objc==5 ) zStateDb = Tcl_GetString(objv[4]); pRbu = sqlite3rbu_open(zTarget, zRbu, zStateDb); Tcl_CreateObjCommand(interp, zCmd, test_sqlite3rbu_cmd, (ClientData)pRbu, 0); Tcl_SetObjResult(interp, objv[1]); return TCL_OK; } /* ** Tclcmd: sqlite3rbu_vacuum CMD <target-db> <state-db> */ static int SQLITE_TCLAPI test_sqlite3rbu_vacuum( ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ sqlite3rbu *pRbu = 0; const char *zCmd; const char *zTarget; const char *zStateDb = 0; if( objc!=3 && objc!=4 ){ Tcl_WrongNumArgs(interp, 1, objv, "NAME TARGET-DB ?STATE-DB?"); return TCL_ERROR; } zCmd = Tcl_GetString(objv[1]); zTarget = Tcl_GetString(objv[2]); if( objc==4 ) zStateDb = Tcl_GetString(objv[3]); pRbu = sqlite3rbu_vacuum(zTarget, zStateDb); Tcl_CreateObjCommand(interp, zCmd, test_sqlite3rbu_cmd, (ClientData)pRbu, 0); Tcl_SetObjResult(interp, objv[1]); return TCL_OK; } /* ** Tclcmd: sqlite3rbu_create_vfs ?-default? NAME PARENT */ static int SQLITE_TCLAPI test_sqlite3rbu_create_vfs( ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ const char *zName; const char *zParent; int rc; if( objc!=3 && objc!=4 ){ Tcl_WrongNumArgs(interp, 1, objv, "?-default? NAME PARENT"); return TCL_ERROR; } zName = Tcl_GetString(objv[objc-2]); zParent = Tcl_GetString(objv[objc-1]); if( zParent[0]=='\0' ) zParent = 0; rc = sqlite3rbu_create_vfs(zName, zParent); if( rc!=SQLITE_OK ){ Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1)); return TCL_ERROR; }else if( objc==4 ){ sqlite3_vfs *pVfs = sqlite3_vfs_find(zName); sqlite3_vfs_register(pVfs, 1); } Tcl_ResetResult(interp); return TCL_OK; } /* ** Tclcmd: sqlite3rbu_destroy_vfs NAME */ static int SQLITE_TCLAPI test_sqlite3rbu_destroy_vfs( ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ const char *zName; if( objc!=2 ){ Tcl_WrongNumArgs(interp, 1, objv, "NAME"); return TCL_ERROR; } zName = Tcl_GetString(objv[1]); sqlite3rbu_destroy_vfs(zName); return TCL_OK; } /* ** Tclcmd: sqlite3rbu_internal_test */ static int SQLITE_TCLAPI test_sqlite3rbu_internal_test( ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ sqlite3 *db; if( objc!=1 ){ Tcl_WrongNumArgs(interp, 1, objv, ""); return TCL_ERROR; } db = sqlite3rbu_db(0, 0); if( db!=0 ){ Tcl_AppendResult(interp, "sqlite3rbu_db(0, 0)!=0", 0); return TCL_ERROR; } return TCL_OK; } int SqliteRbu_Init(Tcl_Interp *interp){ static struct { char *zName; Tcl_ObjCmdProc *xProc; } aObjCmd[] = { { "sqlite3rbu", test_sqlite3rbu }, { "sqlite3rbu_vacuum", test_sqlite3rbu_vacuum }, { "sqlite3rbu_create_vfs", test_sqlite3rbu_create_vfs }, { "sqlite3rbu_destroy_vfs", test_sqlite3rbu_destroy_vfs }, { "sqlite3rbu_internal_test", test_sqlite3rbu_internal_test }, }; int i; for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){ Tcl_CreateObjCommand(interp, aObjCmd[i].zName, aObjCmd[i].xProc, 0, 0); } return TCL_OK; } #else #if defined(INCLUDE_SQLITE_TCL_H) # include "sqlite_tcl.h" #else # include "tcl.h" #endif int SqliteRbu_Init(Tcl_Interp *interp){ return TCL_OK; } #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_RBU) */ #endif /* defined(SQLITE_TEST) */
the_stack_data/104922.c
#include <stdio.h> #include <string.h> struct student{ int id; char name[32]; int year; int month;int day; char home[128]; double height;double weight; char sex; //........... }; void main(void) { int i; struct student stu[10]; for(i=0;i<10;i++){ stu[i].id = 201500+i; stu[i].sex = (stu[i].id%2==0) ? 'M' :'W'; stu[i].day = i +1; } for(i=0;i<10;i++){ printf("%dst id:%d sex:%c day%d\n", i, stu[i].id,stu[i].sex,stu[i].day); } }
the_stack_data/107954066.c
#include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <unistd.h> #include <string.h> void bitout_ui8(uint8_t a){ int i; for (i = 0; i < 8; i++){ printf("%d",(a>>(7-i))&0x1); } } void usage(char* binary_name){ printf("usage: %s [-pcwv] -i filename\n",binary_name); printf("switches:\n"); printf(" -i filename - opens \"filename\"\n"); printf(" -o outfile - writes to \"outfile\"\n"); printf(" -v - verbose\n"); printf("\n"); } int main(int argc, char** argv){ char* filename = NULL; char* outfile = NULL; FILE *f; FILE *of; int c; int verbose = 0; while ((c = getopt(argc,argv,"o:i:")) != -1){ switch (c){ case 'i': filename = optarg; if (verbose > 0) printf("set in filename to: %s\n",filename); break; case 'o': outfile = optarg; if (verbose > 0) printf("set out filename to: %s\n",filename); break; default: printf("\n"); usage(argv[0]); abort(); } } if (filename == NULL){ usage(argv[0]); return 1; } if (outfile == NULL){ of = stdout; } else { if (!(of = fopen(outfile,"w"))){ printf("couldn't open outfile.\n"); return 3; } } char *outdata = (char*)malloc(2048); snprintf(outdata,2048,"<xml><appdata><name>TsAnalyzer-SubExtractor</name><version>GIT</version></appdata><data>"); fwrite(outdata,strlen(outdata),1,of); char* data = (char*)malloc(188); int chk = 0; if (!(f = fopen(filename,"r"))){ printf("couldn't open in file.\n"); return 2; } int oldsize = ftell(f); //sync to syncbyte while (!feof(f) && chk != 0x47){ chk = fgetc(f); } int newsize = ftell(f); if (oldsize != newsize) { fseek(f,-1,SEEK_CUR); oldsize--; } if (feof(f)){ fclose(f); printf("EOF before hitting mainloop.\n"); return 3; } while (!feof(f)){ uint8_t pos = 0; fread(data,188,1,f); uint16_t PID = (data[1] & 0x1F) << 8 | (data[2] & 0xff); uint8_t PUSI = (data[1] & 0x40) >> 6; uint8_t AFC = (data[3] & 0x30) >> 4; pos = pos + 4; if (AFC == 0x02 || AFC == 0x03){ pos = pos + data[pos] + 1; } if (PUSI == 0x01 && (((data[pos] << 16) & 0xFF0000) | ((data[pos+1] << 8) & 0xFF00) | (data[pos+2] & 0xFF)) == 0x000001) { uint32_t i; uint8_t SID = (data[pos+3]); uint16_t orig_PPL = ((data[pos+4] & 0xFF00) << 8) | (data[pos+5] & 0xFF); uint16_t PPL = orig_PPL; pos = pos + 6; if (SID != 0xBD) continue; if (SID != 0x00) { uint8_t PTSDTSF = (data[pos+1] & 0xC0) >> 6; uint8_t ESCRF = (data[pos+1] & 0x20) >> 5; uint8_t ESRF = (data[pos+1] & 0x10) >> 4; uint8_t DSMTMF = (data[pos+1] & 0x08) >> 3; uint8_t ACIF = (data[pos+1] & 0x04) >> 2; uint8_t PESCRCF = (data[pos+1] & 0x02) >> 1; uint8_t PESEF = (data[pos+1] & 0x01); uint8_t PESHDL = data[pos+2]; pos = pos + 3; PPL = PPL - 3; snprintf(outdata,2048,"\n<PES><PID>%02X</PID>",PID); if (PTSDTSF == 0x2){ snprintf(outdata,2048,"\n<PES><PID>%02X</PID><DTS>%02X%02X%02X%02X%02X</DTS>",PID,(uint8_t)data[pos],(uint8_t)data[pos+1],(uint8_t)data[pos+2],(uint8_t)data[pos+3],(uint8_t)data[pos+4]); pos = pos + 5; // 40 bit PPL = PPL - 5; PESHDL = PESHDL - 5; } if (PTSDTSF == 0x3){ pos = pos + 10; // 80 bit PPL = PPL - 10; PESHDL = PESHDL - 10; } if (ESCRF == 0x1){ pos = pos + 6; // 48 bit PPL = PPL - 6; PESHDL = PESHDL - 6; } if (ESRF == 0x1){ pos = pos + 3; // 24 bit PPL = PPL - 3; PESHDL = PESHDL - 3; } if (DSMTMF == 0x1){ pos = pos + 1; // 8 bit PPL = PPL - 1; PESHDL = PESHDL - 1; } if (ACIF == 0x1){ pos = pos + 1; // 8 bit PPL = PPL - 1; PESHDL = PESHDL - 1; } if (PESCRCF == 0x1){ pos = pos + 2; // 16 bit PPL = PPL - 2; PESHDL = PESHDL - 2; } if (PESEF == 0x1){ uint8_t PESPDF = (data[pos] & 0x80) >> 7; uint8_t PHFF = (data[pos] & 0x40) >> 6; uint8_t PPSCF = (data[pos] & 0x20) >> 5; uint8_t PSTDBF = (data[pos] & 0x10) >> 4; uint8_t PESEF2 = data[pos] & 0x01; pos++; PESHDL = PESHDL - 1; PPL = PPL - 1; if (PESPDF == 0x01){ pos = pos + 16; PPL = PPL - 16; PESHDL = PESHDL - 16; } if (PHFF == 0x01){ PPL = PPL - 1 - data[pos]; PESHDL = PESHDL - 1 - data[pos]; pos = pos + data[pos] + 1; } if (PPSCF == 0x01){ pos = pos + 2; PPL = PPL - 2; PESHDL = PESHDL - 2; } if (PSTDBF == 0x01){ pos = pos + 2; PPL = PPL - 2; PESHDL = PESHDL - 2; } if (PESEF2 == 0x01){ uint8_t PEFL = data[pos] & 0x7F; uint8_t SIDEF = data[pos+1] & 0xF0 >> 7; pos = pos + 2; PPL = PPL - 2; PESHDL = PESHDL - 2; if (SIDEF == 0x0){ pos = pos + PEFL; PPL = PPL - PEFL; PESHDL = PESHDL - PEFL; } } } for (i = 0; PESHDL>0; i++) {pos++; PPL--; PESHDL--; } uint8_t data_group_id = (data[pos] & 0xFC) >> 2; //printf("pos: %d PESHDL %d PPL: %d\n",pos,PESHDL,PPL); pos = pos + 3; PPL = PPL - 3; if (data_group_id != 0x20){ //snprintf(outdata,2048,"<TYPE>INVALID-PRE-DG-TYPE %02X</TYPE></DG></PES>",data_group_id); //fwrite(outdata,strlen(outdata),1,of); continue; } data_group_id = (data[pos] & 0xFC) >> 2; if ( (data_group_id > 0x08 && data_group_id < 0x20) || (data_group_id > 0x28) ){ //snprintf(outdata,2048,"<TYPE>INVALID-TYPE %02X</TYPE></DG></PES>",data_group_id); //fwrite(outdata,strlen(outdata),1,of); continue; } uint16_t data_group_size = ((data[pos+3] << 8) & 0xFF00) | (data[pos+4] & 0xFF); pos = pos + 5; PPL = PPL - 5; if (data_group_size > PPL){ //snprintf(outdata,2048,"<TYPE>PPL-INVALID</TYPE></DG></PES>"); //fwrite(outdata,strlen(outdata),1,of); continue; } char* closetag = malloc(2*sizeof(char)); if (data_group_id == 0x0 || data_group_id == 0x20) { fwrite(outdata,strlen(outdata),1,of); snprintf(outdata,2048,"<DG><TYPE>CAPTION MANAGEMENT</TYPE>"); fwrite(outdata,strlen(outdata),1,of); sprintf(closetag,"CM"); uint8_t TMD = (data[pos] & 0xC0) >> 6; uint8_t reserved1 = data[pos] & 0x3F; pos++; snprintf(outdata,2048,"<CM><TMD>%02X</TMD>",(uint8_t)TMD); fwrite(outdata,strlen(outdata),1,of); //printf("(ARIB-CM): TMD: %X | reserved1: %X | ",TMD,reserved1); if (TMD == 0x1 || TMD == 0x02){ snprintf(outdata,2048,"<OTM>%02X%02X%02X%02X%02X</OTM>",(uint8_t)data[pos+0],(uint8_t)data[pos+1],(uint8_t)data[pos+2],(uint8_t)data[pos+3],(uint8_t)data[pos+4]); fwrite(outdata,strlen(outdata),1,of); pos=pos+5; } uint8_t numlang = data[pos]; snprintf(outdata,2048,"<NUMLANG>%02X</NUMLANG>",(uint8_t)data[pos]); fwrite(outdata,strlen(outdata),1,of); pos++; for (i = 0; i < numlang; i++){ uint8_t DMF = data[pos] & 0x0F; pos++; if (DMF == 0x0C || DMF == 0x0D || DMF == 0x0E){ pos++; } snprintf(outdata,2048,"<LANG>%c%c%c</LANG>",(uint8_t)data[pos],(uint8_t)data[pos+1],(uint8_t)data[pos+2]); fwrite(outdata,strlen(outdata),1,of); pos = pos + 3; pos++; } } else { fwrite(outdata,strlen(outdata),1,of); snprintf(outdata,2048,"<DG><TYPE>CAPTION STATEMENT</TYPE>"); fwrite(outdata,strlen(outdata),1,of); sprintf(closetag,"CS"); uint8_t TMD = (data[pos] & 0xC0) >> 6; pos++; snprintf(outdata,2048,"<CS><TMD>%02X</TMD>",(uint8_t)TMD); fwrite(outdata,strlen(outdata),1,of); if (TMD == 0x1 || TMD == 0x02){ snprintf(outdata,2048,"<STM>%02X%02X%02X%02X%02X</STM>",(uint8_t)data[pos+0],(uint8_t)data[pos+1],(uint8_t)data[pos+2],(uint8_t)data[pos+3],(uint8_t)data[pos+4]); fwrite(outdata,strlen(outdata),1,of); pos=pos+5; } } uint32_t dull = ((data[pos] << 16) & 0xFF0000) | ((data[pos+1] << 8) & 0xFF00) | (data[pos+2] & 0xFF); uint32_t dullcounter = dull; snprintf(outdata,2048,"<LEN>%02X%02X%02X</LEN>",(uint8_t)data[pos+0],(uint8_t)data[pos+1],(uint8_t)data[pos+2]); fwrite(outdata,strlen(outdata),1,of); pos = pos + 3; PPL = PPL - 3; while (dullcounter != 0){ uint8_t oldpos = pos; uint32_t data_unit_size = (((data[pos+2] & 0x0000FF) << 16) | ((data[pos+3] & 0x00FF) << 8) | ((data[pos+4] & 0xFF) << 0)); //uint32_t data_unit_size = ((data[pos+2] << 16) & 0x0000FF) | ((data[pos+3] << 8) & 0x00FF) | (data[pos+4] & 0xFF); if (data_unit_size > 188 || data_unit_size > PPL){ if (dullcounter < data_unit_size) dullcounter=0; else dullcounter = dullcounter - data_unit_size; continue; } memset(outdata,0,(2048)); snprintf(outdata,2048,"<DU><DUP>%02X</DUP><LEN>%02X%02X%02X|%08X</LEN><DATA>",data[pos+1],data[pos+2],data[pos+3],data[pos+4],data_unit_size); fwrite(outdata,strlen(outdata),1,of); pos = pos + 5; for (i = 0; i < data_unit_size; i++){ sprintf(outdata,"%02X",(uint8_t)data[pos]); fwrite(outdata,strlen(outdata),1,of); pos++; } snprintf(outdata,2048,"</DATA></DU>"); fwrite(outdata,strlen(outdata),1,of); dullcounter = dullcounter - (pos - oldpos); } snprintf(outdata,2048,"</%s></DG></PES>",closetag); fwrite(outdata,strlen(outdata),1,of); } } } snprintf(outdata,2048,"\n</data></xml>\n"); fwrite(outdata,strlen(outdata),1,of); fflush(of); if (of != stdout) fclose(of); fclose(f); return 0; }
the_stack_data/84397.c
/*********************************************************************/ /* Copyright 2009, 2010 The University of Texas at Austin. */ /* All rights reserved. */ /* */ /* Redistribution and use in source and binary forms, with or */ /* without modification, are permitted provided that the following */ /* conditions are met: */ /* */ /* 1. Redistributions of source code must retain the above */ /* copyright notice, this list of conditions and the following */ /* disclaimer. */ /* */ /* 2. Redistributions in binary form must reproduce the above */ /* copyright notice, this list of conditions and the following */ /* disclaimer in the documentation and/or other materials */ /* provided with the distribution. */ /* */ /* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF TEXAS AT */ /* AUSTIN ``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 UNIVERSITY OF TEXAS AT */ /* AUSTIN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */ /* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */ /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE */ /* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR */ /* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */ /* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */ /* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */ /* POSSIBILITY OF SUCH DAMAGE. */ /* */ /* The views and conclusions contained in the software and */ /* documentation are those of the authors and should not be */ /* interpreted as representing official policies, either expressed */ /* or implied, of The University of Texas at Austin. */ /*********************************************************************/ #include <stdio.h> int sgemm_tcopy_4(long m, long n, float *a, long lda, float *b) { long i, j; float *a_offset, *a_offset1, *a_offset2, *a_offset3, *a_offset4; float *b_offset, *b_offset1, *b_offset2, *b_offset3; float ctemp1, ctemp2, ctemp3, ctemp4; float ctemp5, ctemp6, ctemp7, ctemp8; float ctemp9, ctemp10, ctemp11, ctemp12; float ctemp13, ctemp14, ctemp15, ctemp16; a_offset = a; b_offset = b; b_offset2 = b + m * (n & ~3); b_offset3 = b + m * (n & ~1); j = (m >> 2); if (j > 0) { do { a_offset1 = a_offset; a_offset2 = a_offset1 + lda; a_offset3 = a_offset2 + lda; a_offset4 = a_offset3 + lda; a_offset += 4 * lda; b_offset1 = b_offset; b_offset += 16; i = (n >> 2); if (i > 0) { do { ctemp1 = *(a_offset1 + 0); ctemp2 = *(a_offset1 + 1); ctemp3 = *(a_offset1 + 2); ctemp4 = *(a_offset1 + 3); ctemp5 = *(a_offset2 + 0); ctemp6 = *(a_offset2 + 1); ctemp7 = *(a_offset2 + 2); ctemp8 = *(a_offset2 + 3); ctemp9 = *(a_offset3 + 0); ctemp10 = *(a_offset3 + 1); ctemp11 = *(a_offset3 + 2); ctemp12 = *(a_offset3 + 3); ctemp13 = *(a_offset4 + 0); ctemp14 = *(a_offset4 + 1); ctemp15 = *(a_offset4 + 2); ctemp16 = *(a_offset4 + 3); a_offset1 += 4; a_offset2 += 4; a_offset3 += 4; a_offset4 += 4; *(b_offset1 + 0) = ctemp1; *(b_offset1 + 1) = ctemp2; *(b_offset1 + 2) = ctemp3; *(b_offset1 + 3) = ctemp4; *(b_offset1 + 4) = ctemp5; *(b_offset1 + 5) = ctemp6; *(b_offset1 + 6) = ctemp7; *(b_offset1 + 7) = ctemp8; *(b_offset1 + 8) = ctemp9; *(b_offset1 + 9) = ctemp10; *(b_offset1 + 10) = ctemp11; *(b_offset1 + 11) = ctemp12; *(b_offset1 + 12) = ctemp13; *(b_offset1 + 13) = ctemp14; *(b_offset1 + 14) = ctemp15; *(b_offset1 + 15) = ctemp16; b_offset1 += m * 4; i--; } while (i > 0); } if (n & 2) { ctemp1 = *(a_offset1 + 0); ctemp2 = *(a_offset1 + 1); ctemp3 = *(a_offset2 + 0); ctemp4 = *(a_offset2 + 1); ctemp5 = *(a_offset3 + 0); ctemp6 = *(a_offset3 + 1); ctemp7 = *(a_offset4 + 0); ctemp8 = *(a_offset4 + 1); a_offset1 += 2; a_offset2 += 2; a_offset3 += 2; a_offset4 += 2; *(b_offset2 + 0) = ctemp1; *(b_offset2 + 1) = ctemp2; *(b_offset2 + 2) = ctemp3; *(b_offset2 + 3) = ctemp4; *(b_offset2 + 4) = ctemp5; *(b_offset2 + 5) = ctemp6; *(b_offset2 + 6) = ctemp7; *(b_offset2 + 7) = ctemp8; b_offset2 += 8; } if (n & 1) { ctemp1 = *(a_offset1 + 0); ctemp2 = *(a_offset2 + 0); ctemp3 = *(a_offset3 + 0); ctemp4 = *(a_offset4 + 0); *(b_offset3 + 0) = ctemp1; *(b_offset3 + 1) = ctemp2; *(b_offset3 + 2) = ctemp3; *(b_offset3 + 3) = ctemp4; b_offset3 += 4; } j--; } while (j > 0); } if (m & 2) { a_offset1 = a_offset; a_offset2 = a_offset1 + lda; a_offset += 2 * lda; b_offset1 = b_offset; b_offset += 8; i = (n >> 2); if (i > 0) { do { ctemp1 = *(a_offset1 + 0); ctemp2 = *(a_offset1 + 1); ctemp3 = *(a_offset1 + 2); ctemp4 = *(a_offset1 + 3); ctemp5 = *(a_offset2 + 0); ctemp6 = *(a_offset2 + 1); ctemp7 = *(a_offset2 + 2); ctemp8 = *(a_offset2 + 3); a_offset1 += 4; a_offset2 += 4; *(b_offset1 + 0) = ctemp1; *(b_offset1 + 1) = ctemp2; *(b_offset1 + 2) = ctemp3; *(b_offset1 + 3) = ctemp4; *(b_offset1 + 4) = ctemp5; *(b_offset1 + 5) = ctemp6; *(b_offset1 + 6) = ctemp7; *(b_offset1 + 7) = ctemp8; b_offset1 += m * 4; i--; } while (i > 0); } if (n & 2) { ctemp1 = *(a_offset1 + 0); ctemp2 = *(a_offset1 + 1); ctemp3 = *(a_offset2 + 0); ctemp4 = *(a_offset2 + 1); a_offset1 += 2; a_offset2 += 2; *(b_offset2 + 0) = ctemp1; *(b_offset2 + 1) = ctemp2; *(b_offset2 + 2) = ctemp3; *(b_offset2 + 3) = ctemp4; b_offset2 += 4; } if (n & 1) { ctemp1 = *(a_offset1 + 0); ctemp2 = *(a_offset2 + 0); *(b_offset3 + 0) = ctemp1; *(b_offset3 + 1) = ctemp2; b_offset3 += 2; } } if (m & 1) { a_offset1 = a_offset; b_offset1 = b_offset; i = (n >> 2); if (i > 0) { do { ctemp1 = *(a_offset1 + 0); ctemp2 = *(a_offset1 + 1); ctemp3 = *(a_offset1 + 2); ctemp4 = *(a_offset1 + 3); a_offset1 += 4; *(b_offset1 + 0) = ctemp1; *(b_offset1 + 1) = ctemp2; *(b_offset1 + 2) = ctemp3; *(b_offset1 + 3) = ctemp4; b_offset1 += 4 * m; i--; } while (i > 0); } if (n & 2) { ctemp1 = *(a_offset1 + 0); ctemp2 = *(a_offset1 + 1); a_offset1 += 2; *(b_offset2 + 0) = ctemp1; *(b_offset2 + 1) = ctemp2; } if (n & 1) { ctemp1 = *(a_offset1 + 0); *(b_offset3 + 0) = ctemp1; } } return 0; }
the_stack_data/150139735.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_str_is_numeric.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: mmasstou <[email protected]> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/06/30 16:47:10 by mmasstou #+# #+# */ /* Updated: 2021/07/07 10:03:29 by mmasstou ### ########.fr */ /* */ /* ************************************************************************** */ int ft_str_is_numeric(char *str) { int index; index = 0; if (*(str + index) == '\0') return (1); while (*(str + index) != '\0') { if (!(*(str + index) >= 48 && *(str + index) <= 57)) return (0); index++; } return (1); }
the_stack_data/898572.c
extern int expect(int, int); extern int externvar1; int extern externvar2; int main() { expect(98, externvar1); expect(99, externvar2); }
the_stack_data/202601.c
#include <stdio.h> #include <stdlib.h> unsigned long long maximum = 0; int main(){ unsigned long blocksize[] = {1024 * 1024 * 1024, 1024 * 1024, 1024, 1}; int i, count; for(i = 0; i< 3; i++){ for(count = 1;;count++){ void *block = malloc(maximum + blocksize[i] * count); if(block) { maximum = maximum + blocksize[i] * count; free(block); }else{ break; } } } printf("maximum malloc size = %llu bytes\n", maximum); }
the_stack_data/43197.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strncmp.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: lutsiara <[email protected]> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2018/11/09 14:37:35 by lutsiara #+# #+# */ /* Updated: 2019/03/13 16:23:18 by lutsiara ### ########.fr */ /* */ /* ************************************************************************** */ int ft_strncmp(const char *s1, const char *s2, unsigned long n) { if (!n) return (0); while (--n && *s1 && *s2) { if ((unsigned char)(*s1) != (unsigned char)(*s2)) return ((int)((unsigned char)(*s1) - (unsigned char)(*s2))); s1++; s2++; } return ((int)((unsigned char)(*s1) - (unsigned char)(*s2))); }
the_stack_data/867178.c
#include <stdio.h> #include <math.h> void insertion_sort(int arr_size, int *arr) { // Fuction to do insertion sort. int i; int pivot; int j; for (i = 1; i < arr_size; i++) { pivot = arr[i]; j = i-1; /* Move elements of arr[0..i-1], that are greater than pivot, to one position ahead of their current position */ while (j >= 0 && arr[j] > pivot) { arr[j+1] = arr[j]; j = j-1; } arr[j+1] = pivot; } } int main() { int arr_size = 6, i; int arr[6] = {6, 5, 4, 3, 2, 1}; insertion_sort(arr_size, arr); for (i=0; i<arr_size; i++) { printf("%d\n", arr[i]); } return 0; }
the_stack_data/72013088.c
// Polynomial Multiplication using singly linked list // Takes in coeffients and powers of two expressions as input, and diplays them in polynomial form and also displays the product in polynomial form #include <stdio.h> #include <stdlib.h> #include<math.h> struct poly{ int coeff,power; struct poly* link; // Defining structure - polynomial expression }; // Declaring pointers struct poly* temp = NULL; // used for traversal during display struct poly* PPTR = NULL; // used for expression 1 traversal struct poly* QPTR = NULL; // used for expression 2 traversal struct poly* RPTR = NULL; // used for product expression int insert_exp(struct poly ** header,int coef,int expo){ // insertion of each input expression term struct poly* new = (struct poly *)malloc(sizeof(struct poly)); new->coeff = coef; new->power = expo; if(header==NULL){ header = new; } else{ temp = header; while(temp->link!=NULL) // insertion at end is followed to keep tab of order of input and for proper display { temp = temp->link; } temp -> link = new; new = temp; } } void disp_exp(struct poly* header){ // Using recursion temp = header->link; if(header->link==0) return; if(temp->power == 1) printf("+ %dx ",temp->coeff); else if(temp->power == 0) printf("+ %d ",temp->coeff); else printf("+ %dx^%d ",temp->coeff,temp->power); disp_exp(header->link); } void multiply(struct poly* pheader, struct poly* qheader){ struct poly* rheader = (struct poly *)malloc(sizeof(struct poly)); rheader->link = NULL; rheader->coeff = NULL; rheader->power = NULL; struct poly * RPTR1 = NULL; if(pheader == NULL || qheader == NULL) printf("Not possible"); PPTR = pheader->link; while(PPTR != NULL){ QPTR = qheader->link; while (QPTR != NULL){ int c = PPTR->coeff * QPTR->coeff; // Operation int e = PPTR->power + QPTR->power; RPTR = rheader->link; RPTR1 = rheader; while(RPTR != NULL && RPTR->power>e){ // Insertion of values into product linked list RPTR1 = RPTR; RPTR = RPTR->link; } if(RPTR != NULL && RPTR->power == e){ RPTR->coeff = RPTR->coeff+c; } else{ struct poly* new = (struct poly *)malloc(sizeof(struct poly)); new->power = e; new->coeff = c; new->link = RPTR1->link; RPTR1->link = new; } QPTR = QPTR->link; } PPTR = PPTR->link; } disp_exp(rheader); } int main() { struct poly* pheader = (struct poly *)malloc(sizeof(struct poly)); struct poly* qheader = (struct poly *)malloc(sizeof(struct poly)); pheader->link = NULL; pheader->coeff = NULL; pheader->power = NULL; qheader->link = NULL; qheader->coeff = NULL; qheader->power = NULL; printf("\t\t\t\tPOLYNOMIAL MULTIPLICATION"); int coef,expo,p1,p2,i; printf("\nEnter number of terms in polynomial 1: "); scanf("%d",&p1); printf("\nEnter terms in descending order of powers!"); for(i=1;i<=p1;i++){ printf("\nEnter coefficient of term %d :", i); scanf("%d", &coef); printf("Enter exponent:"); scanf("%d",&expo); insert_exp(pheader,coef,expo); } printf("\nExpression 1: "); disp_exp(pheader); printf("\nEnter number of terms in polynomial 2: "); scanf("%d",&p2); printf("\nEnter terms in descending order of powers!"); for(i=1;i<=p2;i++){ printf("\nEnter coefficient of term %d :", i); scanf("%d", &coef); printf("Enter exponent:"); scanf("%d",&expo); insert_exp(qheader,coef,expo); } printf("\nExpression 2: "); disp_exp(qheader); printf("\nProduct expression: "); multiply(pheader,qheader); }
the_stack_data/633823.c
#include <stdio.h> #include <string.h> #define BUFFER_SIZE 65536 static char sn_buf[BUFFER_SIZE]; int vsnprintf(char *s, size_t n,const char *fmt, va_list ap) { int rv; int bytes; if(n > BUFFER_SIZE ) return 0; rv = vsprintf(sn_buf, fmt, ap); if(rv >= BUFFER_SIZE ) return BUFFER_SIZE; // "snprintf buffer overflow" bytes = rv; if (bytes > 0) { memcpy(s, sn_buf, bytes); s[bytes] = '\0'; } return (rv); }
the_stack_data/3261744.c
#include<stdio.h> int main(){ float celsius,fahrenheit; //Taking input in fahrenheit printf("\nEnter temperature in Fahrenheit: "); scanf("%f",&fahrenheit); //Formula to convert temperature in fahrenheit to celcius celsius=(fahrenheit - 32)*5/9; //printing the temperature in celcius printf("\nCelsius = %.3f\n",celsius); return 0; }
the_stack_data/5254.c
#include <stdint.h> #include <string.h> #include <stdio.h> #include <sys/time.h> #include <sys/resource.h> double get_time() { struct timeval t; struct timezone tzp; gettimeofday(&t, &tzp); return t.tv_sec + t.tv_usec*1e-6; } unsigned int feld_rotl(const unsigned int value, int shift) { if ((shift &= sizeof(value) * 8 - 1) == 0) return value; return value << shift | value >> sizeof(value) * 8 - shift; } uint8_t *sha1() { uint8_t _a0[] = {84, 104, 101, 32, 113, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110, 32, 102, 111, 120, 32, 106, 117, 109, 112, 115, 32, 111, 118, 101, 114, 32, 116, 104, 101, 32, 108, 97, 122, 121, 32, 100, 111, 103}; uint8_t *a0 = _a0; uint64_t r1; uint8_t _a2[64]; uint8_t *a2 = _a2; uint8_t v3; uint8_t v4; uint32_t _a5[80]; uint32_t *a5 = _a5; uint8_t v6; uint8_t v7; uint32_t r8; uint32_t r9; uint32_t r10; uint32_t r11; uint32_t r12; uint32_t r13; uint32_t r14; uint32_t r15; uint32_t r16; uint32_t r17; uint8_t v18; uint8_t _a26[20]; uint8_t *a26 = _a26; uint8_t v27; uint8_t v28; uint8_t v29; uint8_t v30; uint8_t v31; r1 = (uint64_t) 43 * 8; memcpy(a2, a0, 43 * sizeof(uint8_t)); a2[43 + 0] = 1; for (v3 = 43 + 1; v3 <= 55; v3++) { a2[v3 + 0] = 0; } for (v4 = 56; v4 <= 63; v4++) { a2[v4 + 0] = (uint8_t) (r1 >> 8 * (63 - (uint32_t) v4)); } for (v6 = 0; v6 <= 15; v6++) { a5[v6 + 0] = (uint32_t) a2[v6 * 4 + 0] + ((uint32_t) a2[v6 * 4 + 1 + 0] << 8) + ((uint32_t) a2[v6 * 4 + 2 + 0] << 16) + ((uint32_t) a2[v6 * 4 + 3 + 0] << 24); } for (v7 = 16; v7 <= 79; v7++) { a5[v7 + 0] = feld_rotl(((a5[v7 - 3 + 0] ^ a5[v7 - 8 + 0]) ^ a5[v7 - 14 + 0]) ^ a5[v7 - 16 + 0], 1); } r8 = 1732584193; r9 = 4023233417; r10 = 2562383102; r11 = 271733878; r12 = 3285377520; r13 = r8; r14 = r9; r15 = r10; r16 = r11; r17 = r12; for (v18 = 0; v18 <= 79; v18++) { uint32_t b19; uint32_t b22; uint32_t r25; if (0 <= v18 && v18 <= 19) { b19 = (r14 & r15) | (~r14 & r16); } else { uint32_t b20; if (20 <= v18 && v18 <= 39) { b20 = (r14 ^ r15) ^ r16; } else { uint32_t b21; if (40 <= v18 && v18 <= 59) { b21 = (r14 & r15) | (r14 & r16) | (r15 & r16); } else { b21 = (r14 ^ r15) ^ r16; } b20 = b21; } b19 = b20; } if (0 <= v18 && v18 <= 19) { b22 = 1518500249; } else { uint32_t b23; if (20 <= v18 && v18 <= 39) { b23 = 1859775393; } else { uint32_t b24; if (40 <= v18 && v18 <= 59) { b24 = 2400959708; } else { b24 = 3395469782; } b23 = b24; } b22 = b23; } r25 = feld_rotl(r13, 5) + b19 + r17 + a5[v18 + 0] + b22; r17 = r16; r16 = r15; r15 = feld_rotl(r14, 30); r14 = r13; r13 = r25; } r8 = r8 + r13; r9 = r9 + r14; r10 = r10 + r15; r11 = r11 + r16; r12 = r12 + r17; for (v27 = 0; v27 <= 3; v27++) { a26[v27 + 0] = (uint8_t) (r8 >> 8 * (3 - (uint32_t) v27)); } for (v28 = 0; v28 <= 3; v28++) { a26[v28 + 4 + 0] = (uint8_t) (r9 >> 8 * (3 - (uint32_t) v28)); } for (v29 = 0; v29 <= 3; v29++) { a26[v29 + 8 + 0] = (uint8_t) (r10 >> 8 * (3 - (uint32_t) v29)); } for (v30 = 0; v30 <= 3; v30++) { a26[v30 + 12 + 0] = (uint8_t) (r11 >> 8 * (3 - (uint32_t) v30)); } for (v31 = 0; v31 <= 3; v31++) { a26[v31 + 16 + 0] = (uint8_t) (r12 >> 8 * (3 - (uint32_t) v31)); } return a26; } int main() { uint16_t iter; double before = get_time(); for (iter = 1; iter <= 1000; iter++) { sha1(); } double diff = get_time() - before; printf("%f\n", diff); return 0; }
the_stack_data/1005200.c
/** * @file * * @date May 29, 2014 * @author: Anton Bondarev */ #include <errno.h> #include <unistd.h> #include <sys/types.h> #include <sys/uio.h> void syslog(int prio, const char *format, ...) { } void openlog(const char *ident, int option, int facility) { } int dn_expand(unsigned char *msg, unsigned char *eomorig, unsigned char *comp_dn, char *exp_dn, int length) { return -1; } int res_query(const char *dname, int class, int type, unsigned char *answer, int anslen) { return -1; } char *mktemp(char *template) { if (template) { *template = 0; } return template; } unsigned int alarm(unsigned int seconds) { return 0; } ssize_t readv(int fd, const struct iovec *iov, int iovcnt) { errno = ENOSYS; return -1; } ssize_t writev(int fd, const struct iovec *iov, int iovcnt) { int i; size_t bw = 0; for(i=0; i<iovcnt; i++) { int res; if (iov[i].iov_len) { res = write(fd, iov[i].iov_base, iov[i].iov_len); } else { res = 0; } if (res<0) { return -1; } if (res != iov[i].iov_len) { errno = EIO; return -1; } bw += res; } return bw; } #include <dirent.h> void seekdir(DIR *dirp, long offset) { } long telldir(DIR *dirp) { errno = EPERM; return -1; } void setgrent(void) { } struct group *getgrent(void) { errno = EPERM; return 0; } void endgrent(void) { } int fnmatch(const char *pattern, const char *string, int flags) { return -1; } void atexit(void *addr) { } int fork(void) { return -1; }
the_stack_data/512046.c
/* * Copyright 2020 u-blox * * 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. */ /* Only #includes of u_* and the C standard library are allowed here, * no platform stuff and no OS stuff. Anything required from * the platform/OS must be brought in through u_port* to maintain * portability. */ /** @file * @brief Tests for the cellular power API: these should pass on all * platforms that have a cellular module connected to them. They * are only compiled if U_CFG_TEST_CELL_MODULE_TYPE is defined. * IMPORTANT: see notes in u_cfg_test_platform_specific.h for the * naming rules that must be followed when using the U_PORT_TEST_FUNCTION() * macro. */ #ifdef U_CFG_TEST_CELL_MODULE_TYPE # ifdef U_CFG_OVERRIDE # include "u_cfg_override.h" // For a customer's configuration override # endif #include "stddef.h" // NULL, size_t etc. #include "stdint.h" // int32_t etc. #include "stdbool.h" #include "u_cfg_sw.h" #include "u_cfg_os_platform_specific.h" #include "u_cfg_app_platform_specific.h" #include "u_cfg_test_platform_specific.h" #include "u_error_common.h" #include "u_port.h" #include "u_port_debug.h" #include "u_port_os.h" // Required by u_cell_private.h #include "u_port_uart.h" #include "u_at_client.h" #include "u_cell_module_type.h" #include "u_cell.h" #include "u_cell_net.h" // Required by u_cell_private.h #include "u_cell_private.h" // So that we can get at some innards #include "u_cell_pwr.h" #include "u_cell_test_cfg.h" #include "u_cell_test_private.h" /* ---------------------------------------------------------------- * COMPILE-TIME MACROS * -------------------------------------------------------------- */ /* ---------------------------------------------------------------- * TYPES * -------------------------------------------------------------- */ /* ---------------------------------------------------------------- * VARIABLES * -------------------------------------------------------------- */ /** Used for keepGoingCallback() timeout. */ static int64_t gStopTimeMs; /** Handles. */ static uCellTestPrivate_t gHandles = U_CELL_TEST_PRIVATE_DEFAULTS; /** A variable to track errors in the callbacks. */ static int32_t gCallbackErrorCode = 0; /** For tracking heap lost to allocations made * by the C library in new tasks: newlib does NOT * necessarily reclaim it on task deletion. */ static size_t gSystemHeapLost = 0; /* ---------------------------------------------------------------- * STATIC FUNCTIONS * -------------------------------------------------------------- */ // Callback function for the cellular power-down process static bool keepGoingCallback(int32_t cellHandle) { bool keepGoing = true; if (cellHandle != gHandles.cellHandle) { gCallbackErrorCode = 1; } if (uPortGetTickTimeMs() > gStopTimeMs) { keepGoing = false; } return keepGoing; } # if U_CFG_APP_PIN_CELL_PWR_ON >= 0 // Test power on/off and aliveness, parameterised by the VInt pin. static void testPowerAliveVInt(uCellTestPrivate_t *pHandles, int32_t pinVint) { bool (*pKeepGoingCallback) (int32_t) = NULL; int32_t cellHandle; bool trulyHardPowerOff = false; const uCellPrivateModule_t *pModule; # if U_CFG_APP_PIN_CELL_VINT < 0 int64_t timeMs; # endif # if U_CFG_APP_PIN_CELL_ENABLE_POWER >= 0 //lint -e(838) Suppress previously assigned value has not been used trulyHardPowerOff = true; # endif uPortLog("U_CELL_PWR_TEST: running power-on and alive tests"); if (pinVint >= 0) { uPortLog(" with VInt on pin %d.\n", pinVint); } else { uPortLog(" without VInt.\n"); } uPortLog("U_CELL_PWR_TEST: adding a cellular instance on the AT client...\n"); pHandles->cellHandle = uCellAdd(U_CFG_TEST_CELL_MODULE_TYPE, pHandles->atClientHandle, U_CFG_APP_PIN_CELL_ENABLE_POWER, U_CFG_APP_PIN_CELL_PWR_ON, pinVint, false); U_PORT_TEST_ASSERT(pHandles->cellHandle >= 0); cellHandle = pHandles->cellHandle; // Get the private module data as we need it for testing pModule = pUCellPrivateGetModule(cellHandle); U_PORT_TEST_ASSERT(pModule != NULL); //lint -esym(613, pModule) Suppress possible use of NULL pointer // for pModule from now on // Let the module state settle in case it is on but still // booting uPortTaskBlock((pModule->bootWaitSeconds) * 1000); // If the module is on at the start, switch it off. if (uCellPwrIsAlive(cellHandle)) { uPortLog("U_CELL_PWR_TEST: powering off to begin test.\n"); uCellPwrOff(cellHandle, NULL); uPortLog("U_CELL_PWR_TEST: power off completed.\n"); # if U_CFG_APP_PIN_CELL_VINT < 0 uPortLog("U_CELL_PWR_TEST: waiting another %d second(s)" " to be sure of a clean power off as there's" " no VInt pin to tell us...\n", pModule->powerDownWaitSeconds); uPortTaskBlock(pModule->powerDownWaitSeconds); # endif } // Do this twice so as to check transiting from // a call to uCellPwrOff() back to a call to uCellPwrOn(). for (size_t x = 0; x < 2; x++) { uPortLog("U_CELL_PWR_TEST: testing power-on and alive calls"); if (x > 0) { uPortLog(" with a callback passed to uCellPwrOff(), and" " a %d second power-off timer, iteration %d.\n", pModule->powerDownWaitSeconds, x + 1); } else { uPortLog(" with cellPwrOff(NULL), iteration %d.\n", x + 1); } U_PORT_TEST_ASSERT(!uCellPwrIsAlive(cellHandle)); # if U_CFG_APP_PIN_CELL_ENABLE_POWER >= 0 U_PORT_TEST_ASSERT(!uCellPwrIsPowered(cellHandle)); # endif // TODO Note: only use a NULL PIN as we don't support anything // else at least that's the case on SARA-R4 when you want to // have power saving uPortLog("U_CELL_PWR_TEST: powering on...\n"); U_PORT_TEST_ASSERT(uCellPwrOn(cellHandle, U_CELL_TEST_CFG_SIM_PIN, NULL) == 0); uPortLog("U_CELL_PWR_TEST: checking that module is alive...\n"); U_PORT_TEST_ASSERT(uCellPwrIsAlive(cellHandle)); // Give the module time to sort itself out uPortLog("U_CELL_PWR_TEST: waiting %d second(s) before powering off...\n", pModule->minAwakeTimeSeconds); uPortTaskBlock(pModule->minAwakeTimeSeconds * 1000); # if U_CFG_APP_PIN_CELL_VINT < 0 timeMs = uPortGetTickTimeMs(); # endif // Test with and without a keep-going callback if (x > 0) { // Note: can't check if keepGoingCallback is being // called here as we've no control over how long the // module takes to power off. pKeepGoingCallback = keepGoingCallback; gStopTimeMs = uPortGetTickTimeMs() + (((int64_t) pModule->powerDownWaitSeconds) * 1000); } // Give the module time to sort itself out uPortLog("U_CELL_PWR_TEST: waiting %d second(s) before powering off...\n", pModule->minAwakeTimeSeconds); uPortTaskBlock(pModule->minAwakeTimeSeconds * 1000); # if U_CFG_APP_PIN_CELL_VINT < 0 timeMs = uPortGetTickTimeMs(); # endif uPortLog("U_CELL_PWR_TEST: powering off...\n"); uCellPwrOff(cellHandle, pKeepGoingCallback); uPortLog("U_CELL_PWR_TEST: power off completed.\n"); # if U_CFG_APP_PIN_CELL_VINT < 0 timeMs = uPortGetTickTimeMs() - timeMs; if (timeMs < pModule->powerDownWaitSeconds * 1000) { timeMs = (pModule->powerDownWaitSeconds * 1000) - timeMs; uPortLog("U_CELL_PWR_TEST: waiting another %d second(s) to be sure of a " "clean power off as there's no VInt pin to tell us...\n", (int32_t) ((timeMs / 1000) + 1)); uPortTaskBlock(timeMs); } # endif } // Do this twice so as to check transiting from // a call to uCellPwrOffHard() to a call to // uCellPwrOn(). for (size_t x = 0; x < 2; x++) { uPortLog("U_CELL_PWR_TEST: testing power-on and alive calls with " "uCellPwrOffHard()"); if (trulyHardPowerOff) { uPortLog(" and truly hard power off"); } uPortLog(", iteration %d.\n", x + 1); U_PORT_TEST_ASSERT(!uCellPwrIsAlive(cellHandle)); # if U_CFG_APP_PIN_CELL_ENABLE_POWER >= 0 U_PORT_TEST_ASSERT(!uCellPwrIsPowered(cellHandle)); # endif uPortLog("U_CELL_PWR_TEST: powering on...\n"); U_PORT_TEST_ASSERT(uCellPwrOn(cellHandle, U_CELL_TEST_CFG_SIM_PIN, NULL) == 0); uPortLog("U_CELL_PWR_TEST: checking that module is alive...\n"); U_PORT_TEST_ASSERT(uCellPwrIsAlive(cellHandle)); // Let the module sort itself out uPortLog("U_CELL_PWR_TEST: waiting %d second(s) before powering off...\n", pModule->minAwakeTimeSeconds); uPortTaskBlock(pModule->minAwakeTimeSeconds * 1000); # if U_CFG_APP_PIN_CELL_VINT < 0 timeMs = uPortGetTickTimeMs(); # endif uPortLog("U_CELL_PWR_TEST: hard powering off...\n"); uCellPwrOffHard(cellHandle, trulyHardPowerOff, NULL); uPortLog("U_CELL_PWR_TEST: hard power off completed.\n"); # if U_CFG_APP_PIN_CELL_VINT < 0 timeMs = uPortGetTickTimeMs() - timeMs; if (!trulyHardPowerOff && (timeMs < pModule->powerDownWaitSeconds * 1000)) { timeMs = (pModule->powerDownWaitSeconds * 1000) - timeMs; uPortLog("U_CELL_PWR_TEST: waiting another %d second(s) to be" " sure of a clean power off as there's no VInt pin to" " tell us...\n", (int32_t) ((timeMs / 1000) + 1)); uPortTaskBlock(timeMs); } # endif } uPortLog("U_CELL_PWR_TEST: testing power-on and alive calls after hard power off.\n"); U_PORT_TEST_ASSERT(!uCellPwrIsAlive(cellHandle)); # if U_CFG_APP_PIN_CELL_ENABLE_POWER >= 0 U_PORT_TEST_ASSERT(!uCellPwrIsPowered(cellHandle)); # endif uPortLog("U_CELL_PWR_TEST: removing cellular instance...\n"); uCellRemove(cellHandle); } # endif // if U_CFG_APP_PIN_CELL_PWR_ON >= 0 /* ---------------------------------------------------------------- * PUBLIC FUNCTIONS * -------------------------------------------------------------- */ # if U_CFG_APP_PIN_CELL_PWR_ON >= 0 /** Test all the power functions apart from reboot. * * IMPORTANT: see notes in u_cfg_test_platform_specific.h for the * naming rules that must be followed when using the * U_PORT_TEST_FUNCTION() macro. */ U_PORT_TEST_FUNCTION("[cellPwr]", "cellPwr") { int32_t heapUsed; int32_t heapClibLossOffset = (int32_t) gSystemHeapLost; // In case a previous test failed uCellTestPrivateCleanup(&gHandles); // Obtain the initial heap size heapUsed = uPortGetHeapFree(); // Note: not using the standard preamble here as // we need to fiddle with the parameters into // uCellInit(). U_PORT_TEST_ASSERT(uPortInit() == 0); gHandles.uartHandle = uPortUartOpen(U_CFG_APP_CELL_UART, 115200, NULL, U_CELL_UART_BUFFER_LENGTH_BYTES, U_CFG_APP_PIN_CELL_TXD, U_CFG_APP_PIN_CELL_RXD, U_CFG_APP_PIN_CELL_CTS, U_CFG_APP_PIN_CELL_RTS); U_PORT_TEST_ASSERT(gHandles.uartHandle >= 0); U_PORT_TEST_ASSERT(uAtClientInit() == 0); uPortLog("U_CELL_PWR_TEST: adding an AT client on UART %d...\n", U_CFG_APP_CELL_UART); gHandles.atClientHandle = uAtClientAdd(gHandles.uartHandle, U_AT_CLIENT_STREAM_TYPE_UART, NULL, U_CELL_AT_BUFFER_LENGTH_BYTES); U_PORT_TEST_ASSERT(gHandles.atClientHandle != NULL); // So that we can see what we're doing uAtClientPrintAtSet(gHandles.atClientHandle, true); U_PORT_TEST_ASSERT(uCellInit() == 0); // The main bit, which is done with and // without use of the VInt pin, even // if it is connected testPowerAliveVInt(&gHandles, -1); # if U_CFG_APP_PIN_CELL_VINT >= 0 testPowerAliveVInt(&gHandles, U_CFG_APP_PIN_CELL_VINT); # endif U_PORT_TEST_ASSERT(gCallbackErrorCode == 0); // Do the standard postamble, leaving the module on for the next // test to speed things up uCellTestPrivatePostamble(&gHandles, false); // Check for memory leaks heapUsed -= uPortGetHeapFree(); uPortLog("U_CELL_PWR_TEST: %d byte(s) of heap were lost to" " the C library during this test and we have" " leaked %d byte(s).\n", gSystemHeapLost - heapClibLossOffset, heapUsed - (gSystemHeapLost - heapClibLossOffset)); // heapUsed < 0 for the Zephyr case where the heap can look // like it increases (negative leak) U_PORT_TEST_ASSERT((heapUsed < 0) || (heapUsed <= ((int32_t) gSystemHeapLost) - heapClibLossOffset)); } #endif // if U_CFG_APP_PIN_CELL_PWR_ON >= 0 /** Test reboot. */ U_PORT_TEST_FUNCTION("[cellPwr]", "cellPwrReboot") { int32_t heapUsed; int32_t heapClibLossOffset = (int32_t) gSystemHeapLost; // In case a previous test failed uCellTestPrivateCleanup(&gHandles); // Obtain the initial heap size heapUsed = uPortGetHeapFree(); // Do the standard preamble U_PORT_TEST_ASSERT(uCellTestPrivatePreamble(U_CFG_TEST_CELL_MODULE_TYPE, &gHandles, true) == 0); // Not much of a test really, need to find some setting // that is ephemeral so that we know whether a reboot has // occurred. Anyway, this will be tested in those tests that // change bandmask and RAT. uPortLog("U_CELL_PWR_TEST: rebooting cellular...\n"); U_PORT_TEST_ASSERT(uCellPwrReboot(gHandles.cellHandle, NULL) == 0); U_PORT_TEST_ASSERT(uCellPwrIsAlive(gHandles.cellHandle)); // Do the standard postamble, leaving the module on for the next // test to speed things up uCellTestPrivatePostamble(&gHandles, false); // Check for memory leaks heapUsed -= uPortGetHeapFree(); uPortLog("U_CELL_PWR_TEST: %d byte(s) of heap were lost to" " the C library during this test and we have" " leaked %d byte(s).\n", gSystemHeapLost - heapClibLossOffset, heapUsed - (gSystemHeapLost - heapClibLossOffset)); // heapUsed < 0 for the Zephyr case where the heap can look // like it increases (negative leak) U_PORT_TEST_ASSERT((heapUsed < 0) || (heapUsed <= ((int32_t) gSystemHeapLost) - heapClibLossOffset)); } /** Test reset */ U_PORT_TEST_FUNCTION("[cellPwr]", "cellPwrReset") { int32_t heapUsed; int32_t heapClibLossOffset = (int32_t) gSystemHeapLost; int32_t x; // In case a previous test failed uCellTestPrivateCleanup(&gHandles); // Obtain the initial heap size heapUsed = uPortGetHeapFree(); // Do the standard preamble U_PORT_TEST_ASSERT(uCellTestPrivatePreamble(U_CFG_TEST_CELL_MODULE_TYPE, &gHandles, true) == 0); uPortLog("U_CELL_PWR_TEST: resetting cellular...\n"); x = uCellPwrResetHard(gHandles.cellHandle, U_CFG_APP_PIN_CELL_RESET); # if U_CFG_APP_PIN_CELL_RESET >= 0 U_PORT_TEST_ASSERT(x == 0); # else U_PORT_TEST_ASSERT(x < 0); # endif U_PORT_TEST_ASSERT(uCellPwrIsAlive(gHandles.cellHandle)); // Do the standard postamble, leaving the module on for the next // test to speed things up uCellTestPrivatePostamble(&gHandles, false); // Check for memory leaks heapUsed -= uPortGetHeapFree(); uPortLog("U_CELL_PWR_TEST: %d byte(s) of heap were lost to" " the C library during this test and we have" " leaked %d byte(s).\n", gSystemHeapLost - heapClibLossOffset, heapUsed - (gSystemHeapLost - heapClibLossOffset)); // heapUsed < 0 for the Zephyr case where the heap can look // like it increases (negative leak) U_PORT_TEST_ASSERT((heapUsed < 0) || (heapUsed <= ((int32_t) gSystemHeapLost) - heapClibLossOffset)); } /** Clean-up to be run at the end of this round of tests, just * in case there were test failures which would have resulted * in the deinitialisation being skipped. */ U_PORT_TEST_FUNCTION("[cellPwr]", "cellPwrCleanUp") { int32_t x; uCellTestPrivateCleanup(&gHandles); x = uPortTaskStackMinFree(NULL); if (x != (int32_t) U_ERROR_COMMON_NOT_SUPPORTED) { uPortLog("U_CELL_PWR_TEST: main task stack had a minimum of %d" " byte(s) free at the end of these tests.\n", x); U_PORT_TEST_ASSERT(x >= U_CFG_TEST_OS_MAIN_TASK_MIN_FREE_STACK_BYTES); } uPortDeinit(); x = uPortGetHeapMinFree(); if (x >= 0) { uPortLog("U_CELL_PWR_TEST: heap had a minimum of %d" " byte(s) free at the end of these tests.\n", x); U_PORT_TEST_ASSERT(x >= U_CFG_TEST_HEAP_MIN_FREE_BYTES); } } #endif // #ifdef U_CFG_TEST_CELL_MODULE_TYPE // End of file
the_stack_data/51699765.c
#include <string.h> static inline int match_string(const char **cursor, char *str) { const char *cursor_str = *cursor; size_t strlength = strlen(str); if (!strncmp(cursor_str, str, strlength)) { *cursor = cursor_str + strlength; return 1; } return 0; } static inline int is_alpha(char ch) { return (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z'); } static inline int is_digit(char ch) { return (ch >= '0' && ch <= '9'); } static inline int is_pchar(char ch) { // RFC3986: pchar = unreserved / pct-encoded / sub-delims / ":" / "@" // unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" // "ALPHA (%41-%5A and %61-%7A), DIGIT (%30-%39)" // pct-encoded = "%" HEXDIG HEXDIG // sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "=" // NOTE: This isn't a strict parse, because we allow '%' anywhere rather than just in 'pct-encoded'. return is_alpha(ch) || is_digit(ch) || (ch >= '&' && ch <= '.') || ch == '_' || ch == ':' || ch == '~' || ch == ';' || ch == '=' || ch == '@' || ch == '!' || ch == '$' || ch == '%'; } static inline size_t parse_http_uri_rougly(const char **cursor) { // RFC7230: request-target = origin-form / absolute-form / authority-form / asterisk-form // origin-form = absolute-path [ "?" query ] // absolute-path = 1*( "/" segment ) // segment = *pchar // pchar = unreserved / pct-encoded / sub-delims / ":" / "@" // unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" // pct-encoded = "%" HEXDIG HEXDIG // sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "=" // authority-form = authority // authority = [ userinfo "@" ] host [ ":" port ] // absolute-form = absolute-URI // absolute-URI = scheme ":" hier-part [ "?" query ] // hier-part = ("//" authority path-abempty) / path-absolute / path-rootless / path-empty // asterisk-form = "*" // RFC7231: Referer = absolute-URI / partial-URI // partial-URI = relative-part [ "?" query ] // relative-part = ("//" authority path-abempty) / path-absolute / path-noscheme / path-empty // NOTE: We don't /super/ care about every little part here, so this is just a rough parse for a string with combinations of 'pchar' and '/' characters. const char *uri_start = *cursor; const char *uri_end = uri_start; while (is_pchar(*uri_end) || *uri_end == '/') { ++uri_end; } *cursor = uri_end; return uri_end - uri_start; } static inline int skip_number(const char **cursor) { const char *cursor_str = *cursor; if (!is_digit(*cursor_str++)) { return 0; } while (is_digit(*cursor_str)) { ++cursor_str; } *cursor = cursor_str; return 1; } static inline void skip_to_next_sp(const char **cursor) { const char *cursor_str = *cursor; while (*cursor_str != ' ' && *cursor_str != '\0') { ++cursor_str; } *cursor = cursor_str; } static inline void skip_http_ows(const char **cursor) { // OWS = *( SP / HTAB ), RWS = 1*( SP / HTAB ), BWS = OWS const char *cursor_str = *cursor; while (*cursor_str == ' ' || *cursor_str == '\t') { ++cursor_str; } *cursor = cursor_str; } static inline int peek_http_newline(const char *cursor) { // Accept '\r\n' or '\n' (returning the number of characters peeked) if (cursor[0] == '\r') { return (cursor[1] == '\n' ? 2 : 1); } return cursor[0] == '\n'; } static inline int skip_past_next_http_newline(const char **cursor) { const char *cursor_str = *cursor; while (*cursor_str != '\r' && *cursor_str != '\n' && *cursor_str != '\0') { ++cursor_str; } int newline_characters_peeked = peek_http_newline(cursor_str); if (newline_characters_peeked) { *cursor = cursor_str + newline_characters_peeked; return 1; } return 0; } // RFC7230 int parse_http_request_header(const char *cursor, const char **request_uri_out, size_t *request_uri_length_out, const char **referer_out, size_t *referer_length_out, const char **host_out, size_t *host_length_out) { // Parse HTTP 'Request-Line' [RFC7230 3.1.1]: 'method SP request-target SP HTTP-Version CRLF' if (!match_string(&cursor, "GET ")) { return 0; } // 'method SP' *request_uri_out = cursor; if (!(*request_uri_length_out = parse_http_uri_rougly(&cursor))) { return 0; } // 'request-target' skip_to_next_sp(&cursor); // Skip any remainder of the URI that we didn't parse (e.g. querystring) if (!match_string(&cursor, " HTTP/")) { return 0; } // 'SP HTTP/' if (!skip_number(&cursor)) { return 0; } // '1*DIGIT' if (!match_string(&cursor, ".")) { return 0; } // '.' if (!skip_number(&cursor)) { return 0; } // '1*DIGIT' int fields_matched = 0; // RFC7230 3.2 // "field-name ":" OWS field-value OWS" // field-value = *( field-content / obs-fold ) // field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ] // field-vchar = VCHAR / obs-text // NOTE: This implementation does not support obsolete line folding (i.e. 'obs-fold') while (skip_past_next_http_newline(&cursor)) { if (peek_http_newline(cursor)) { break; } else if (match_string(&cursor, "Referer:")) { skip_http_ows(&cursor); // 'OWS' // I don't believe the referer field value can be a 'quoted-string' *referer_out = cursor; *referer_length_out = parse_http_uri_rougly(&cursor); // 'field-value' if (++fields_matched == 2) { break; } } else if (match_string(&cursor, "Host:")) { skip_http_ows(&cursor); // 'OWS' *host_out = cursor; *host_length_out = parse_http_uri_rougly(&cursor); // 'field-value' if (++fields_matched == 2) { break; } } } return 1; } int file_extension(const char *string, size_t length, const char **string_out, size_t *length_out) { if (length == 0) { return -1; } const char *result = string + length - 1; while (result > string) { if (!is_alpha(*result)) { if (*result == '.') { break; } else { return -1; } } --result; } size_t result_length = length - (result - string) - 1; if (result == string || result_length <= 0 || *(result + 1) == '\0') { return -1; } *string_out = result + 1; *length_out = result_length; return 0; }
the_stack_data/1022546.c
/* File: odd_even.c * * Purpose: Use odd-even transposition sort to sort a list of ints. * * Compile: gcc -g -Wall -o odd_even odd_even.c * Run: odd_even <n> <g|i> * n: number of elements in list * 'g': generate list using a random number generator * 'i': user input list * * Input: list (optional) * Output: sorted list * * IPP: Section 3.7.1 (p. 128) and Section 5.6.2 (pp. 233 and ff.) */ #include <stdio.h> #include <stdlib.h> /* Keys in the random list in the range 0 <= key < RMAX */ const int RMAX = 100; void Usage(char *prog_name); void Get_args(int argc, char *argv[], int *n_p, char *g_i_p); void Generate_list(int a[], int n); void Print_list(int a[], int n, char *title); void Read_list(int a[], int n); void Odd_even_sort(int a[], int n); /*-----------------------------------------------------------------*/ int main(int argc, char *argv[]) { int n; char g_i; int *a; Get_args(argc, argv, &n, &g_i); a = (int *)malloc(n * sizeof(int)); if (g_i == 'g') { Generate_list(a, n); // Print_list(a, n, "Before sort"); } else { Read_list(a, n); } Odd_even_sort(a, n); // Print_list(a, n, "After sort"); free(a); return 0; } /* main */ /*----------------------------------------------------------------- * Function: Usage * Purpose: Summary of how to run program */ void Usage(char *prog_name) { fprintf(stderr, "usage: %s <n> <g|i>\n", prog_name); fprintf(stderr, " n: number of elements in list\n"); fprintf(stderr, " 'g': generate list using a random number generator\n"); fprintf(stderr, " 'i': user input list\n"); } /* Usage */ /*----------------------------------------------------------------- * Function: Get_args * Purpose: Get and check command line arguments * In args: argc, argv * Out args: n_p, g_i_p */ void Get_args(int argc, char *argv[], int *n_p, char *g_i_p) { if (argc != 3) { Usage(argv[0]); exit(0); } *n_p = atoi(argv[1]); *g_i_p = argv[2][0]; if (*n_p <= 0 || (*g_i_p != 'g' && *g_i_p != 'i')) { Usage(argv[0]); exit(0); } } /* Get_args */ /*----------------------------------------------------------------- * Function: Generate_list * Purpose: Use random number generator to generate list elements * In args: n * Out args: a */ void Generate_list(int a[], int n) { int i; srandom(0); for (i = 0; i < n; i++) a[i] = random() % RMAX; } /* Generate_list */ /*----------------------------------------------------------------- * Function: Print_list * Purpose: Print the elements in the list * In args: a, n */ void Print_list(int a[], int n, char *title) { int i; printf("%s:\n", title); for (i = 0; i < n; i++) printf("%d ", a[i]); printf("\n\n"); } /* Print_list */ /*----------------------------------------------------------------- * Function: Read_list * Purpose: Read elements of list from stdin * In args: n * Out args: a */ void Read_list(int a[], int n) { int i; printf("Please enter the elements of the list\n"); for (i = 0; i < n; i++) scanf("%d", &a[i]); } /* Read_list */ /*----------------------------------------------------------------- * Function: Odd_even_sort * Purpose: Sort list using odd-even transposition sort * In args: n * In/out args: a */ void Odd_even_sort(int a[] /* in/out */, int n /* in */) { int phase, i, temp; for (phase = 0; phase < n; phase++) if (phase % 2 == 0) { /* Even phase */ for (i = 1; i < n; i += 2) if (a[i - 1] > a[i]) { temp = a[i]; a[i] = a[i - 1]; a[i - 1] = temp; } } else { /* Odd phase */ for (i = 1; i < n - 1; i += 2) if (a[i] > a[i + 1]) { temp = a[i]; a[i] = a[i + 1]; a[i + 1] = temp; } } } /* Odd_even_sort */
the_stack_data/68887457.c
/* profile with: gcc -Wall -pg -o vector_elmts_sum vector_elmts_sum.c ./vector_elmts_sum 1000000 1000 1000000 gprof --brief vector_elmts_sum */ #include <assert.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> uint8_t *vec_8; uint32_t *vec_32; size_t *indices; void init(size_t vec_sz, size_t i_sz) { vec_8 = malloc(vec_sz * sizeof(uint8_t)); assert(vec_8 != NULL); vec_32 = malloc(vec_sz * sizeof(uint32_t)); assert(vec_32 != NULL); for (size_t i = 0; i < vec_sz; i++) { vec_8[i] = (uint8_t)i; vec_32[i] = (uint32_t)i; } indices = malloc(i_sz * sizeof(size_t)); assert(indices != NULL); } void clean() { free(vec_32); free(vec_8); free(indices); } void shuffle_indices(size_t vec_sz, size_t i_sz) { for (size_t i = 0; i < i_sz; i++) { indices[i] = (size_t)(rand() * vec_sz / RAND_MAX); } } int compute_sum8(size_t i_sz) { int sum = 0; for (size_t i = 0; i < i_sz; i++) { sum += vec_8[indices[i]]; } return sum; } int compute_sum32(size_t i_sz) { int sum = 0; for (size_t i = 0; i < i_sz; i++) { sum += vec_32[indices[i]]; } return sum; } void print_debug(size_t vec_sz, size_t i_sz) { printf("vec_8 = ["); for (size_t i = 0; i < vec_sz; i++) { printf("%d ", vec_8[i]); } printf("]\n"); printf("vec_32 = ["); for (size_t i = 0; i < vec_sz; i++) { printf("%d ", vec_32[i]); } printf("]\n"); printf("indices = ["); for (size_t i = 0; i < i_sz; i++) { printf("%ld ", indices[i]); } printf("]\n"); } int main(int argc, char *argv[]) { if (argc < 4) { printf("Usage: vector_elmts_sum vector_size indices_sz loops\n"); exit(1); } size_t length = atoi(argv[1]); size_t isize = atoi(argv[2]); int loops = atoi(argv[3]); init(length, isize); int sum8 = 0; int sum32 = 0; for (int i = 0; i < loops; i++) { shuffle_indices(length, isize); sum8 += compute_sum8(isize); sum32 += compute_sum32(isize); } if (length < 50 && loops == 1) { print_debug(length, isize); } printf("sum8 = %d\n", sum8); printf("sum32 = %d\n", sum32); clean(); }
the_stack_data/314738.c
//C program to insert an element in an array #include <stdio.h> int main() { int array[100], position, c, n, value; printf("Enter number of elements in array\n"); scanf("%d", &n); printf("Enter %d elements\n", n); for (c = 0; c < n; c++) scanf("%d", &array[c]); printf("Enter the location where you wish to insert an element\n"); scanf("%d", &position); printf("Enter the value to insert\n"); scanf("%d", &value); for (c = n - 1; c >= position - 1; c--) array[c+1] = array[c]; array[position-1] = value; printf("Resultant array is\n"); for (c = 0; c <= n; c++) printf("%d\n", array[c]); return 0; }
the_stack_data/35911.c
#include <math.h> #include <stdlib.h> #include <string.h> #include <stdio.h> #include <complex.h> #ifdef complex #undef complex #endif #ifdef I #undef I #endif #if defined(_WIN64) typedef long long BLASLONG; typedef unsigned long long BLASULONG; #else typedef long BLASLONG; typedef unsigned long BLASULONG; #endif #ifdef LAPACK_ILP64 typedef BLASLONG blasint; #if defined(_WIN64) #define blasabs(x) llabs(x) #else #define blasabs(x) labs(x) #endif #else typedef int blasint; #define blasabs(x) abs(x) #endif typedef blasint integer; typedef unsigned int uinteger; typedef char *address; typedef short int shortint; typedef float real; typedef double doublereal; typedef struct { real r, i; } complex; typedef struct { doublereal r, i; } doublecomplex; #ifdef _MSC_VER static inline _Fcomplex Cf(complex *z) {_Fcomplex zz={z->r , z->i}; return zz;} static inline _Dcomplex Cd(doublecomplex *z) {_Dcomplex zz={z->r , z->i};return zz;} static inline _Fcomplex * _pCf(complex *z) {return (_Fcomplex*)z;} static inline _Dcomplex * _pCd(doublecomplex *z) {return (_Dcomplex*)z;} #else static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} #endif #define pCf(z) (*_pCf(z)) #define pCd(z) (*_pCd(z)) typedef int logical; typedef short int shortlogical; typedef char logical1; typedef char integer1; #define TRUE_ (1) #define FALSE_ (0) /* Extern is for use with -E */ #ifndef Extern #define Extern extern #endif /* I/O stuff */ typedef int flag; typedef int ftnlen; typedef int ftnint; /*external read, write*/ typedef struct { flag cierr; ftnint ciunit; flag ciend; char *cifmt; ftnint cirec; } cilist; /*internal read, write*/ typedef struct { flag icierr; char *iciunit; flag iciend; char *icifmt; ftnint icirlen; ftnint icirnum; } icilist; /*open*/ typedef struct { flag oerr; ftnint ounit; char *ofnm; ftnlen ofnmlen; char *osta; char *oacc; char *ofm; ftnint orl; char *oblnk; } olist; /*close*/ typedef struct { flag cerr; ftnint cunit; char *csta; } cllist; /*rewind, backspace, endfile*/ typedef struct { flag aerr; ftnint aunit; } alist; /* inquire */ typedef struct { flag inerr; ftnint inunit; char *infile; ftnlen infilen; ftnint *inex; /*parameters in standard's order*/ ftnint *inopen; ftnint *innum; ftnint *innamed; char *inname; ftnlen innamlen; char *inacc; ftnlen inacclen; char *inseq; ftnlen inseqlen; char *indir; ftnlen indirlen; char *infmt; ftnlen infmtlen; char *inform; ftnint informlen; char *inunf; ftnlen inunflen; ftnint *inrecl; ftnint *innrec; char *inblank; ftnlen inblanklen; } inlist; #define VOID void union Multitype { /* for multiple entry points */ integer1 g; shortint h; integer i; /* longint j; */ real r; doublereal d; complex c; doublecomplex z; }; typedef union Multitype Multitype; struct Vardesc { /* for Namelist */ char *name; char *addr; ftnlen *dims; int type; }; typedef struct Vardesc Vardesc; struct Namelist { char *name; Vardesc **vars; int nvars; }; typedef struct Namelist Namelist; #define abs(x) ((x) >= 0 ? (x) : -(x)) #define dabs(x) (fabs(x)) #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) #define dmin(a,b) (f2cmin(a,b)) #define dmax(a,b) (f2cmax(a,b)) #define bit_test(a,b) ((a) >> (b) & 1) #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) #define abort_() { sig_die("Fortran abort routine called", 1); } #define c_abs(z) (cabsf(Cf(z))) #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } #ifdef _MSC_VER #define c_div(c, a, b) {Cf(c)._Val[0] = (Cf(a)._Val[0]/Cf(b)._Val[0]); Cf(c)._Val[1]=(Cf(a)._Val[1]/Cf(b)._Val[1]);} #define z_div(c, a, b) {Cd(c)._Val[0] = (Cd(a)._Val[0]/Cd(b)._Val[0]); Cd(c)._Val[1]=(Cd(a)._Val[1]/df(b)._Val[1]);} #else #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} #endif #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} #define d_abs(x) (fabs(*(x))) #define d_acos(x) (acos(*(x))) #define d_asin(x) (asin(*(x))) #define d_atan(x) (atan(*(x))) #define d_atn2(x, y) (atan2(*(x),*(y))) #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } #define r_cnjg(R, Z) { pCf(R) = conjf(Cf(Z)); } #define d_cos(x) (cos(*(x))) #define d_cosh(x) (cosh(*(x))) #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) #define d_exp(x) (exp(*(x))) #define d_imag(z) (cimag(Cd(z))) #define r_imag(z) (cimagf(Cf(z))) #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) #define d_log(x) (log(*(x))) #define d_mod(x, y) (fmod(*(x), *(y))) #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) #define d_nint(x) u_nint(*(x)) #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) #define d_sign(a,b) u_sign(*(a),*(b)) #define r_sign(a,b) u_sign(*(a),*(b)) #define d_sin(x) (sin(*(x))) #define d_sinh(x) (sinh(*(x))) #define d_sqrt(x) (sqrt(*(x))) #define d_tan(x) (tan(*(x))) #define d_tanh(x) (tanh(*(x))) #define i_abs(x) abs(*(x)) #define i_dnnt(x) ((integer)u_nint(*(x))) #define i_len(s, n) (n) #define i_nint(x) ((integer)u_nint(*(x))) #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) #define pow_si(B,E) spow_ui(*(B),*(E)) #define pow_ri(B,E) spow_ui(*(B),*(E)) #define pow_di(B,E) dpow_ui(*(B),*(E)) #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } #define sig_die(s, kill) { exit(1); } #define s_stop(s, n) {exit(0);} static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; #define z_abs(z) (cabs(Cd(z))) #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} #define myexit_() break; #define mycycle() continue; #define myceiling(w) {ceil(w)} #define myhuge(w) {HUGE_VAL} //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} /* procedure parameter types for -A and -C++ */ #define F2C_proc_par_types 1 #ifdef __cplusplus typedef logical (*L_fp)(...); #else typedef logical (*L_fp)(); #endif static float spow_ui(float x, integer n) { float pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static double dpow_ui(double x, integer n) { double pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } #ifdef _MSC_VER static _Fcomplex cpow_ui(complex x, integer n) { complex pow={1.0,0.0}; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x.r = 1/x.r, x.i=1/x.i; for(u = n; ; ) { if(u & 01) pow.r *= x.r, pow.i *= x.i; if(u >>= 1) x.r *= x.r, x.i *= x.i; else break; } } _Fcomplex p={pow.r, pow.i}; return p; } #else static _Complex float cpow_ui(_Complex float x, integer n) { _Complex float pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } #endif #ifdef _MSC_VER static _Dcomplex zpow_ui(_Dcomplex x, integer n) { _Dcomplex pow={1.0,0.0}; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x._Val[0] = 1/x._Val[0], x._Val[1] =1/x._Val[1]; for(u = n; ; ) { if(u & 01) pow._Val[0] *= x._Val[0], pow._Val[1] *= x._Val[1]; if(u >>= 1) x._Val[0] *= x._Val[0], x._Val[1] *= x._Val[1]; else break; } } _Dcomplex p = {pow._Val[0], pow._Val[1]}; return p; } #else static _Complex double zpow_ui(_Complex double x, integer n) { _Complex double pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } #endif static integer pow_ii(integer x, integer n) { integer pow; unsigned long int u; if (n <= 0) { if (n == 0 || x == 1) pow = 1; else if (x != -1) pow = x == 0 ? 1/x : 0; else n = -n; } if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { u = n; for(pow = 1; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static integer dmaxloc_(double *w, integer s, integer e, integer *n) { double m; integer i, mi; for(m=w[s-1], mi=s, i=s+1; i<=e; i++) if (w[i-1]>m) mi=i ,m=w[i-1]; return mi-s+1; } static integer smaxloc_(float *w, integer s, integer e, integer *n) { float m; integer i, mi; for(m=w[s-1], mi=s, i=s+1; i<=e; i++) if (w[i-1]>m) mi=i ,m=w[i-1]; return mi-s+1; } static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; #ifdef _MSC_VER _Fcomplex zdotc = {0.0, 0.0}; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += conjf(Cf(&x[i]))._Val[0] * Cf(&y[i])._Val[0]; zdotc._Val[1] += conjf(Cf(&x[i]))._Val[1] * Cf(&y[i])._Val[1]; } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += conjf(Cf(&x[i*incx]))._Val[0] * Cf(&y[i*incy])._Val[0]; zdotc._Val[1] += conjf(Cf(&x[i*incx]))._Val[1] * Cf(&y[i*incy])._Val[1]; } } pCf(z) = zdotc; } #else _Complex float zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); } } pCf(z) = zdotc; } #endif static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; #ifdef _MSC_VER _Dcomplex zdotc = {0.0, 0.0}; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += conj(Cd(&x[i]))._Val[0] * Cd(&y[i])._Val[0]; zdotc._Val[1] += conj(Cd(&x[i]))._Val[1] * Cd(&y[i])._Val[1]; } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += conj(Cd(&x[i*incx]))._Val[0] * Cd(&y[i*incy])._Val[0]; zdotc._Val[1] += conj(Cd(&x[i*incx]))._Val[1] * Cd(&y[i*incy])._Val[1]; } } pCd(z) = zdotc; } #else _Complex double zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conj(Cd(&x[i])) * Cd(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); } } pCd(z) = zdotc; } #endif static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; #ifdef _MSC_VER _Fcomplex zdotc = {0.0, 0.0}; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += Cf(&x[i])._Val[0] * Cf(&y[i])._Val[0]; zdotc._Val[1] += Cf(&x[i])._Val[1] * Cf(&y[i])._Val[1]; } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += Cf(&x[i*incx])._Val[0] * Cf(&y[i*incy])._Val[0]; zdotc._Val[1] += Cf(&x[i*incx])._Val[1] * Cf(&y[i*incy])._Val[1]; } } pCf(z) = zdotc; } #else _Complex float zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cf(&x[i]) * Cf(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); } } pCf(z) = zdotc; } #endif static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; #ifdef _MSC_VER _Dcomplex zdotc = {0.0, 0.0}; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += Cd(&x[i])._Val[0] * Cd(&y[i])._Val[0]; zdotc._Val[1] += Cd(&x[i])._Val[1] * Cd(&y[i])._Val[1]; } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += Cd(&x[i*incx])._Val[0] * Cd(&y[i*incy])._Val[0]; zdotc._Val[1] += Cd(&x[i*incx])._Val[1] * Cd(&y[i*incy])._Val[1]; } } pCd(z) = zdotc; } #else _Complex double zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cd(&x[i]) * Cd(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); } } pCd(z) = zdotc; } #endif /* -- translated by f2c (version 20000121). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ /* Table of constant values */ static integer c__1 = 1; /* > \brief \b DTRTI2 computes the inverse of a triangular matrix (unblocked algorithm). */ /* =========== DOCUMENTATION =========== */ /* Online html documentation available at */ /* http://www.netlib.org/lapack/explore-html/ */ /* > \htmlonly */ /* > Download DTRTI2 + dependencies */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dtrti2. f"> */ /* > [TGZ]</a> */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dtrti2. f"> */ /* > [ZIP]</a> */ /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dtrti2. f"> */ /* > [TXT]</a> */ /* > \endhtmlonly */ /* Definition: */ /* =========== */ /* SUBROUTINE DTRTI2( UPLO, DIAG, N, A, LDA, INFO ) */ /* CHARACTER DIAG, UPLO */ /* INTEGER INFO, LDA, N */ /* DOUBLE PRECISION A( LDA, * ) */ /* > \par Purpose: */ /* ============= */ /* > */ /* > \verbatim */ /* > */ /* > DTRTI2 computes the inverse of a real upper or lower triangular */ /* > matrix. */ /* > */ /* > This is the Level 2 BLAS version of the algorithm. */ /* > \endverbatim */ /* Arguments: */ /* ========== */ /* > \param[in] UPLO */ /* > \verbatim */ /* > UPLO is CHARACTER*1 */ /* > Specifies whether the matrix A is upper or lower triangular. */ /* > = 'U': Upper triangular */ /* > = 'L': Lower triangular */ /* > \endverbatim */ /* > */ /* > \param[in] DIAG */ /* > \verbatim */ /* > DIAG is CHARACTER*1 */ /* > Specifies whether or not the matrix A is unit triangular. */ /* > = 'N': Non-unit triangular */ /* > = 'U': Unit triangular */ /* > \endverbatim */ /* > */ /* > \param[in] N */ /* > \verbatim */ /* > N is INTEGER */ /* > The order of the matrix A. N >= 0. */ /* > \endverbatim */ /* > */ /* > \param[in,out] A */ /* > \verbatim */ /* > A is DOUBLE PRECISION array, dimension (LDA,N) */ /* > On entry, the triangular matrix A. If UPLO = 'U', the */ /* > leading n by n upper triangular part of the array A contains */ /* > the upper triangular matrix, and the strictly lower */ /* > triangular part of A is not referenced. If UPLO = 'L', the */ /* > leading n by n lower triangular part of the array A contains */ /* > the lower triangular matrix, and the strictly upper */ /* > triangular part of A is not referenced. If DIAG = 'U', the */ /* > diagonal elements of A are also not referenced and are */ /* > assumed to be 1. */ /* > */ /* > On exit, the (triangular) inverse of the original matrix, in */ /* > the same storage format. */ /* > \endverbatim */ /* > */ /* > \param[in] LDA */ /* > \verbatim */ /* > LDA is INTEGER */ /* > The leading dimension of the array A. LDA >= f2cmax(1,N). */ /* > \endverbatim */ /* > */ /* > \param[out] INFO */ /* > \verbatim */ /* > INFO is INTEGER */ /* > = 0: successful exit */ /* > < 0: if INFO = -k, the k-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 doubleOTHERcomputational */ /* ===================================================================== */ /* Subroutine */ int dtrti2_(char *uplo, char *diag, integer *n, doublereal * a, integer *lda, integer *info) { /* System generated locals */ integer a_dim1, a_offset, i__1, i__2; /* Local variables */ integer j; extern /* Subroutine */ int dscal_(integer *, doublereal *, doublereal *, integer *); extern logical lsame_(char *, char *); logical upper; extern /* Subroutine */ int dtrmv_(char *, char *, char *, integer *, doublereal *, integer *, doublereal *, integer *), xerbla_(char *, integer *, ftnlen); logical nounit; doublereal ajj; /* -- LAPACK computational routine (version 3.7.0) -- */ /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ /* December 2016 */ /* ===================================================================== */ /* Test the input parameters. */ /* Parameter adjustments */ a_dim1 = *lda; a_offset = 1 + a_dim1 * 1; a -= a_offset; /* Function Body */ *info = 0; upper = lsame_(uplo, "U"); nounit = lsame_(diag, "N"); if (! upper && ! lsame_(uplo, "L")) { *info = -1; } else if (! nounit && ! lsame_(diag, "U")) { *info = -2; } else if (*n < 0) { *info = -3; } else if (*lda < f2cmax(1,*n)) { *info = -5; } if (*info != 0) { i__1 = -(*info); xerbla_("DTRTI2", &i__1, (ftnlen)6); return 0; } if (upper) { /* Compute inverse of upper triangular matrix. */ i__1 = *n; for (j = 1; j <= i__1; ++j) { if (nounit) { a[j + j * a_dim1] = 1. / a[j + j * a_dim1]; ajj = -a[j + j * a_dim1]; } else { ajj = -1.; } /* Compute elements 1:j-1 of j-th column. */ i__2 = j - 1; dtrmv_("Upper", "No transpose", diag, &i__2, &a[a_offset], lda, & a[j * a_dim1 + 1], &c__1); i__2 = j - 1; dscal_(&i__2, &ajj, &a[j * a_dim1 + 1], &c__1); /* L10: */ } } else { /* Compute inverse of lower triangular matrix. */ for (j = *n; j >= 1; --j) { if (nounit) { a[j + j * a_dim1] = 1. / a[j + j * a_dim1]; ajj = -a[j + j * a_dim1]; } else { ajj = -1.; } if (j < *n) { /* Compute elements j+1:n of j-th column. */ i__1 = *n - j; dtrmv_("Lower", "No transpose", diag, &i__1, &a[j + 1 + (j + 1) * a_dim1], lda, &a[j + 1 + j * a_dim1], &c__1); i__1 = *n - j; dscal_(&i__1, &ajj, &a[j + 1 + j * a_dim1], &c__1); } /* L20: */ } } return 0; /* End of DTRTI2 */ } /* dtrti2_ */
the_stack_data/72012300.c
/* * Copyright (c) 2017, 2018, Oracle and/or its affiliates. * * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, this list of * conditions and the following disclaimer in the documentation and/or other materials provided * with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors may be used to * endorse or promote products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ void func(int *ptr) { *ptr = 7; } int main() { static int var; func(&var); return var; }
the_stack_data/97013487.c
#include<stdio.h> #include<stdlib.h> int linearSearch(int * number, int size, int num); int binarySearch(int * number, int start, int end, int num); int displayMenu(); int acceptVal(); int * acceptArray(); int * copyArray(int * inputArray, int size); void printArray(int* array, int size); void sort(int * arr, int size); int linearSearch(int * number, int size, int num) { int i; for (i=0; i<size; i++) { if (number[i]==num) return (i+1); } return -1; } int binarySearch (int * number, int start, int end, int num) { if (end>=1) { int mid = start + (end - start)/2; if (number[mid]>num) return binarySearch(number, start, mid-1, num); else if (number[mid]==num) return (mid+1); else return binarySearch(number, mid+1, end, num); } else return -1; } int displayMenu() { int choice; printf("\nChoose:\n1. Linear\n2. Binary\n3. Exit\n"); scanf("%d", &choice); return choice; } int acceptVal() { int val; printf("\nEnter a number to search: "); scanf("%d", &val); return val; } int * acceptArray(int *size) { int * arr; int n, i; printf("\nEnter the size of the array: "); scanf("%d", &n); arr = (int *)malloc(n*sizeof(int)); printf("Enter the values: "); for (i=0; i<n; i++) { scanf("%d", &arr[i]); } *size = n; return arr; } int * copyArray(int * inputArray, int size) { int i = 0; int *copyArr = (int *)malloc(size*sizeof(int)); for (i=0; i<size; i++) { copyArr[i] = inputArray[i]; } return copyArr; } void printArray(int * array, int size) { int i; printf("\n"); for (i=0; i<size-1; i++) { printf("%d, ", array[i]); } printf("%d", array[i]); } void sort(int * arr, int size) { int i, j, t; for (i=0; i<size; i++) { for (j=0; j<size-i; j++) { if (arr[j]>arr[j+1]) { t = arr[j]; arr[j] = arr[j+1]; arr[j+1] = t; } } } } int main() { int choice, size, number, another; int *arr1, *arr2; arr1 = acceptArray(&size); arr2 = copyArray(arr1, size); sort(arr2, size); printArray(arr1, size); while(1) { choice = displayMenu(); if (choice == 1) { another = linearSearch(arr1, size, acceptVal()); if (another == -1) printf("That number isn't in the array"); else printf("That number was found at %d", another); } else if (choice == 2) { printf("Array will be sorted to: "); printArray(arr2, size); number = binarySearch(arr2, 0, size, acceptVal()); if (number == -1) printf("That number isn't in the array"); else printf("That number was found at %d", number); } else { return 0; } } return 0; }
the_stack_data/78946.c
#include <stdio.h> #include <stdlib.h> #define g 12 #define o 12 int main(){ int n,c=0,l=0,r=0,q=0,m=0,t=0,cont1=0; char nom; int i,j; double q1=0,q2=0,q3=0,q4=0; double matriz [g][o]; n=12; m=n; scanf("%c",&nom); for (j=0;j<n;j++){ m--; for(i=0;i<n;i++){ scanf("%lf",&matriz [j] [i]); if(i<j && i>m){ q1+=matriz [j][i]; cont1++; } } } if(nom=='S'){ printf("%0.1lf\n",q1); } if(nom=='M'){ printf("%0.1lf\n",q1/cont1); } return 0; }
the_stack_data/1166564.c
/** ****************************************************************************** * @file stm32l0xx_ll_lptim.c * @author MCD Application Team * @version V1.8.0 * @date 25-November-2016 * @brief LPTIM LL module driver. ****************************************************************************** * @attention * * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2> * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ #if defined(USE_FULL_LL_DRIVER) /* Includes ------------------------------------------------------------------*/ #include "stm32l0xx_ll_lptim.h" #include "stm32l0xx_ll_bus.h" #ifdef USE_FULL_ASSERT #include "stm32_assert.h" #else #define assert_param(expr) ((void)0U) #endif /** @addtogroup STM32L0xx_LL_Driver * @{ */ #if defined (LPTIM1) || defined (LPTIM2) /** @addtogroup LPTIM_LL * @{ */ /* Private types -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private constants ---------------------------------------------------------*/ /* Private macros ------------------------------------------------------------*/ /** @addtogroup LPTIM_LL_Private_Macros * @{ */ #define IS_LPTIM_CLOCK_SOURCE(__VALUE__) (((__VALUE__) == LL_LPTIM_CLK_SOURCE_INTERNAL) \ || ((__VALUE__) == LL_LPTIM_CLK_SOURCE_EXTERNAL)) #define IS_LPTIM_CLOCK_PRESCALER(__VALUE__) (((__VALUE__) == LL_LPTIM_PRESCALER_DIV1) \ || ((__VALUE__) == LL_LPTIM_PRESCALER_DIV2) \ || ((__VALUE__) == LL_LPTIM_PRESCALER_DIV4) \ || ((__VALUE__) == LL_LPTIM_PRESCALER_DIV8) \ || ((__VALUE__) == LL_LPTIM_PRESCALER_DIV16) \ || ((__VALUE__) == LL_LPTIM_PRESCALER_DIV32) \ || ((__VALUE__) == LL_LPTIM_PRESCALER_DIV64) \ || ((__VALUE__) == LL_LPTIM_PRESCALER_DIV128)) #define IS_LPTIM_WAVEFORM(__VALUE__) (((__VALUE__) == LL_LPTIM_OUTPUT_WAVEFORM_PWM) \ || ((__VALUE__) == LL_LPTIM_OUTPUT_WAVEFORM_SETONCE)) #define IS_LPTIM_OUTPUT_POLARITY(__VALUE__) (((__VALUE__) == LL_LPTIM_OUTPUT_POLARITY_REGULAR) \ || ((__VALUE__) == LL_LPTIM_OUTPUT_POLARITY_INVERSE)) /** * @} */ /* Private function prototypes -----------------------------------------------*/ /* Exported functions --------------------------------------------------------*/ /** @addtogroup LPTIM_LL_Exported_Functions * @{ */ /** @addtogroup LPTIM_LL_EF_Init * @{ */ /** * @brief Set LPTIMx registers to their reset values. * @param LPTIMx LP Timer instance * @retval An ErrorStatus enumeration value: * - SUCCESS: LPTIMx registers are de-initialized * - ERROR: invalid LPTIMx instance */ ErrorStatus LL_LPTIM_DeInit(LPTIM_TypeDef* LPTIMx) { ErrorStatus result = SUCCESS; /* Check the parameters */ assert_param(IS_LPTIM_INSTANCE(LPTIMx)); if (LPTIMx == LPTIM1) { LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_LPTIM1); LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_LPTIM1); } #if defined(LPTIM2) else if (LPTIMx == LPTIM2) { LL_APB1_GRP2_ForceReset(LL_APB1_GRP2_PERIPH_LPTIM2); LL_APB1_GRP2_ReleaseReset(LL_APB1_GRP2_PERIPH_LPTIM2); } #endif else { result = ERROR; } return result; } /** * @brief Set each fields of the LPTIM_InitStruct structure to its default * value. * @param LPTIM_InitStruct pointer to a @ref LL_LPTIM_InitTypeDef structure * @retval None */ void LL_LPTIM_StructInit(LL_LPTIM_InitTypeDef* LPTIM_InitStruct) { /* Set the default configuration */ LPTIM_InitStruct->ClockSource = LL_LPTIM_CLK_SOURCE_INTERNAL; LPTIM_InitStruct->Prescaler = LL_LPTIM_PRESCALER_DIV1; LPTIM_InitStruct->Waveform = LL_LPTIM_OUTPUT_WAVEFORM_PWM; LPTIM_InitStruct->Polarity = LL_LPTIM_OUTPUT_POLARITY_REGULAR; } /** * @brief Configure the LPTIMx peripheral according to the specified parameters. * @note LL_LPTIM_Init can only be called when the LPTIM instance is disabled. * @note LPTIMx can be disabled using unitary function @ref LL_LPTIM_Disable(). * @param LPTIMx LP Timer Instance * @param LPTIM_InitStruct pointer to a @ref LL_LPTIM_InitTypeDef structure * @retval An ErrorStatus enumeration value: * - SUCCESS: LPTIMx instance has been initialized * - ERROR: LPTIMx instance hasn't been initialized */ ErrorStatus LL_LPTIM_Init(LPTIM_TypeDef * LPTIMx, LL_LPTIM_InitTypeDef* LPTIM_InitStruct) { ErrorStatus result = SUCCESS; /* The LPTIMx_CFGR register must only be modified when the LPTIM is disabled (ENABLE bit is reset to 0). */ if (LL_LPTIM_IsEnabled(LPTIMx)) { result = ERROR; } else { /* Check the parameters */ assert_param(IS_LPTIM_INSTANCE(LPTIMx)); assert_param(IS_LPTIM_CLOCK_SOURCE(LPTIM_InitStruct->ClockSource)); assert_param(IS_LPTIM_CLOCK_PRESCALER(LPTIM_InitStruct->Prescaler)); assert_param(IS_LPTIM_WAVEFORM(LPTIM_InitStruct->Waveform)); assert_param(IS_LPTIM_OUTPUT_POLARITY(LPTIM_InitStruct->Polarity)); /* Set CKSEL bitfield according to ClockSource value */ /* Set PRESC bitfield according to Prescaler value */ /* Set WAVE bitfield according to Waveform value */ /* Set WAVEPOL bitfield according to Polarity value */ MODIFY_REG(LPTIMx->CFGR, (LPTIM_CFGR_CKSEL | LPTIM_CFGR_PRESC | LPTIM_CFGR_WAVE| LPTIM_CFGR_WAVPOL), LPTIM_InitStruct->ClockSource | \ LPTIM_InitStruct->Prescaler | \ LPTIM_InitStruct->Waveform | \ LPTIM_InitStruct->Polarity); } return result; } /** * @} */ /** * @} */ /** * @} */ #endif /* defined (LPTIM1) || defined (LPTIM2) */ /** * @} */ #endif /* USE_FULL_LL_DRIVER */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
the_stack_data/578757.c
int main(){ int x,y,z; x = 0; if (y > 5){ x++; z++; } else { z++; } y++; return 0; }
the_stack_data/599199.c
/* * $XConsortium: RaAoA8.c,v 1.3 94/04/17 20:16:43 gildea Exp $ * * Copyright (c) 1989 X Consortium 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 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Except as contained in this notice, the name of the X Consortium shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from the X Consortium. * * * Author: Keith Packard, MIT X Consortium */ #include <X11/Xos.h> #include <X11/X.h> #include <X11/Xmd.h> #include <X11/Xdmcp.h> int XdmcpReallocARRAYofARRAY8 (array, length) ARRAYofARRAY8Ptr array; int length; { ARRAY8Ptr newData; newData = (ARRAY8Ptr) Xrealloc (array->data, length * sizeof (ARRAY8)); if (!newData) return FALSE; array->length = length; array->data = newData; return TRUE; }
the_stack_data/242330063.c
#include <pthread.h> #include <stdio.h> static int data1; static int data2; static pthread_rwlock_t rwlock = PTHREAD_RWLOCK_INITIALIZER; void *t_fun(void *arg) { pthread_rwlock_wrlock(&rwlock); data1++; // NORACE printf("%d",data2); // NORACE pthread_rwlock_unlock(&rwlock); return NULL; } int main(void) { pthread_t id; pthread_create(&id, NULL, t_fun, NULL); pthread_rwlock_rdlock(&rwlock); printf("%d",data1); // NORACE data2++; // NORACE pthread_rwlock_unlock(&rwlock); pthread_join (id, NULL); return 0; }
the_stack_data/37442.c
/* crypto/md/md5_dgst.c */ /* Copyright (C) 1995-1997 Eric Young ([email protected]) * All rights reserved. * * This package is an SSL implementation written * by Eric Young ([email protected]). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson ([email protected]). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young ([email protected])" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson ([email protected])" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #ifdef USE_MD5 /* Added by [email protected] 1998/1/26 */ #include <port_before.h> #ifndef HAVE_MD5 #include <stdio.h> #include "md5_locl.h" #include <port_after.h> const char *MD5_version="MD5 part of SSLeay 0.8.1 19-Jul-1997"; /* Implemented from RFC1321 The MD5 Message-Digest Algorithm */ #define INIT_DATA_A (unsigned long)0x67452301L #define INIT_DATA_B (unsigned long)0xefcdab89L #define INIT_DATA_C (unsigned long)0x98badcfeL #define INIT_DATA_D (unsigned long)0x10325476L #ifndef NOPROTO static void md5_block(MD5_CTX *c, unsigned long *p); #else static void md5_block(); #endif void MD5_Init(c) MD5_CTX *c; { c->A=INIT_DATA_A; c->B=INIT_DATA_B; c->C=INIT_DATA_C; c->D=INIT_DATA_D; c->Nl=0; c->Nh=0; c->num=0; } void MD5_Update(c, data, len) MD5_CTX *c; register const unsigned char *data; unsigned long len; { register ULONG *p; int sw,sc; ULONG l; if (len == 0U) return; l=(c->Nl+(len<<3))&0xffffffffL; /* 95-05-24 eay Fixed a bug with the overflow handling, thanks to * Wei Dai <[email protected]> for pointing it out. */ if (l < c->Nl) /* overflow */ c->Nh++; c->Nh+=(len>>29); c->Nl=l; if (c->num != 0) { p=c->data; sw=c->num>>2; sc=c->num&0x03; if ((c->num+len) >= (size_t)MD5_CBLOCK) { l= p[sw]; p_c2l(data,l,sc); p[sw++]=l; for (; sw<MD5_LBLOCK; sw++) { c2l(data,l); p[sw]=l; } len-=(MD5_CBLOCK-c->num); md5_block(c,p); c->num=0; /* drop through and do the rest */ } else { int ew,ec; c->num+=(int)len; if ((sc+len) < 4U) /* ugly, add char's to a word */ { l= p[sw]; p_c2l_p(data,l,sc,len); p[sw]=l; } else { ew=(c->num>>2); ec=(c->num&0x03); l= p[sw]; p_c2l(data,l,sc); p[sw++]=l; for (; sw < ew; sw++) { c2l(data,l); p[sw]=l; } if (ec) { c2l_p(data,l,ec); p[sw]=l; } } return; } } /* we now can process the input data in blocks of MD5_CBLOCK * chars and save the leftovers to c->data. */ p=c->data; while (len >= (size_t)MD5_CBLOCK) { #if defined(L_ENDIAN) || defined(B_ENDIAN) memcpy(p,data,MD5_CBLOCK); data+=MD5_CBLOCK; #ifdef B_ENDIAN for (sw=(MD5_LBLOCK/4); sw; sw--) { Endian_Reverse32(p[0]); Endian_Reverse32(p[1]); Endian_Reverse32(p[2]); Endian_Reverse32(p[3]); p+=4; } #endif #else for (sw=(MD5_LBLOCK/4); sw; sw--) { c2l(data,l); *(p++)=l; c2l(data,l); *(p++)=l; c2l(data,l); *(p++)=l; c2l(data,l); *(p++)=l; } #endif p=c->data; md5_block(c,p); len-=MD5_CBLOCK; } sc=(int)len; c->num=sc; if (sc) { sw=sc>>2; /* words to copy */ #ifdef L_ENDIAN p[sw]=0; memcpy(p,data,sc); #else sc&=0x03; for ( ; sw; sw--) { c2l(data,l); *(p++)=l; } c2l_p(data,l,sc); *p=l; #endif } } static void md5_block(c, X) MD5_CTX *c; register ULONG *X; { register ULONG A,B,C,D; A=c->A; B=c->B; C=c->C; D=c->D; /* Round 0 */ R0(A,B,C,D,X[ 0], 7,0xd76aa478L); R0(D,A,B,C,X[ 1],12,0xe8c7b756L); R0(C,D,A,B,X[ 2],17,0x242070dbL); R0(B,C,D,A,X[ 3],22,0xc1bdceeeL); R0(A,B,C,D,X[ 4], 7,0xf57c0fafL); R0(D,A,B,C,X[ 5],12,0x4787c62aL); R0(C,D,A,B,X[ 6],17,0xa8304613L); R0(B,C,D,A,X[ 7],22,0xfd469501L); R0(A,B,C,D,X[ 8], 7,0x698098d8L); R0(D,A,B,C,X[ 9],12,0x8b44f7afL); R0(C,D,A,B,X[10],17,0xffff5bb1L); R0(B,C,D,A,X[11],22,0x895cd7beL); R0(A,B,C,D,X[12], 7,0x6b901122L); R0(D,A,B,C,X[13],12,0xfd987193L); R0(C,D,A,B,X[14],17,0xa679438eL); R0(B,C,D,A,X[15],22,0x49b40821L); /* Round 1 */ R1(A,B,C,D,X[ 1], 5,0xf61e2562L); R1(D,A,B,C,X[ 6], 9,0xc040b340L); R1(C,D,A,B,X[11],14,0x265e5a51L); R1(B,C,D,A,X[ 0],20,0xe9b6c7aaL); R1(A,B,C,D,X[ 5], 5,0xd62f105dL); R1(D,A,B,C,X[10], 9,0x02441453L); R1(C,D,A,B,X[15],14,0xd8a1e681L); R1(B,C,D,A,X[ 4],20,0xe7d3fbc8L); R1(A,B,C,D,X[ 9], 5,0x21e1cde6L); R1(D,A,B,C,X[14], 9,0xc33707d6L); R1(C,D,A,B,X[ 3],14,0xf4d50d87L); R1(B,C,D,A,X[ 8],20,0x455a14edL); R1(A,B,C,D,X[13], 5,0xa9e3e905L); R1(D,A,B,C,X[ 2], 9,0xfcefa3f8L); R1(C,D,A,B,X[ 7],14,0x676f02d9L); R1(B,C,D,A,X[12],20,0x8d2a4c8aL); /* Round 2 */ R2(A,B,C,D,X[ 5], 4,0xfffa3942L); R2(D,A,B,C,X[ 8],11,0x8771f681L); R2(C,D,A,B,X[11],16,0x6d9d6122L); R2(B,C,D,A,X[14],23,0xfde5380cL); R2(A,B,C,D,X[ 1], 4,0xa4beea44L); R2(D,A,B,C,X[ 4],11,0x4bdecfa9L); R2(C,D,A,B,X[ 7],16,0xf6bb4b60L); R2(B,C,D,A,X[10],23,0xbebfbc70L); R2(A,B,C,D,X[13], 4,0x289b7ec6L); R2(D,A,B,C,X[ 0],11,0xeaa127faL); R2(C,D,A,B,X[ 3],16,0xd4ef3085L); R2(B,C,D,A,X[ 6],23,0x04881d05L); R2(A,B,C,D,X[ 9], 4,0xd9d4d039L); R2(D,A,B,C,X[12],11,0xe6db99e5L); R2(C,D,A,B,X[15],16,0x1fa27cf8L); R2(B,C,D,A,X[ 2],23,0xc4ac5665L); /* Round 3 */ R3(A,B,C,D,X[ 0], 6,0xf4292244L); R3(D,A,B,C,X[ 7],10,0x432aff97L); R3(C,D,A,B,X[14],15,0xab9423a7L); R3(B,C,D,A,X[ 5],21,0xfc93a039L); R3(A,B,C,D,X[12], 6,0x655b59c3L); R3(D,A,B,C,X[ 3],10,0x8f0ccc92L); R3(C,D,A,B,X[10],15,0xffeff47dL); R3(B,C,D,A,X[ 1],21,0x85845dd1L); R3(A,B,C,D,X[ 8], 6,0x6fa87e4fL); R3(D,A,B,C,X[15],10,0xfe2ce6e0L); R3(C,D,A,B,X[ 6],15,0xa3014314L); R3(B,C,D,A,X[13],21,0x4e0811a1L); R3(A,B,C,D,X[ 4], 6,0xf7537e82L); R3(D,A,B,C,X[11],10,0xbd3af235L); R3(C,D,A,B,X[ 2],15,0x2ad7d2bbL); R3(B,C,D,A,X[ 9],21,0xeb86d391L); c->A+=A&0xffffffffL; c->B+=B&0xffffffffL; c->C+=C&0xffffffffL; c->D+=D&0xffffffffL; } void MD5_Final(md, c) unsigned char *md; MD5_CTX *c; { register int i,j; register ULONG l; register ULONG *p; static unsigned char end[4]={0x80,0x00,0x00,0x00}; unsigned char *cp=end; /* c->num should definitly have room for at least one more byte. */ p=c->data; j=c->num; i=j>>2; /* purify often complains about the following line as an * Uninitialized Memory Read. While this can be true, the * following p_c2l macro will reset l when that case is true. * This is because j&0x03 contains the number of 'valid' bytes * already in p[i]. If and only if j&0x03 == 0, the UMR will * occur but this is also the only time p_c2l will do * l= *(cp++) instead of l|= *(cp++) * Many thanks to Alex Tang <[email protected]> for pickup this * 'potential bug' */ #ifdef PURIFY if ((j&0x03) == 0) p[i]=0; #endif l=p[i]; p_c2l(cp,l,j&0x03); p[i]=l; i++; /* i is the next 'undefined word' */ if (c->num >= MD5_LAST_BLOCK) { for (; i<MD5_LBLOCK; i++) p[i]=0; md5_block(c,p); i=0; } for (; i<(MD5_LBLOCK-2); i++) p[i]=0; p[MD5_LBLOCK-2]=c->Nl; p[MD5_LBLOCK-1]=c->Nh; md5_block(c,p); cp=md; l=c->A; l2c(l,cp); l=c->B; l2c(l,cp); l=c->C; l2c(l,cp); l=c->D; l2c(l,cp); /* clear stuff, md5_block may be leaving some stuff on the stack * but I'm not worried :-) */ c->num=0; /* memset((char *)&c,0,sizeof(c));*/ } #ifdef undef int printit(l) unsigned long *l; { int i,ii; for (i=0; i<2; i++) { for (ii=0; ii<8; ii++) { fprintf(stderr,"%08lx ",l[i*8+ii]); } fprintf(stderr,"\n"); } } #endif #endif /* HAVE_MD5 */ #endif /* USE_MD5 */
the_stack_data/10304.c
/******************************************************************************* * Copyright (C) 2009-2017 the original author(s). * * 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(_WIN32) || defined(_WIN64) #include <windows.h> void __cdecl __security_init_cookie(void); BOOL WINAPI _DllMainCRTStartup(HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved) { if (dwReason == DLL_PROCESS_ATTACH) __security_init_cookie(); return TRUE; } #endif /* defined(_WIN32) || defined(_WIN64) */
the_stack_data/1186022.c
/* $FreeBSD$ */ #define logo_width 88 #define logo_height 88 unsigned int logo_w = logo_width; unsigned int logo_h = logo_height; unsigned char logo_pal[768] = { 0x00, 0x00, 0x00, 0x33, 0x33, 0x33, 0x66, 0x66, 0x66, 0x99, 0x99, 0x99, 0xcc, 0xcc, 0xcc, 0xff, 0xff, 0xff, 0x90, 0x8f, 0x90, 0x56, 0x4b, 0x55, 0xa3, 0xa5, 0xab, 0xfd, 0xfd, 0xfd, 0x6d, 0x6e, 0x74, 0x41, 0x2b, 0x39, 0xcb, 0xc8, 0xcb, 0xcf, 0xbb, 0xba, 0x8e, 0x82, 0x87, 0x5c, 0x5d, 0x60, 0x52, 0x2a, 0x37, 0x7f, 0x76, 0x7d, 0x82, 0x82, 0x85, 0x7a, 0x3e, 0x45, 0x7f, 0x6e, 0x70, 0xef, 0xef, 0xed, 0x53, 0x41, 0x4b, 0x67, 0x2b, 0x35, 0x6a, 0x55, 0x62, 0xe7, 0xe2, 0xe3, 0x64, 0x35, 0x3f, 0xf7, 0xe0, 0xe7, 0xb1, 0xb2, 0xb2, 0x31, 0x2b, 0x35, 0x7a, 0x2d, 0x37, 0x69, 0x4c, 0x56, 0x95, 0x9d, 0xa4, 0x85, 0x61, 0x69, 0x40, 0x34, 0x41, 0x8f, 0x2e, 0x39, 0x7a, 0x50, 0x5a, 0xde, 0xe1, 0xe0, 0x32, 0x33, 0x3d, 0xa0, 0x9b, 0x9c, 0x68, 0x63, 0x67, 0x76, 0x60, 0x67, 0xba, 0xb6, 0xb8, 0x29, 0x24, 0x41, 0x38, 0x21, 0x29, 0x42, 0x21, 0x27, 0xa2, 0x2a, 0x32, 0x56, 0x55, 0x58, 0x55, 0x21, 0x2b, 0x7a, 0x20, 0x2a, 0x37, 0x16, 0x21, 0x4d, 0x18, 0x37, 0x8a, 0x3a, 0x3e, 0xc0, 0xc2, 0xc4, 0x64, 0x23, 0x2c, 0x37, 0x1a, 0x24, 0x42, 0x18, 0x20, 0x4c, 0x21, 0x2b, 0xa0, 0x23, 0x2e, 0x95, 0x6c, 0x76, 0x26, 0x16, 0x1c, 0xa5, 0x18, 0x23, 0x84, 0x20, 0x2b, 0x6d, 0x3f, 0x49, 0xae, 0xa7, 0xac, 0x2a, 0x1f, 0x24, 0x90, 0x21, 0x30, 0xa0, 0x39, 0x3e, 0x95, 0x0f, 0x1c, 0x84, 0x13, 0x1e, 0x4e, 0x17, 0x24, 0x8c, 0x56, 0x5f, 0xe0, 0xc4, 0xcb, 0xa5, 0x7f, 0x8e, 0xff, 0xff, 0xf1, 0x3d, 0x3d, 0x5d, 0x61, 0x19, 0x26, 0xd5, 0xd5, 0xd5, 0xff, 0xf1, 0xed, 0xb6, 0x9c, 0xa5, 0x87, 0x4c, 0x5a, 0xa0, 0x76, 0x76, 0xc8, 0xa0, 0xa0, 0xa2, 0xc1, 0xc8, 0x91, 0xae, 0xb6, 0x52, 0x8b, 0xae, 0xb3, 0xd2, 0xd4, 0x95, 0xb7, 0xc1, 0x54, 0x6e, 0x83, 0x67, 0x90, 0xa6, 0x44, 0x3e, 0x45, 0x23, 0x40, 0x6a, 0x41, 0x6e, 0x97, 0x7e, 0x8e, 0x91, 0x52, 0x33, 0x41, 0x39, 0x49, 0x68, 0x1d, 0x2a, 0x48, 0x17, 0x21, 0x45, 0x90, 0x17, 0x1f, 0x38, 0x54, 0x71, 0x1c, 0x33, 0x58, 0x1c, 0x1e, 0x23, 0x6c, 0x17, 0x21, 0xb0, 0xc5, 0xc1, 0x5d, 0x7f, 0x96, 0xe9, 0xbf, 0xc1, 0x96, 0x06, 0x0f, 0x78, 0x16, 0x1e, 0xab, 0x0e, 0x18, 0xa6, 0x06, 0x0e, 0x4c, 0x4c, 0x54, 0x61, 0x42, 0x4c, 0x48, 0x5f, 0x84, 0xa0, 0xb8, 0xbe, 0x5c, 0x66, 0x7f, 0x7b, 0x9e, 0xa9, 0x6f, 0x75, 0x7f, 0x45, 0x54, 0x74, 0x32, 0x3e, 0x63, 0xb1, 0xb4, 0xb3, 0x66, 0x9d, 0xb4, 0x7a, 0x9f, 0xbb, 0x82, 0xaa, 0xba, 0x13, 0x15, 0x17, 0x0b, 0x0b, 0x0a, 0x37, 0x66, 0x92, 0x4c, 0x7f, 0xa5, 0x24, 0x4c, 0x7b, 0x25, 0x5f, 0x91, 0x40, 0x7d, 0xa5, 0x1d, 0x56, 0x88, 0x2d, 0x6f, 0xa0, 0x70, 0x81, 0x8f, 0x58, 0x97, 0xbd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; unsigned char logo_img[logo_width*logo_height] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x05, 0x05, 0x05, 0x05, 0x04, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x05, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x03, 0x04, 0x05, 0x05, 0x09, 0x0a, 0x0b, 0x07, 0x0c, 0x05, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x0d, 0x0e, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x03, 0x04, 0x05, 0x05, 0x05, 0x05, 0x09, 0x0f, 0x0b, 0x10, 0x11, 0x09, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x12, 0x13, 0x14, 0x05, 0x05, 0x04, 0x03, 0x02, 0x01, 0x02, 0x02, 0x02, 0x03, 0x03, 0x04, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x15, 0x16, 0x0b, 0x17, 0x18, 0x19, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x11, 0x13, 0x1a, 0x1b, 0x05, 0x05, 0x05, 0x04, 0x03, 0x02, 0x03, 0x03, 0x03, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x1c, 0x1d, 0x10, 0x1e, 0x1f, 0x19, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x20, 0x0b, 0x1e, 0x21, 0x05, 0x05, 0x05, 0x05, 0x05, 0x04, 0x03, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x19, 0x22, 0x0b, 0x17, 0x23, 0x24, 0x15, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x25, 0x26, 0x10, 0x23, 0x27, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x04, 0x05, 0x05, 0x05, 0x25, 0x27, 0x11, 0x28, 0x29, 0x11, 0x06, 0x0d, 0x09, 0x05, 0x2a, 0x2b, 0x2c, 0x2d, 0x1e, 0x2e, 0x21, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x2f, 0x0b, 0x30, 0x31, 0x0c, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x15, 0x06, 0x16, 0x22, 0x1d, 0x2c, 0x32, 0x33, 0x17, 0x17, 0x17, 0x22, 0x14, 0x16, 0x1d, 0x2c, 0x2d, 0x1e, 0x2e, 0x34, 0x0c, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x35, 0x2b, 0x2c, 0x36, 0x36, 0x35, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x27, 0x0b, 0x2c, 0x2c, 0x37, 0x32, 0x38, 0x2c, 0x2d, 0x39, 0x36, 0x17, 0x30, 0x2c, 0x2c, 0x2d, 0x2c, 0x2c, 0x1a, 0x3a, 0x3a, 0x3b, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x0a, 0x2d, 0x2b, 0x33, 0x31, 0x0e, 0x05, 0x05, 0x05, 0x05, 0x09, 0x28, 0x2c, 0x37, 0x3c, 0x32, 0x38, 0x38, 0x37, 0x2c, 0x30, 0x36, 0x36, 0x17, 0x31, 0x36, 0x23, 0x23, 0x17, 0x2c, 0x17, 0x3a, 0x3d, 0x13, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x22, 0x2c, 0x37, 0x33, 0x3e, 0x31, 0x3f, 0x40, 0x19, 0x05, 0x11, 0x2c, 0x2c, 0x32, 0x32, 0x32, 0x38, 0x37, 0x41, 0x30, 0x3a, 0x3a, 0x2e, 0x42, 0x43, 0x17, 0x1a, 0x13, 0x23, 0x31, 0x1a, 0x2e, 0x3d, 0x1a, 0x09, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x0b, 0x37, 0x32, 0x37, 0x33, 0x44, 0x44, 0x45, 0x17, 0x1a, 0x10, 0x2d, 0x37, 0x38, 0x46, 0x33, 0x46, 0x32, 0x2c, 0x23, 0x23, 0x47, 0x21, 0x13, 0x43, 0x34, 0x48, 0x19, 0x49, 0x34, 0x17, 0x1e, 0x3a, 0x13, 0x4a, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x4b, 0x32, 0x32, 0x32, 0x32, 0x4c, 0x45, 0x44, 0x44, 0x42, 0x36, 0x30, 0x33, 0x46, 0x38, 0x33, 0x46, 0x38, 0x31, 0x23, 0x27, 0x09, 0x4a, 0x4d, 0x47, 0x43, 0x0d, 0x4e, 0x4a, 0x4f, 0x34, 0x1a, 0x2e, 0x29, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x11, 0x33, 0x32, 0x32, 0x32, 0x33, 0x4c, 0x31, 0x45, 0x3e, 0x31, 0x36, 0x46, 0x46, 0x33, 0x33, 0x39, 0x30, 0x23, 0x50, 0x4a, 0x4a, 0x4a, 0x4a, 0x4d, 0x47, 0x51, 0x4e, 0x4a, 0x4a, 0x0e, 0x13, 0x1a, 0x27, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x35, 0x2b, 0x32, 0x32, 0x2b, 0x32, 0x33, 0x4c, 0x33, 0x4c, 0x4c, 0x36, 0x30, 0x30, 0x30, 0x30, 0x31, 0x23, 0x3a, 0x49, 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, 0x4f, 0x50, 0x1b, 0x4e, 0x4a, 0x19, 0x50, 0x16, 0x0c, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x07, 0x32, 0x32, 0x32, 0x32, 0x2b, 0x33, 0x33, 0x30, 0x2d, 0x39, 0x30, 0x30, 0x30, 0x4c, 0x36, 0x42, 0x3a, 0x52, 0x05, 0x4a, 0x4a, 0x4a, 0x4a, 0x09, 0x3b, 0x52, 0x4e, 0x4a, 0x4a, 0x4f, 0x1a, 0x2a, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x4d, 0x2b, 0x2b, 0x32, 0x32, 0x32, 0x37, 0x2c, 0x2c, 0x2c, 0x2c, 0x2d, 0x10, 0x30, 0x30, 0x3e, 0x23, 0x3a, 0x0d, 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, 0x40, 0x51, 0x4a, 0x4a, 0x25, 0x15, 0x1f, 0x27, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x40, 0x22, 0x2c, 0x32, 0x32, 0x32, 0x38, 0x2d, 0x2c, 0x41, 0x32, 0x39, 0x46, 0x4c, 0x31, 0x2e, 0x2e, 0x0c, 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, 0x25, 0x53, 0x18, 0x4a, 0x54, 0x55, 0x56, 0x51, 0x11, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x2a, 0x22, 0x32, 0x32, 0x32, 0x38, 0x38, 0x32, 0x2c, 0x37, 0x38, 0x30, 0x30, 0x3e, 0x3a, 0x3a, 0x2a, 0x4a, 0x4a, 0x05, 0x4a, 0x57, 0x58, 0x59, 0x5a, 0x35, 0x58, 0x5b, 0x5c, 0x5d, 0x5e, 0x4a, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x4d, 0x07, 0x37, 0x32, 0x38, 0x38, 0x32, 0x32, 0x41, 0x38, 0x30, 0x30, 0x3e, 0x3a, 0x3d, 0x27, 0x05, 0x4a, 0x4a, 0x4a, 0x5c, 0x5f, 0x59, 0x1d, 0x29, 0x2f, 0x60, 0x61, 0x26, 0x0b, 0x1c, 0x05, 0x05, 0x04, 0x03, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x4e, 0x0a, 0x2d, 0x38, 0x38, 0x32, 0x37, 0x32, 0x2d, 0x39, 0x36, 0x31, 0x62, 0x3d, 0x0e, 0x4a, 0x4a, 0x4a, 0x09, 0x63, 0x64, 0x64, 0x61, 0x2d, 0x1d, 0x65, 0x61, 0x2b, 0x17, 0x16, 0x4a, 0x05, 0x05, 0x04, 0x03, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x05, 0x27, 0x2c, 0x38, 0x38, 0x37, 0x37, 0x38, 0x2d, 0x30, 0x31, 0x42, 0x3a, 0x18, 0x09, 0x05, 0x05, 0x4a, 0x63, 0x60, 0x60, 0x2b, 0x10, 0x2d, 0x41, 0x41, 0x30, 0x42, 0x3e, 0x29, 0x09, 0x05, 0x05, 0x04, 0x03, 0x03, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x2a, 0x37, 0x32, 0x38, 0x32, 0x41, 0x38, 0x38, 0x30, 0x66, 0x31, 0x3a, 0x1e, 0x67, 0x4a, 0x4a, 0x05, 0x68, 0x64, 0x61, 0x2b, 0x17, 0x36, 0x10, 0x33, 0x31, 0x42, 0x3d, 0x45, 0x06, 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x1c, 0x2c, 0x32, 0x32, 0x37, 0x41, 0x2c, 0x46, 0x30, 0x36, 0x36, 0x42, 0x42, 0x29, 0x1b, 0x4a, 0x4a, 0x4d, 0x26, 0x60, 0x0b, 0x17, 0x36, 0x44, 0x45, 0x66, 0x3e, 0x44, 0x44, 0x1a, 0x05, 0x05, 0x05, 0x05, 0x05, 0x15, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x0c, 0x2c, 0x32, 0x32, 0x38, 0x37, 0x32, 0x37, 0x30, 0x36, 0x4c, 0x31, 0x1e, 0x10, 0x1f, 0x52, 0x69, 0x52, 0x07, 0x2c, 0x10, 0x36, 0x62, 0x6a, 0x44, 0x6b, 0x3e, 0x44, 0x6c, 0x30, 0x09, 0x05, 0x05, 0x25, 0x54, 0x19, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x25, 0x2c, 0x37, 0x38, 0x37, 0x2c, 0x32, 0x32, 0x46, 0x30, 0x46, 0x4c, 0x31, 0x66, 0x4c, 0x36, 0x1a, 0x1a, 0x17, 0x37, 0x37, 0x10, 0x31, 0x62, 0x45, 0x4c, 0x3e, 0x44, 0x62, 0x30, 0x09, 0x05, 0x0a, 0x70, 0x71, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x22, 0x32, 0x32, 0x38, 0x41, 0x41, 0x38, 0x2d, 0x46, 0x66, 0x44, 0x6c, 0x6c, 0x6c, 0x3d, 0x3a, 0x42, 0x31, 0x32, 0x32, 0x32, 0x33, 0x33, 0x30, 0x36, 0x3e, 0x3e, 0x31, 0x07, 0x05, 0x12, 0x6e, 0x72, 0x09, 0x05, 0x05, 0x04, 0x03, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x2d, 0x2c, 0x38, 0x32, 0x41, 0x37, 0x2d, 0x46, 0x66, 0x6a, 0x6c, 0x6d, 0x6d, 0x6c, 0x3d, 0x3d, 0x31, 0x38, 0x38, 0x39, 0x33, 0x39, 0x36, 0x30, 0x30, 0x66, 0x30, 0x40, 0x4d, 0x5f, 0x4d, 0x4d, 0x05, 0x05, 0x05, 0x15, 0x04, 0x03, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x09, 0x5a, 0x2d, 0x32, 0x32, 0x37, 0x37, 0x32, 0x38, 0x46, 0x46, 0x66, 0x45, 0x44, 0x62, 0x44, 0x44, 0x3e, 0x31, 0x31, 0x31, 0x31, 0x31, 0x33, 0x37, 0x30, 0x10, 0x06, 0x05, 0x12, 0x0a, 0x05, 0x05, 0x05, 0x08, 0x68, 0x73, 0x05, 0x04, 0x03, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x35, 0x22, 0x32, 0x32, 0x32, 0x3c, 0x37, 0x37, 0x2d, 0x39, 0x39, 0x39, 0x36, 0x36, 0x6b, 0x3e, 0x3e, 0x3e, 0x3e, 0x31, 0x4c, 0x39, 0x2d, 0x10, 0x16, 0x2a, 0x05, 0x05, 0x74, 0x74, 0x05, 0x05, 0x0c, 0x75, 0x5f, 0x1c, 0x05, 0x05, 0x04, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x40, 0x2c, 0x32, 0x32, 0x32, 0x41, 0x37, 0x41, 0x2c, 0x2c, 0x41, 0x2c, 0x33, 0x36, 0x31, 0x36, 0x31, 0x31, 0x17, 0x46, 0x2c, 0x16, 0x40, 0x05, 0x05, 0x05, 0x05, 0x20, 0x5f, 0x4d, 0x72, 0x76, 0x06, 0x25, 0x4a, 0x05, 0x05, 0x05, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x40, 0x0b, 0x2d, 0x37, 0x2d, 0x2c, 0x2c, 0x37, 0x37, 0x38, 0x2c, 0x37, 0x2c, 0x10, 0x10, 0x39, 0x30, 0x0b, 0x2c, 0x11, 0x09, 0x05, 0x09, 0x4a, 0x05, 0x05, 0x19, 0x1d, 0x26, 0x76, 0x08, 0x05, 0x05, 0x05, 0x15, 0x25, 0x4d, 0x53, 0x77, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x4d, 0x5a, 0x2c, 0x37, 0x2d, 0x2c, 0x37, 0x37, 0x39, 0x39, 0x33, 0x38, 0x2c, 0x2d, 0x2d, 0x2c, 0x5e, 0x2a, 0x05, 0x15, 0x3b, 0x17, 0x1f, 0x19, 0x05, 0x06, 0x26, 0x60, 0x5f, 0x0c, 0x05, 0x05, 0x05, 0x35, 0x68, 0x78, 0x56, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x35, 0x2c, 0x2c, 0x2c, 0x37, 0x32, 0x37, 0x2c, 0x37, 0x32, 0x46, 0x33, 0x46, 0x39, 0x11, 0x15, 0x05, 0x05, 0x18, 0x31, 0x44, 0x6a, 0x30, 0x6e, 0x2b, 0x4b, 0x11, 0x5f, 0x63, 0x72, 0x54, 0x20, 0x74, 0x58, 0x25, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x15, 0x0b, 0x2c, 0x38, 0x2d, 0x39, 0x39, 0x2d, 0x37, 0x3c, 0x32, 0x37, 0x0b, 0x18, 0x05, 0x05, 0x05, 0x4e, 0x26, 0x32, 0x45, 0x6a, 0x46, 0x2b, 0x72, 0x4e, 0x05, 0x35, 0x0a, 0x75, 0x5f, 0x70, 0x08, 0x09, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x35, 0x22, 0x2d, 0x30, 0x6b, 0x6b, 0x66, 0x36, 0x30, 0x36, 0x4c, 0x36, 0x30, 0x18, 0x05, 0x05, 0x05, 0x09, 0x4b, 0x32, 0x46, 0x66, 0x38, 0x0b, 0x09, 0x05, 0x05, 0x05, 0x05, 0x09, 0x05, 0x05, 0x05, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x0a, 0x2c, 0x2c, 0x31, 0x62, 0x62, 0x6b, 0x31, 0x45, 0x44, 0x44, 0x45, 0x31, 0x10, 0x0c, 0x4d, 0x0c, 0x08, 0x0b, 0x3c, 0x32, 0x33, 0x66, 0x17, 0x06, 0x05, 0x05, 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x09, 0x22, 0x2c, 0x2d, 0x31, 0x45, 0x6b, 0x36, 0x31, 0x6b, 0x62, 0x45, 0x6a, 0x66, 0x30, 0x0b, 0x2c, 0x2c, 0x2c, 0x2c, 0x37, 0x46, 0x6b, 0x44, 0x62, 0x5e, 0x05, 0x05, 0x05, 0x05, 0x04, 0x03, 0x03, 0x03, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x0c, 0x1d, 0x2c, 0x39, 0x36, 0x4c, 0x30, 0x30, 0x30, 0x36, 0x4c, 0x66, 0x4c, 0x36, 0x30, 0x37, 0x41, 0x2c, 0x2d, 0x2c, 0x3c, 0x33, 0x6b, 0x44, 0x44, 0x39, 0x09, 0x05, 0x05, 0x04, 0x03, 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x2d, 0x2d, 0x2d, 0x36, 0x39, 0x2d, 0x32, 0x38, 0x38, 0x46, 0x6a, 0x6d, 0x3d, 0x62, 0x46, 0x3c, 0x37, 0x2d, 0x32, 0x32, 0x32, 0x38, 0x4c, 0x30, 0x16, 0x05, 0x05, 0x04, 0x03, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x0a, 0x37, 0x38, 0x38, 0x39, 0x37, 0x2c, 0x37, 0x37, 0x30, 0x45, 0x6d, 0x6d, 0x62, 0x62, 0x38, 0x3c, 0x3c, 0x32, 0x37, 0x32, 0x32, 0x32, 0x2c, 0x14, 0x15, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x6e, 0x37, 0x38, 0x38, 0x38, 0x37, 0x2c, 0x2d, 0x30, 0x31, 0x62, 0x6a, 0x6d, 0x6a, 0x6a, 0x46, 0x32, 0x32, 0x37, 0x37, 0x32, 0x30, 0x17, 0x29, 0x05, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x4a, 0x0b, 0x38, 0x38, 0x38, 0x2c, 0x2c, 0x0b, 0x2d, 0x39, 0x4c, 0x45, 0x6a, 0x6a, 0x6a, 0x6a, 0x6a, 0x38, 0x37, 0x2c, 0x41, 0x18, 0x1c, 0x0c, 0x05, 0x04, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x15, 0x0b, 0x2d, 0x38, 0x38, 0x37, 0x2c, 0x2c, 0x2c, 0x37, 0x32, 0x4c, 0x6b, 0x44, 0x44, 0x45, 0x6a, 0x45, 0x38, 0x37, 0x1c, 0x09, 0x05, 0x05, 0x04, 0x03, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x09, 0x1d, 0x38, 0x38, 0x38, 0x38, 0x2c, 0x3c, 0x37, 0x37, 0x32, 0x32, 0x46, 0x36, 0x1e, 0x6b, 0x4c, 0x46, 0x32, 0x22, 0x09, 0x05, 0x05, 0x04, 0x03, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x07, 0x37, 0x32, 0x37, 0x38, 0x38, 0x37, 0x32, 0x3c, 0x32, 0x32, 0x37, 0x38, 0x2d, 0x2d, 0x38, 0x2c, 0x2c, 0x4f, 0x05, 0x05, 0x04, 0x03, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x08, 0x3c, 0x37, 0x41, 0x38, 0x2d, 0x37, 0x37, 0x3c, 0x32, 0x3c, 0x32, 0x37, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x0c, 0x41, 0x3c, 0x3c, 0x38, 0x32, 0x3c, 0x3c, 0x3c, 0x41, 0x32, 0x41, 0x37, 0x2c, 0x2c, 0x41, 0x38, 0x45, 0x18, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x2a, 0x2c, 0x3c, 0x37, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x37, 0x2c, 0x2c, 0x2c, 0x2c, 0x4c, 0x45, 0x6a, 0x1a, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x11, 0x2c, 0x37, 0x41, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x41, 0x37, 0x37, 0x4c, 0x44, 0x6d, 0x6a, 0x1a, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x5a, 0x2c, 0x41, 0x3c, 0x3c, 0x3c, 0x32, 0x2c, 0x32, 0x2c, 0x2c, 0x38, 0x38, 0x36, 0x45, 0x62, 0x44, 0x45, 0x29, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x2a, 0x2c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x37, 0x37, 0x32, 0x37, 0x39, 0x4c, 0x4c, 0x45, 0x62, 0x44, 0x62, 0x30, 0x2a, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x4a, 0x5a, 0x41, 0x3c, 0x3c, 0x3c, 0x3c, 0x32, 0x3c, 0x37, 0x37, 0x2d, 0x46, 0x4c, 0x6b, 0x6b, 0x45, 0x3e, 0x36, 0x29, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x03, 0x04, 0x05, 0x05, 0x27, 0x3c, 0x37, 0x3c, 0x3c, 0x37, 0x37, 0x32, 0x38, 0x37, 0x37, 0x37, 0x38, 0x39, 0x36, 0x4c, 0x30, 0x10, 0x16, 0x09, 0x05, 0x05, 0x04, 0x03, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x03, 0x04, 0x05, 0x05, 0x25, 0x1d, 0x37, 0x37, 0x41, 0x32, 0x3c, 0x32, 0x41, 0x37, 0x32, 0x2c, 0x41, 0x37, 0x2c, 0x32, 0x37, 0x2c, 0x2c, 0x5a, 0x0c, 0x05, 0x05, 0x05, 0x04, 0x03, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x04, 0x05, 0x05, 0x15, 0x5a, 0x37, 0x2c, 0x41, 0x2c, 0x2c, 0x41, 0x37, 0x41, 0x41, 0x3c, 0x2c, 0x41, 0x41, 0x3c, 0x37, 0x2c, 0x39, 0x0b, 0x0b, 0x25, 0x05, 0x05, 0x05, 0x05, 0x04, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x05, 0x05, 0x2a, 0x22, 0x2d, 0x37, 0x2c, 0x3c, 0x1d, 0x2c, 0x38, 0x2c, 0x41, 0x2c, 0x2c, 0x2d, 0x39, 0x37, 0x3c, 0x37, 0x30, 0x1a, 0x5e, 0x6e, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x2a, 0x6e, 0x0b, 0x2d, 0x38, 0x41, 0x41, 0x6e, 0x5a, 0x2c, 0x41, 0x32, 0x38, 0x32, 0x39, 0x3f, 0x6f, 0x16, 0x37, 0x1a, 0x1f, 0x1f, 0x16, 0x1d, 0x0c, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x09, 0x40, 0x07, 0x2c, 0x37, 0x2c, 0x2d, 0x2c, 0x1d, 0x0e, 0x09, 0x0b, 0x4b, 0x07, 0x41, 0x38, 0x2d, 0x10, 0x2d, 0x10, 0x0b, 0x2b, 0x33, 0x3f, 0x21, 0x29, 0x07, 0x5e, 0x2f, 0x12, 0x08, 0x2a, 0x0c, 0x25, 0x09, 0x09, 0x09, 0x05, 0x05, 0x05, 0x05, 0x04, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x05, 0x19, 0x40, 0x28, 0x22, 0x2c, 0x38, 0x32, 0x32, 0x32, 0x1d, 0x0e, 0x19, 0x05, 0x35, 0x2c, 0x4b, 0x70, 0x0b, 0x32, 0x2c, 0x16, 0x16, 0x16, 0x0b, 0x22, 0x26, 0x0b, 0x10, 0x3f, 0x29, 0x1f, 0x47, 0x1f, 0x1f, 0x5e, 0x0b, 0x4b, 0x74, 0x84, 0x74, 0x84, 0x06, 0x35, 0x09, 0x05, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x03, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x09, 0x4d, 0x27, 0x0a, 0x22, 0x1d, 0x2c, 0x2c, 0x37, 0x32, 0x41, 0x41, 0x16, 0x27, 0x15, 0x09, 0x4a, 0x09, 0x28, 0x2d, 0x0b, 0x76, 0x2c, 0x37, 0x2d, 0x37, 0x32, 0x37, 0x0b, 0x0b, 0x5e, 0x5a, 0x4b, 0x0b, 0x0b, 0x07, 0x6e, 0x16, 0x5e, 0x10, 0x76, 0x5c, 0x68, 0x79, 0x7a, 0x53, 0x71, 0x54, 0x5d, 0x08, 0x4d, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x03, 0x04, 0x05, 0x05, 0x05, 0x25, 0x27, 0x28, 0x0b, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x41, 0x41, 0x41, 0x22, 0x11, 0x35, 0x4d, 0x4d, 0x35, 0x1c, 0x06, 0x0a, 0x22, 0x38, 0x38, 0x37, 0x38, 0x38, 0x38, 0x2d, 0x39, 0x39, 0x39, 0x10, 0x39, 0x10, 0x4b, 0x12, 0x08, 0x35, 0x67, 0x2a, 0x08, 0x74, 0x70, 0x81, 0x55, 0x78, 0x79, 0x57, 0x53, 0x71, 0x71, 0x73, 0x84, 0x25, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x04, 0x05, 0x09, 0x27, 0x16, 0x0b, 0x2c, 0x2d, 0x2c, 0x41, 0x41, 0x1d, 0x22, 0x5a, 0x0f, 0x14, 0x0a, 0x28, 0x0a, 0x28, 0x28, 0x28, 0x6e, 0x5a, 0x65, 0x1d, 0x0b, 0x2d, 0x38, 0x46, 0x38, 0x38, 0x38, 0x39, 0x2d, 0x46, 0x39, 0x30, 0x39, 0x4b, 0x68, 0x79, 0x7a, 0x57, 0x67, 0x67, 0x56, 0x53, 0x71, 0x68, 0x7e, 0x85, 0x59, 0x73, 0x79, 0x54, 0x7a, 0x54, 0x06, 0x1c, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x05, 0x4d, 0x16, 0x0b, 0x10, 0x39, 0x2d, 0x0b, 0x28, 0x06, 0x2a, 0x25, 0x35, 0x06, 0x11, 0x0a, 0x28, 0x07, 0x5a, 0x22, 0x26, 0x5a, 0x41, 0x7b, 0x7c, 0x60, 0x76, 0x22, 0x1d, 0x32, 0x38, 0x46, 0x46, 0x46, 0x38, 0x38, 0x38, 0x38, 0x2b, 0x75, 0x7d, 0x7e, 0x55, 0x78, 0x7a, 0x57, 0x57, 0x57, 0x71, 0x20, 0x68, 0x55, 0x85, 0x7a, 0x57, 0x53, 0x71, 0x57, 0x5d, 0x19, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x0c, 0x16, 0x0b, 0x30, 0x39, 0x18, 0x2a, 0x09, 0x05, 0x4e, 0x19, 0x25, 0x0c, 0x27, 0x11, 0x0a, 0x0a, 0x2f, 0x5a, 0x5a, 0x26, 0x5a, 0x7b, 0x7c, 0x7c, 0x61, 0x7f, 0x7f, 0x7f, 0x76, 0x22, 0x22, 0x0b, 0x2d, 0x0b, 0x2d, 0x2d, 0x33, 0x0b, 0x5f, 0x80, 0x7d, 0x5c, 0x81, 0x55, 0x59, 0x59, 0x73, 0x73, 0x54, 0x5c, 0x5c, 0x7e, 0x55, 0x59, 0x73, 0x7a, 0x71, 0x19, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x05, 0x05, 0x05, 0x09, 0x25, 0x08, 0x07, 0x5e, 0x10, 0x22, 0x1c, 0x4a, 0x05, 0x09, 0x05, 0x15, 0x4d, 0x19, 0x19, 0x4d, 0x08, 0x12, 0x74, 0x0f, 0x6e, 0x5a, 0x26, 0x1d, 0x7b, 0x7b, 0x7c, 0x7c, 0x7c, 0x61, 0x5b, 0x82, 0x82, 0x80, 0x80, 0x82, 0x7f, 0x7f, 0x7f, 0x7f, 0x5b, 0x7f, 0x82, 0x80, 0x7d, 0x5c, 0x7e, 0x79, 0x54, 0x54, 0x7a, 0x73, 0x0f, 0x2a, 0x25, 0x19, 0x09, 0x4a, 0x05, 0x05, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x09, 0x4d, 0x2a, 0x06, 0x74, 0x28, 0x22, 0x22, 0x2d, 0x2c, 0x0e, 0x05, 0x05, 0x05, 0x05, 0x05, 0x3b, 0x07, 0x19, 0x09, 0x25, 0x0c, 0x27, 0x12, 0x0f, 0x2f, 0x26, 0x26, 0x1d, 0x65, 0x65, 0x7c, 0x7c, 0x7b, 0x7c, 0x7b, 0x7b, 0x60, 0x5b, 0x7f, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x80, 0x80, 0x83, 0x83, 0x81, 0x7e, 0x59, 0x73, 0x73, 0x84, 0x5d, 0x25, 0x05, 0x05, 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x19, 0x08, 0x12, 0x0a, 0x0f, 0x6e, 0x5a, 0x26, 0x22, 0x2c, 0x2c, 0x0b, 0x27, 0x05, 0x05, 0x05, 0x15, 0x1e, 0x1e, 0x6f, 0x0c, 0x09, 0x15, 0x0c, 0x20, 0x12, 0x0f, 0x6e, 0x5a, 0x26, 0x26, 0x26, 0x65, 0x65, 0x65, 0x65, 0x7b, 0x7c, 0x7b, 0x65, 0x7b, 0x61, 0x61, 0x60, 0x64, 0x64, 0x64, 0x5b, 0x5b, 0x5f, 0x63, 0x70, 0x63, 0x58, 0x5d, 0x2a, 0x15, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x4a, 0x4d, 0x27, 0x11, 0x0a, 0x28, 0x6e, 0x5a, 0x26, 0x65, 0x41, 0x1d, 0x2c, 0x2c, 0x5e, 0x29, 0x0e, 0x14, 0x17, 0x31, 0x6b, 0x30, 0x14, 0x25, 0x09, 0x15, 0x4d, 0x08, 0x74, 0x0a, 0x0f, 0x2f, 0x5a, 0x26, 0x26, 0x1d, 0x1d, 0x1d, 0x2b, 0x65, 0x1d, 0x41, 0x65, 0x65, 0x7b, 0x65, 0x65, 0x1d, 0x6e, 0x74, 0x5d, 0x1c, 0x25, 0x15, 0x05, 0x05, 0x05, 0x05, 0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x09, 0x19, 0x4d, 0x08, 0x06, 0x0a, 0x2f, 0x6e, 0x2f, 0x6e, 0x26, 0x41, 0x7b, 0x65, 0x41, 0x37, 0x33, 0x30, 0x36, 0x36, 0x4c, 0x6b, 0x66, 0x30, 0x14, 0x35, 0x4a, 0x09, 0x15, 0x15, 0x25, 0x25, 0x0c, 0x1c, 0x08, 0x06, 0x5d, 0x5d, 0x5d, 0x0e, 0x06, 0x12, 0x06, 0x08, 0x1c, 0x2a, 0x0c, 0x19, 0x09, 0x05, 0x05, 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x09, 0x09, 0x19, 0x35, 0x08, 0x12, 0x28, 0x2f, 0x2f, 0x6e, 0x5a, 0x41, 0x7c, 0x3c, 0x3c, 0x2c, 0x41, 0x2d, 0x2d, 0x39, 0x30, 0x4c, 0x4c, 0x66, 0x66, 0x31, 0x24, 0x20, 0x4a, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x4a, 0x09, 0x4a, 0x09, 0x09, 0x05, 0x09, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x09, 0x15, 0x0c, 0x1c, 0x12, 0x28, 0x2f, 0x5a, 0x1d, 0x7c, 0x7b, 0x41, 0x7b, 0x3c, 0x7b, 0x3c, 0x41, 0x41, 0x5a, 0x16, 0x28, 0x14, 0x14, 0x14, 0x3b, 0x12, 0x05, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x05, 0x4a, 0x09, 0x15, 0x1c, 0x12, 0x12, 0x0a, 0x0f, 0x2f, 0x07, 0x2f, 0x0a, 0x12, 0x27, 0x0c, 0x4d, 0x15, 0x09, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x09, 0x15, 0x15, 0x15, 0x19, 0x4e, 0x4e, 0x05, 0x4a, 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; unsigned int logo_img_size = sizeof(logo_img);
the_stack_data/140764640.c
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #define TAM_INI 50 #define FACTOR 2 typedef struct _pila { size_t tam; size_t cant_elem; void* *datos; } pila_t; pila_t* pila_crear() { pila_t *pila = malloc (sizeof(pila_t)); if (pila == NULL) return NULL; pila->datos = malloc (TAM_INI*sizeof(void*)); if (pila->datos == NULL){ free (pila); return NULL; } pila->tam = TAM_INI; pila->cant_elem = 0; return pila; } void pila_destruir(pila_t *pila){ free (pila->datos); free (pila); } bool pila_esta_vacia(const pila_t *pila){ if (pila->cant_elem == 0){ return true; } return false; } bool redimensionar_pila (pila_t *pila, size_t tam_nuevo){ void* datos_nuevo = realloc (pila->datos, tam_nuevo * sizeof(void*)); if (datos_nuevo == NULL){ return false; } pila->datos = datos_nuevo; pila->tam = tam_nuevo; return true; } bool redimensionar(pila_t *pila, int proporcion){ if (proporcion == 33){ return redimensionar_pila(pila, (pila->tam/2)); } return false; } bool pila_apilar(pila_t *pila, void *valor){ if (pila->cant_elem == pila->tam){ if (redimensionar_pila(pila, FACTOR * pila->tam)){ pila->datos[pila->cant_elem] = valor; pila->cant_elem = pila->cant_elem + 1; return true; } return false; } pila->datos[pila->cant_elem] = valor; pila->cant_elem = pila->cant_elem + 1; return true; } void* pila_ver_tope(const pila_t *pila){ if (pila_esta_vacia(pila)){ return NULL; } return pila->datos[pila->cant_elem-1]; } void* pila_desapilar(pila_t *pila){ int proporcion; if (pila_esta_vacia(pila)){ return NULL; } proporcion =((pila->cant_elem)/(pila->tam))*100; if (redimensionar(pila, proporcion)){ pila->cant_elem = pila->cant_elem - 1; return pila->datos[pila->cant_elem]; }; pila->cant_elem = pila->cant_elem - 1; return pila->datos[pila->cant_elem]; }
the_stack_data/154829992.c
typedef float fftw_real; void __attribute__ ((noinline)) complex_transpose(fftw_real *rA, fftw_real *iA, int n, int is, int js); void complex_transpose(fftw_real *rA, fftw_real *iA, int n, int is, int js) { int i, j; for (i = 1; i < n; ++i) { for (j = 0; j < i; ++j) { fftw_real ar, ai, br, bi; ar = rA[i * is + j * js]; ai = iA[i * is + j * js]; br = rA[j * is + i * js]; bi = iA[j * is + i * js]; rA[j * is + i * js] = ar; iA[j * is + i * js] = ai; rA[i * is + j * js] = br; iA[i * is + j * js] = bi; } } } extern int printf(const char *str, ...); fftw_real A[2048]; int main(int argc, char **argv) { int i; fftw_real sum = 0.0; for (i = 0; i < 2048; ++i) { A[i] = i; sum = sum + A[i]; } printf("Checksum before = %lf\n", sum); for (i = 0; i < 10; ++i) { complex_transpose(A, A+1, 32, 2, 64); } sum = 0.0; for (i = 0; i < 2048; ++i) sum = sum + A[i]; printf("Checksum after = %lf\n", sum); return 0; }
the_stack_data/121337.c
extern void foo(); extern void bar(); int main() { foo(); bar(); return 0; }
the_stack_data/90766629.c
#include<stdio.h> #include<stdlib.h> // An AVL tree node struct node{ int key; struct node *left; struct node *right; int height; }; // A utility function to get maximum of two integers int max(int a, int b); // A utility function to get height of the tree int height(struct node *n){ if (n == NULL) return 0; return n->height; } // A utility function to get maximum of two integers int max(int a, int b){ return (a > b)? a : b; } /* Helper function that allocates a new node with the given key and NULL left and right pointers. */ struct node* newNode(int key){ struct node* node = (struct node*)malloc(sizeof(struct node)); node->key = key; node->left = NULL; node->right = NULL; node->height = 1; // new node is initially added at leaf return(node); } // A utility function to right rotate subtree rooted with y // See the diagram given above. struct node *rightRotate(struct node *y){ struct node *x = y->left; struct node *T2 = x->right; // Perform rotation x->right = y; y->left = T2; // Update heights y->height = max(height(y->left), height(y->right))+1; x->height = max(height(x->left), height(x->right))+1; // Return new root return x; } // A utility function to left rotate subtree rooted with x // See the diagram given above. struct node *leftRotate(struct node *x){ struct node *y = x->right; struct node *T2 = y->left; // Perform rotation y->left = x; x->right = T2; // Update heights x->height = max(height(x->left), height(x->right))+1; y->height = max(height(y->left), height(y->right))+1; // Return new root return y; } // Get Balance factor of node N int getBalance(struct node *n){ if (n == NULL) return 0; return height(n->left) - height(n->right); } struct node* insert(struct node* node, int key){ /* 1. Perform the normal BST insertion */ if (node == NULL) return(newNode(key)); if (key < node->key) node->left = insert(node->left, key); else node->right = insert(node->right, key); /* 2. Update height of this ancestor node */ node->height = max(height(node->left), height(node->right)) + 1; /* 3. Get the balance factor of this ancestor node to check whether this node became unbalanced */ int balance = getBalance(node); // If this node becomes unbalanced, then there are 4 cases // Left Left Case if (balance > 1 && key < node->left->key) return rightRotate(node); // Right Right Case if (balance < -1 && key > node->right->key) return leftRotate(node); // Left Right Case if (balance > 1 && key > node->left->key){ node->left = leftRotate(node->left); return rightRotate(node); } // Right Left Case if (balance < -1 && key < node->right->key){ node->right = rightRotate(node->right); return leftRotate(node); } /* return the (unchanged) node pointer */ return node; } /* Given a non-empty binary search tree, return the node with minimum key value found in that tree. Note that the entire tree does not need to be searched. */ struct node * minValueNode(struct node* node) { struct node* current = node; /* loop down to find the leftmost leaf */ while (current->left != NULL) current = current->left; return current; } struct node* deleteNode(struct node* root, int key) { // STEP 1: PERFORM STANDARD BST DELETE if (root == NULL) return root; // If the key to be deleted is smaller than the root's key, // then it lies in left subtree if ( key < root->key ) root->left = deleteNode(root->left, key); // If the key to be deleted is greater than the root's key, // then it lies in right subtree else if( key > root->key ) root->right = deleteNode(root->right, key); // if key is same as root's key, then This is the node // to be deleted else { // node with only one child or no child if( (root->left == NULL) || (root->right == NULL) ){ struct node *temp = root->left ? root->left : root->right; // No child case if(temp == NULL) { temp = root; root = NULL; } else // One child case *root = *temp; // Copy the contents of the non-empty child free(temp); } else { // node with two children: Get the inorder successor (smallest // in the right subtree) struct node* temp = minValueNode(root->right); // Copy the inorder successor's data to this node root->key = temp->key; // Delete the inorder successor root->right = deleteNode(root->right, temp->key); } } // If the tree had only one node then return if (root == NULL) return root; // STEP 2: UPDATE HEIGHT OF THE CURRENT NODE root->height = max(height(root->left), height(root->right)) + 1; // STEP 3: GET THE BALANCE FACTOR OF THIS NODE (to check whether // this node became unbalanced) int balance = getBalance(root); // If this node becomes unbalanced, then there are 4 cases // Left Left Case if (balance > 1 && getBalance(root->left) >= 0) return rightRotate(root); // Left Right Case if (balance > 1 && getBalance(root->left) < 0) { root->left = leftRotate(root->left); return rightRotate(root); } // Right Right Case if (balance < -1 && getBalance(root->right) <= 0) return leftRotate(root); // Right Left Case if (balance < -1 && getBalance(root->right) > 0) { root->right = rightRotate(root->right); return leftRotate(root); } return root; } // A utility function to print preorder traversal of the tree. // The function also prints height of every node void preOrder(struct node *root){ if(root != NULL) { printf("%d ", root->key); preOrder(root->left); preOrder(root->right); } } void postOrder(struct node *root){ if(root != NULL) { preOrder(root->left); preOrder(root->right); printf("%d ", root->key); } } /* Drier program to test above function*/ int main(){ struct node *root = NULL; /* Constructing tree given in the above figure */ root = insert(root, 9); root = insert(root, 5); root = insert(root, 10); root = insert(root, 0); root = insert(root, 6); root = insert(root, 11); root = insert(root, -1); root = insert(root, 1); root = insert(root, 2); /* The constructed AVL Tree would be 9 / \ 1 10 / \ \ 0 5 11 / / \ -1 2 6 */ printf("Pre order traversal of the constructed AVL tree is \n"); preOrder(root); root = deleteNode(root, 10); /* The AVL Tree after deletion of 10 1 / \ 0 9 / / \ -1 5 11 / \ 2 6 */ printf("\nPre order traversal after deletion of 10 \n"); preOrder(root); return 0; }
the_stack_data/29686.c
/*Faça um programa de pesquisa de um cinema sobre uma determinado filme. As pessoas informam o sexo, idade e opinião sobre o filme (Ruim, Bom ou Ótimo) e os dados são armazenados numa lista duplamente encadeada. O programa deve permitir fornecer: (1) a média de idade das pessoas com uma determinada opinião; (2) a porcentagem de pessoas que responderam a pesquisa por sexo; e (3) a porcentagem de cada opinião.*/ #include <stdio.h> #include <stdlib.h> #include <string.h> typedef int id; typedef int op; typedef int ge; int nCadastro; struct pessoa{ id idade; op opiniao; ge genero; struct pessoa *dir; struct pessoa *esq; }; struct pessoa *participante = NULL; void menu(){ printf("\n-----------------------------------------------------------------\n"); printf("\tCADASTRO DE OPINIAO SOBRE O FILME\n"); printf("-----------------------------------------------------------------\n"); printf("Escolha a opcao abaixo:\n"); printf("1 - Cadastro de opiniao\n"); printf("2 - Média de idade das pessoas com uma determinada opiniao\n"); printf("3 - Porcentagem de pessoas que responderam a pesquisa por genero\n"); printf("4 - Porcentagem de cada opiniao\n"); printf("5 - Listar opinioes\n"); printf("6 - Finalizar sistema\n"); } void adicionarOpiniao(){//id idade, op opiniao, ge genero){ struct pessoa *novo_participante = (struct pessoa *)malloc(sizeof(struct pessoa)); //novo_participante->idade = idade; //novo_participante->opiniao = opiniao; //novo_participante->genero = genero; printf("\nDigite a idade: "); scanf("%d", &novo_participante->idade); printf("\nDigite o genero: "); printf("\n1-Feminino\n2-Masculino\nDigite: "); scanf("%d", &novo_participante->genero); printf("\nDigite a opniao sobre o filme: "); printf("\n1-Ruim\n2-Bom\n3-Otimo\nDigite: "); scanf("%d", &novo_participante->opiniao); if(participante==NULL){ novo_participante->dir=NULL; novo_participante->esq=NULL; participante = novo_participante; }else{ novo_participante->dir = participante; if(participante->esq==NULL){ novo_participante->esq = NULL; }else{ novo_participante->esq=participante->esq; participante->esq->dir=novo_participante; } participante->esq=novo_participante; } nCadastro ++; } void imprimir(id ida, ge gen, op opi){ printf("\nIdade: %d | Genero: %d | Opiniao: %d", ida,gen,opi); } void listar(){ struct pessoa *p=participante; if(participante!=NULL){ do{ imprimir(p->idade, p->genero,p->opiniao); printf("\n\n"); p = p->dir; }while(p!=NULL); p=participante->esq; while(p!=NULL){ imprimir(p->idade,p->genero,p->opiniao); printf("\n\n"); p=p->esq; } } } //case 2 - Média de idade das pessoas com uma determinada opiniao void case2(){ float mRuim, mBom, mOtimo; struct pessoa *p=participante; if(participante!=NULL){ do{ if(p->opiniao==1){ mRuim = (p->idade)+mRuim; }else{ if(p->opiniao==2){ mBom = mBom + (p->idade); }else{ mOtimo = mOtimo + (p->idade); } } p = p->dir; }while(p!=NULL); p=participante->esq; while(p!=NULL){ p=p->esq; } } printf("\nMedia de idade opiniao do tipo Ruim: %d",mRuim/nCadastro); printf("\nMedia de idade opiniao do tipo Bom: %d",mBom/nCadastro); printf("\nMedia de idade opiniao do tipo Otimo: %d",mOtimo/nCadastro); } //case 3 - Porcentagem de pessoas que responderam a pesquisa por genero void case3(){ int f, m; struct pessoa *p=participante; if(participante!=NULL){ do{ if(p->genero==1){ f++; }else{ m++; } p = p->dir; }while(p!=NULL); p=participante->esq; while(p!=NULL){ if(p->genero==1){ f++; }else{ m++; } p=p->esq; } } printf("\nPorcentagem de resposatas femininas: %d",(f*100)/nCadastro); printf("\nPorcentagem de resposatas masculinas: %d",(m*100)/nCadastro); } //case 4 - Porcentagem de cada opiniao void case4(){ int ruim, bom, otimo; struct pessoa *p=participante; if(participante!=NULL){ do{ if(p->opiniao==1){ ruim++; }else{ if(p->opiniao==2){ bom++; }else{ otimo++; } } p = p->dir; }while(p!=NULL); p=participante->esq; while(p!=NULL){ if(p->opiniao==1){ ruim++; }else{ if(p->opiniao==2){ bom++; }else{ otimo++; } } p=p->esq; } } printf("\nPorcentagem de opiniao do tipo Ruim: %d",(ruim*100)/nCadastro); printf("\nPorcentagem de opiniao do tipo Bom: %d",(bom*100)/nCadastro); printf("\nPorcentagem de opiniao do tipo Otimo: %d",(otimo*100)/nCadastro); } int main(){ int opMenu; do{ menu(); scanf("%d", &opMenu); switch(opMenu){ case 1: adicionarOpiniao(); break; case 2: //Média de idade das pessoas com uma determinada opiniao case2(); case 3: //Porcentagem de pessoas que responderam a pesquisa por genero case3(); break; case 4: case4(); break; case 5: listar(); break; case 6: return 0; break; default: printf("\nOpcao invalida! Selecione uma nova opcao!\n"); } }while(opMenu!=0); }
the_stack_data/106471.c
extern int __VERIFIER_nondet_int(); extern void __VERIFIER_assume(int); int nondet_signed_int() { int r = __VERIFIER_nondet_int(); __VERIFIER_assume ((-0x7fffffff - 1) <= r && r <= 0x7fffffff); return r; } signed int main() { signed int i; signed int c; i = 0; c = 0; for( ; !(i >= 11); c = c + 1) { while(!(!(i + 1 < (-0x7fffffff - 1) || 0x7fffffff < i + 1))); i = i + 1; while(!(!(c + 1 < (-0x7fffffff - 1) || 0x7fffffff < c + 1))); } return 0; }
the_stack_data/14199501.c
#include<stdio.h> int ac(int a,int b) { return a + b; } int main() { int a = 0; int b = 0; printf("输入计算机啊: "); scanf("%d,%d",&a,&b); int c = ac(a,b); printf("计算器:%d\n",c); return 0; }
the_stack_data/165765927.c
#include <math.h> #include <stdio.h> #include <stdlib.h> float time_stairs(int n, int m, int t) { return abs(n - m) * t; } float time_elev(int n, int m, int k, float ta, float tb) { return (abs(n - k) * ta + 2 * tb + abs(n - m) * ta); } int main() { int N = 0, M = 0, K = 0; float Ta = 0, Tb = 0, Tc = 0; scanf("%d %d %d %f %f %f", &N, &M, &K, &Ta, &Tb, &Tc); printf("%s\n", (time_stairs(N, M, Tc) < time_elev(N, M, K, Ta, Tb) ? "stairs\n" : "elevator\n")); return 0; }
the_stack_data/145454192.c
/* { dg-do compile } */ void bar (int *); void foo () { int i,j; #pragma omp parallel for ordered(1) for (i=0; i < 100; ++i) { #pragma omp ordered depend(sink:i-1) bar(&i); #pragma omp ordered depend(source) } }
the_stack_data/727449.c
#include <stdio.h> #include <stdlib.h> #include <string.h> int main(int argc, char** argv){ int diceRoll(void); void returnDiceRolls(int *array, int *x); int *rolls; if(argc > 1){ *rolls = (int) strtol(argv[1],(char **) NULL,10); }else{ printf("How many rolls of a dice?: "); scanf("%d", rolls); } if(*rolls > 20){ printf("Exceeded total dice rolls (Max: 20)\n"); exit(0); } int diceRolls[*rolls]; for(size_t i = 0; i < *rolls; i++){ int roll = diceRoll(); diceRolls[i] = roll; } returnDiceRolls(diceRolls, rolls); return 0; } int diceRoll (){ srandom(time()); return (random() % 6) + 1; } void returnDiceRolls(int *array, int *arrlen){ char output[*arrlen + 20]; strcat(output, "Results: "); int sum = 0; for(size_t i = 0; i < *arrlen; i++){ int arrval = array[i]; sum += arrval; char str[*arrlen + 4]; sprintf(str,"%d ", arrval); strcat(output, str); } char* sumstr = "\nSum: "; char intchar[sizeof(sum)]; strcat(output, sumstr); sprintf(intchar,"%d",sum); strcat(output, intchar); printf("%s\n",output); return; }
the_stack_data/25138594.c
#include <stdio.h> #include <sys/file.h> #include <sys/types.h> #define FLOAT 4 main(argc,argv) int argc; char *argv[]; { int anal,pitches,j,jj; int npoles,lpcframe,pchframe,pchlast,nbpch; int correct_(); int nskiplpc,nskippch,nbytes,nblpc; char input[32],*output; float pch[2],val[1]; float y[50],frame[50],new; int out,i; int flag,framenum; /* printf(" Enter name of lpc analysis file\t"); scanf("%s",output); */ output = argv[1]; if((anal = open(output,2)) < 0) { fprintf(stderr," Can't open lpc analysis file"); exit(1); } flag = 1; if((out = open("badframes",O_CREAT|O_RDWR, 0644)) < 0) { fprintf(stderr,"Can't open outputfile\n"); exit(-2); } printf("anal and out = %d %d %d\n",anal,out,sizeof(framenum)); /* printf(" Enter number of poles in lpc analysis\t"); scanf("%d",&npoles); */ npoles = atoi(argv[2]); printf("npoles = %d\n",npoles); nblpc = (npoles+4)*FLOAT;/*to beginning of next pchloc*/ framenum = 0; lseek(anal,0,0); nbytes = 4; while(1) { if((read(anal,(char *)frame,nblpc)) != nblpc) { printf("Bad read on lpc analysis file\n"); printf("nblpc = %d %d\n",nblpc,jj); exit(1); } for(i=0; i<npoles; i++) y[i] = -frame[npoles+3-i]; stabletest_(y,&npoles,&flag); if(!flag) printf("flag,framenum %d %d\n",flag,framenum); if(!flag) if(jj=write(out,&framenum,nbytes) != nbytes) { printf("bad write on output file %d\n",jj); exit(-1); } /* if(!flag){ printf("tobefixed\n"); for(i=0; i<npoles+4; i++) printf(" %f",frame[i]); printf("\n"); } */ if(!flag) printf("fixing frame number %d\n",framenum); if(!flag) { /* printf("before correction npoles = %d\n",npoles); for(i=0; i<npoles+4; i++) printf(" %f",frame[i]); */ correct_(frame,&npoles,y); for(i=4; i<npoles+4; i++) frame[i] = y[i-4]; /* printf("after correction\n"); for(i=0; i<npoles+4; i++) printf(" %f",frame[i]); printf("\n"); */ lseek(anal,-nblpc,1); if((write(anal,(char *)frame,nblpc)) != nblpc) { printf("Bad write on lpc analysis file\n"); printf("nblpc = %d %d\n",nblpc,jj); exit(1); } } framenum++; fflush(stdout); } }
the_stack_data/173578355.c
// Program 82: Program to swap two numbers #include<stdio.h> int main() { double first, second, temp; printf("Enter first number: "); scanf("%lf", &first); printf("Enter second number: "); scanf("%lf", &second); // Value of first is assigned to temp temp = first; // Value of second is assigned to first first = second; // Value of temp (initial value of first) is assigned to second second = temp; printf("\nAfter swapping, firstNumber = %.2lf\n", first); printf("After swapping, secondNumber = %.2lf", second); return 0; }
the_stack_data/149975.c
// Verify proper type emitted for compound assignments // RUN: %clang_cc1 -ffreestanding -triple x86_64-apple-darwin10 -emit-llvm -o - %s -fsanitize=signed-integer-overflow,unsigned-integer-overflow -fsanitize-recover=signed-integer-overflow,unsigned-integer-overflow | FileCheck %s #include <stdint.h> // CHECK: @[[INT:.*]] = private unnamed_addr constant { i16, i16, [6 x i8] } { i16 0, i16 11, [6 x i8] c"'int'\00" } // CHECK: @[[LINE_100:.*]] = private unnamed_addr global {{.*}}, i32 100, i32 5 {{.*}} @[[INT]] // CHECK: @[[UINT:.*]] = private unnamed_addr constant { i16, i16, [15 x i8] } { i16 0, i16 10, [15 x i8] c"'unsigned int'\00" } // CHECK: @[[LINE_200:.*]] = private unnamed_addr global {{.*}}, i32 200, i32 5 {{.*}} @[[UINT]] // CHECK: @[[LINE_300:.*]] = private unnamed_addr global {{.*}}, i32 300, i32 5 {{.*}} @[[INT]] int32_t x; // CHECK: @compaddsigned void compaddsigned() { #line 100 x += ((int32_t)1); // CHECK: @__ubsan_handle_add_overflow(i8* bitcast ({{.*}} @[[LINE_100]] to i8*), {{.*}}) } // CHECK: @compaddunsigned void compaddunsigned() { #line 200 x += ((uint32_t)1U); // CHECK: @__ubsan_handle_add_overflow(i8* bitcast ({{.*}} @[[LINE_200]] to i8*), {{.*}}) } int8_t a, b; // CHECK: @compdiv void compdiv() { #line 300 a /= b; // CHECK: @__ubsan_handle_divrem_overflow(i8* bitcast ({{.*}} @[[LINE_300]] to i8*), {{.*}}) }
the_stack_data/184519483.c
#include <stdio.h> #include <malloc.h> #define alturaMaxima 225 typedef struct { int peso; int altura; } PesoAltura; int main(){ /*PesoAltura pessoa1; pessoa1.peso = 78; pessoa1.altura = 190; */ PesoAltura* pessoa1 = (PesoAltura*) malloc(sizeof(PesoAltura)); pessoa1 -> peso = 78; pessoa1 -> altura = 169; //printf("Peso: %i, Altura: %i. ", pessoa1.peso, pessoa1.altura); printf("Peso: %i, Altura: %i. ", pessoa1 -> peso, pessoa1 -> altura); if(pessoa1->altura > alturaMaxima){ printf("Altura excede valor maximo"); }else { printf("Altura nao excede valor maximo"); } return 0; }
the_stack_data/76699501.c
// void f90_markovst_gs_dense_(int* n, double* Q, int* ldq, double* xstart, int* incxs, double* x, int* incx, int* maxiter, double* rtol, int* steps, int* iter, double* rerror, int* info, void (*callback)(int*,double*)); void f90_markovst_gs_csr_(int* n, double* Q, int* rowptr, int* colind, int* nnz, double* xstart, int* incxs, double* x, int* incx, int* maxiter, double* rtol, int* steps, int* iter, double* rerror, int* info, void (*callback)(int*,double*)); void f90_markovst_gs_csc_(int* n, double* Q, int* colptr, int* rowind, int* nnz, double* xstart, int* incxs, double* x, int* incx, int* maxiter, double* rtol, int* steps, int* iter, double* rerror, int* info, void (*callback)(int*,double*)); /// void cc_markovst_gs_dense(int n, double* Q, int ldq, double* xstart, int incxs, double* x, int incx, int maxiter, double rtol, int steps, int* iter, double* rerror, int* info, void (*callback)(int*,double*)) { f90_markovst_gs_dense_(&n, Q, &ldq, xstart, &incxs, x, &incx, &maxiter, &rtol, &steps, iter, rerror, info, callback); } void cc_markovst_gs_csr(int n, double* Q, int* rowptr, int* colind, int nnz, double* xstart, int incxs, double* x, int incx, int maxiter, double rtol, int steps, int* iter, double* rerror, int* info, void (*callback)(int*,double*)) { f90_markovst_gs_csr_(&n, Q, rowptr, colind, &nnz, xstart, &incxs, x, &incx, &maxiter, &rtol, &steps, iter, rerror, info, callback); } void cc_markovst_gs_csc(int n, double* Q, int* colptr, int* rowind, int nnz, double* xstart, int incxs, double* x, int incx, int maxiter, double rtol, int steps, int* iter, double* rerror, int* info, void (*callback)(int*,double*)) { f90_markovst_gs_csc_(&n, Q, colptr, rowind, &nnz, xstart, &incxs, x, &incx, &maxiter, &rtol, &steps, iter, rerror, info, callback); }
the_stack_data/82950270.c
/* * File: pbar.c */ int pbarDummy; // // End. //
the_stack_data/913169.c
int i1 = 1; static int i2 = 2; extern int i3 = 3; int i4; static int i5; // definition, external linkage // definition, internal linkage // definition, external linkage // tentative definition, external linkage // tentative definition, internal linkage // valid tentative definition, refers to previous // 6.2.2 renders undefined, linkage disagreement // valid tentative definition, refers to previous // valid tentative definition, refers to previous // 6.2.2 renders undefined, linkage disagreement // refers to previous, whose linkage is external // refers to previous, whose linkage is internal // refers to previous, whose linkage is external // refers to previous, whose linkage is external // refers to previous, whose linkage is internal
the_stack_data/128686.c
// tag-#anon#ST[*{V}$V$'_call_addr'||S32'_syscall'||U32'_arch'|] // file /usr/include/x86_64-linux-gnu/bits/siginfo.h line 121 struct anonymous$4; // tag-#anon#ST[*{V}$V$'si_addr'||S16'si_addr_lsb'||U48'$pad0'|] // file /usr/include/x86_64-linux-gnu/bits/siginfo.h line 107 struct anonymous$2; // tag-#anon#ST[ARR16{U64}$U64$'__val'|] // file /usr/include/x86_64-linux-gnu/bits/sigset.h line 27 struct anonymous$9; // tag-#anon#ST[S32'si_pid'||U32'si_uid'|] // file /usr/include/x86_64-linux-gnu/bits/siginfo.h line 74 struct anonymous$14; // tag-#anon#ST[S32'si_pid'||U32'si_uid'||S32'si_status'||U32'$pad0'||S64'si_utime'||S64'si_stime'|] // file /usr/include/x86_64-linux-gnu/bits/siginfo.h line 97 struct anonymous$1; // tag-#anon#ST[S32'si_pid'||U32'si_uid'||SYM#tag-sigval#'si_sigval'|] // file /usr/include/x86_64-linux-gnu/bits/siginfo.h line 89 struct anonymous; // tag-#anon#ST[S32'si_signo'||S32'si_errno'||S32'si_code'||U32'$pad0'||SYM#tag-#anon#UN[ARR28{S32}$S32$'_pad'||SYM#tag-#anon#ST[S32'si_pid'||U32'si_uid'|]#'_kill'||SYM#tag-#anon#ST[S32'si_tid'||S32'si_overrun'||SYM#tag-sigval#'si_sigval'|]#'_timer'||SYM#tag-#anon#ST[S32'si_pid'||U32'si_uid'||SYM#tag-sigval#'si_sigval'|]#'_rt'||SYM#tag-#anon#ST[S32'si_pid'||U32'si_uid'||S32'si_status'||U32'$pad0'||S64'si_utime'||S64'si_stime'|]#'_sigchld'||SYM#tag-#anon#ST[*{V}$V$'si_addr'||S16'si_addr_lsb'||U48'$pad0'|]#'_sigfault'||SYM#tag-#anon#ST[S64'si_band'||S32'si_fd'||U32'$pad0'|]#'_sigpoll'||SYM#tag-#anon#ST[*{V}$V$'_call_addr'||S32'_syscall'||U32'_arch'|]#'_sigsys'|]#'_sifields'|] // file /usr/include/x86_64-linux-gnu/bits/siginfo.h line 62 struct anonymous$10; // tag-#anon#ST[S32'si_tid'||S32'si_overrun'||SYM#tag-sigval#'si_sigval'|] // file /usr/include/x86_64-linux-gnu/bits/siginfo.h line 81 struct anonymous$15; // tag-#anon#ST[S64'si_band'||S32'si_fd'||U32'$pad0'|] // file /usr/include/x86_64-linux-gnu/bits/siginfo.h line 114 struct anonymous$3; // tag-#anon#UN[*{V(S32)->V}$V(S32)->V$'sa_handler'||*{V(S32|*{SYM#tag-#anon#ST[S32'si_signo'||S32'si_errno'||S32'si_code'||U32'$pad0'||SYM#tag-#anon#UN[ARR28{S32}$S32$'_pad'||SYM#tag-#anon#ST[S32'si_pid'||U32'si_uid'|]#'_kill'||SYM#tag-#anon#ST[S32'si_tid'||S32'si_overrun'||SYM#tag-sigval#'si_sigval'|]#'_timer'||SYM#tag-#anon#ST[S32'si_pid'||U32'si_uid'||SYM#tag-sigval#'si_sigval'|]#'_rt'||SYM#tag-#anon#ST[S32'si_pid'||U32'si_uid'||S32'si_status'||U32'$pad0'||S64'si_utime'||S64'si_stime'|]#'_sigchld'||SYM#tag-#anon#ST[*{V}$V$'si_addr'||S16'si_addr_lsb'||U48'$pad0'|]#'_sigfault'||SYM#tag-#anon#ST[S64'si_band'||S32'si_fd'||U32'$pad0'|]#'_sigpoll'||SYM#tag-#anon#ST[*{V}$V$'_call_addr'||S32'_syscall'||U32'_arch'|]#'_sigsys'|]#'_sifields'|]#}$SYM#tag-#anon#ST[S32'si_signo'||S32'si_errno'||S32'si_code'||U32'$pad0'||SYM#tag-#anon#UN[ARR28{S32}$S32$'_pad'||SYM#tag-#anon#ST[S32'si_pid'||U32'si_uid'|]#'_kill'||SYM#tag-#anon#ST[S32'si_tid'||S32'si_overrun'||SYM#tag-sigval#'si_sigval'|]#'_timer'||SYM#tag-#anon#ST[S32'si_pid'||U32'si_uid'||SYM#tag-sigval#'si_sigval'|]#'_rt'||SYM#tag-#anon#ST[S32'si_pid'||U32'si_uid'||S32'si_status'||U32'$pad0'||S64'si_utime'||S64'si_stime'|]#'_sigchld'||SYM#tag-#anon#ST[*{V}$V$'si_addr'||S16'si_addr_lsb'||U48'$pad0'|]#'_sigfault'||SYM#tag-#anon#ST[S64'si_band'||S32'si_fd'||U32'$pad0'|]#'_sigpoll'||SYM#tag-#anon#ST[*{V}$V$'_call_addr'||S32'_syscall'||U32'_arch'|]#'_sigsys'|]#'_sifields'|]#$|*{V}$V$)->V}$V(S32|*{SYM#tag-#anon#ST[S32'si_signo'||S32'si_errno'||S32'si_code'||U32'$pad0'||SYM#tag-#anon#UN[ARR28{S32}$S32$'_pad'||SYM#tag-#anon#ST[S32'si_pid'||U32'si_uid'|]#'_kill'||SYM#tag-#anon#ST[S32'si_tid'||S32'si_overrun'||SYM#tag-sigval#'si_sigval'|]#'_timer'||SYM#tag-#anon#ST[S32'si_pid'||U32'si_uid'||SYM#tag-sigval#'si_sigval'|]#'_rt'||SYM#tag-#anon#ST[S32'si_pid'||U32'si_uid'||S32'si_status'||U32'$pad0'||S64'si_utime'||S64'si_stime'|]#'_sigchld'||SYM#tag-#anon#ST[*{V}$V$'si_addr'||S16'si_addr_lsb'||U48'$pad0'|]#'_sigfault'||SYM#tag-#anon#ST[S64'si_band'||S32'si_fd'||U32'$pad0'|]#'_sigpoll'||SYM#tag-#anon#ST[*{V}$V$'_call_addr'||S32'_syscall'||U32'_arch'|]#'_sigsys'|]#'_sifields'|]#}$SYM#tag-#anon#ST[S32'si_signo'||S32'si_errno'||S32'si_code'||U32'$pad0'||SYM#tag-#anon#UN[ARR28{S32}$S32$'_pad'||SYM#tag-#anon#ST[S32'si_pid'||U32'si_uid'|]#'_kill'||SYM#tag-#anon#ST[S32'si_tid'||S32'si_overrun'||SYM#tag-sigval#'si_sigval'|]#'_timer'||SYM#tag-#anon#ST[S32'si_pid'||U32'si_uid'||SYM#tag-sigval#'si_sigval'|]#'_rt'||SYM#tag-#anon#ST[S32'si_pid'||U32'si_uid'||S32'si_status'||U32'$pad0'||S64'si_utime'||S64'si_stime'|]#'_sigchld'||SYM#tag-#anon#ST[*{V}$V$'si_addr'||S16'si_addr_lsb'||U48'$pad0'|]#'_sigfault'||SYM#tag-#anon#ST[S64'si_band'||S32'si_fd'||U32'$pad0'|]#'_sigpoll'||SYM#tag-#anon#ST[*{V}$V$'_call_addr'||S32'_syscall'||U32'_arch'|]#'_sigsys'|]#'_sifields'|]#$|*{V}$V$)->V$'sa_sigaction'|] // file /usr/include/x86_64-linux-gnu/bits/sigaction.h line 28 union anonymous$8; // tag-#anon#UN[ARR16{U8}$U8$'__u6_addr8'||ARR8{U16}$U16$'__u6_addr16'||ARR4{U32}$U32$'__u6_addr32'|] // file /usr/include/netinet/in.h line 211 union anonymous$12; // tag-#anon#UN[ARR28{S32}$S32$'_pad'||SYM#tag-#anon#ST[S32'si_pid'||U32'si_uid'|]#'_kill'||SYM#tag-#anon#ST[S32'si_tid'||S32'si_overrun'||SYM#tag-sigval#'si_sigval'|]#'_timer'||SYM#tag-#anon#ST[S32'si_pid'||U32'si_uid'||SYM#tag-sigval#'si_sigval'|]#'_rt'||SYM#tag-#anon#ST[S32'si_pid'||U32'si_uid'||S32'si_status'||U32'$pad0'||S64'si_utime'||S64'si_stime'|]#'_sigchld'||SYM#tag-#anon#ST[*{V}$V$'si_addr'||S16'si_addr_lsb'||U48'$pad0'|]#'_sigfault'||SYM#tag-#anon#ST[S64'si_band'||S32'si_fd'||U32'$pad0'|]#'_sigpoll'||SYM#tag-#anon#ST[*{V}$V$'_call_addr'||S32'_syscall'||U32'_arch'|]#'_sigsys'|] // file /usr/include/x86_64-linux-gnu/bits/siginfo.h line 69 union anonymous$5; // tag-#anon#UN[ARR4{S8}$S8$'__size'||S32'__align'|] // file /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h line 130 union anonymous$7; // tag-#anon#UN[SYM#tag-__pthread_mutex_s#'__data'||ARR40{S8}$S8$'__size'||S64'__align'|] // file /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h line 90 union anonymous$6; // tag-#anon#UN[r*{SYM#tag-sockaddr#}$SYM#tag-sockaddr#$'__sockaddr__'||r*{SYM#tag-sockaddr_at#}$SYM#tag-sockaddr_at#$'__sockaddr_at__'||r*{SYM#tag-sockaddr_ax25#}$SYM#tag-sockaddr_ax25#$'__sockaddr_ax25__'||r*{SYM#tag-sockaddr_dl#}$SYM#tag-sockaddr_dl#$'__sockaddr_dl__'||r*{SYM#tag-sockaddr_eon#}$SYM#tag-sockaddr_eon#$'__sockaddr_eon__'||r*{SYM#tag-sockaddr_in#}$SYM#tag-sockaddr_in#$'__sockaddr_in__'||r*{SYM#tag-sockaddr_in6#}$SYM#tag-sockaddr_in6#$'__sockaddr_in6__'||r*{SYM#tag-sockaddr_inarp#}$SYM#tag-sockaddr_inarp#$'__sockaddr_inarp__'||r*{SYM#tag-sockaddr_ipx#}$SYM#tag-sockaddr_ipx#$'__sockaddr_ipx__'||r*{SYM#tag-sockaddr_iso#}$SYM#tag-sockaddr_iso#$'__sockaddr_iso__'||r*{SYM#tag-sockaddr_ns#}$SYM#tag-sockaddr_ns#$'__sockaddr_ns__'||r*{SYM#tag-sockaddr_un#}$SYM#tag-sockaddr_un#$'__sockaddr_un__'||r*{SYM#tag-sockaddr_x25#}$SYM#tag-sockaddr_x25#$'__sockaddr_x25__'|] // file /usr/include/x86_64-linux-gnu/sys/socket.h line 90 union anonymous$0; // tag-#anon#UN[r*{SYM#tag-sockaddr#}$SYM#tag-sockaddr#$'__sockaddr__'||r*{SYM#tag-sockaddr_at#}$SYM#tag-sockaddr_at#$'__sockaddr_at__'||r*{SYM#tag-sockaddr_ax25#}$SYM#tag-sockaddr_ax25#$'__sockaddr_ax25__'||r*{SYM#tag-sockaddr_dl#}$SYM#tag-sockaddr_dl#$'__sockaddr_dl__'||r*{SYM#tag-sockaddr_eon#}$SYM#tag-sockaddr_eon#$'__sockaddr_eon__'||r*{SYM#tag-sockaddr_in#}$SYM#tag-sockaddr_in#$'__sockaddr_in__'||r*{SYM#tag-sockaddr_in6#}$SYM#tag-sockaddr_in6#$'__sockaddr_in6__'||r*{SYM#tag-sockaddr_inarp#}$SYM#tag-sockaddr_inarp#$'__sockaddr_inarp__'||r*{SYM#tag-sockaddr_ipx#}$SYM#tag-sockaddr_ipx#$'__sockaddr_ipx__'||r*{SYM#tag-sockaddr_iso#}$SYM#tag-sockaddr_iso#$'__sockaddr_iso__'||r*{SYM#tag-sockaddr_ns#}$SYM#tag-sockaddr_ns#$'__sockaddr_ns__'||r*{SYM#tag-sockaddr_un#}$SYM#tag-sockaddr_un#$'__sockaddr_un__'||r*{SYM#tag-sockaddr_x25#}$SYM#tag-sockaddr_x25#$'__sockaddr_x25__'|]$transparent // file /usr/include/x86_64-linux-gnu/sys/socket.h line 90 union anonymous$13; // tag-_IO_FILE // file /usr/include/stdio.h line 44 struct _IO_FILE; // tag-_IO_marker // file /usr/include/libio.h line 160 struct _IO_marker; // tag-__pthread_internal_list // file /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h line 75 struct __pthread_internal_list; // tag-__pthread_mutex_s // file /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h line 92 struct __pthread_mutex_s; // tag-addrinfo // file /usr/include/netdb.h line 567 struct addrinfo; // tag-connection // file internal.h line 68 struct connection; // tag-group // file /usr/include/grp.h line 42 struct group; // tag-in6_addr // file /usr/include/netinet/in.h line 209 struct in6_addr; // tag-in_addr // file /usr/include/netinet/in.h line 31 struct in_addr; // tag-nbdkit_plugin // file ../include/nbdkit-plugin.h line 49 struct nbdkit_plugin; // tag-old_handshake // file protocol.h line 40 struct old_handshake; // tag-option // file /usr/include/getopt.h line 104 struct option; // tag-passwd // file /usr/include/pwd.h line 49 struct passwd; // tag-pollfd // file /usr/include/x86_64-linux-gnu/sys/poll.h line 39 struct pollfd; // tag-pthread_attr_t // file /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h line 63 union pthread_attr_t; // tag-reply // file protocol.h line 72 struct reply; // tag-request // file protocol.h line 63 struct request; // tag-sigaction // file /usr/include/x86_64-linux-gnu/bits/sigaction.h line 24 struct sigaction; // tag-sigval // file /usr/include/x86_64-linux-gnu/bits/siginfo.h line 32 union sigval; // tag-sockaddr // file /usr/include/x86_64-linux-gnu/bits/socket.h line 149 struct sockaddr; // tag-sockaddr_at // file /usr/include/x86_64-linux-gnu/sys/socket.h line 90 struct sockaddr_at; // tag-sockaddr_ax25 // file /usr/include/x86_64-linux-gnu/sys/socket.h line 90 struct sockaddr_ax25; // tag-sockaddr_dl // file /usr/include/x86_64-linux-gnu/sys/socket.h line 90 struct sockaddr_dl; // tag-sockaddr_eon // file /usr/include/x86_64-linux-gnu/sys/socket.h line 90 struct sockaddr_eon; // tag-sockaddr_in // file /usr/include/x86_64-linux-gnu/sys/socket.h line 90 struct sockaddr_in; // tag-sockaddr_in6 // file /usr/include/x86_64-linux-gnu/sys/socket.h line 90 struct sockaddr_in6; // tag-sockaddr_inarp // file /usr/include/x86_64-linux-gnu/sys/socket.h line 90 struct sockaddr_inarp; // tag-sockaddr_ipx // file /usr/include/x86_64-linux-gnu/sys/socket.h line 90 struct sockaddr_ipx; // tag-sockaddr_iso // file /usr/include/x86_64-linux-gnu/sys/socket.h line 90 struct sockaddr_iso; // tag-sockaddr_ns // file /usr/include/x86_64-linux-gnu/sys/socket.h line 90 struct sockaddr_ns; // tag-sockaddr_un // file /usr/include/x86_64-linux-gnu/sys/socket.h line 90 struct sockaddr_un; // tag-sockaddr_x25 // file /usr/include/x86_64-linux-gnu/sys/socket.h line 90 struct sockaddr_x25; // tag-thread_data // file sockets.c line 201 struct thread_data; // tag-tls // file tls.c line 54 struct tls; #include <assert.h> #ifndef NULL #define NULL ((void*)0) #endif // __assert_fail // file /usr/include/assert.h line 69 extern void __assert_fail(const char *, const char *, unsigned int, const char *); // __bswap_32 // file /usr/include/x86_64-linux-gnu/bits/byteswap.h line 45 static inline unsigned int __bswap_32(unsigned int __bsx); // __bswap_64 // file /usr/include/x86_64-linux-gnu/bits/byteswap.h line 109 static inline unsigned long int __bswap_64(unsigned long int __bsx); // __errno_location // file /usr/include/x86_64-linux-gnu/bits/errno.h line 50 extern signed int * __errno_location(void); // _exit // file /usr/include/unistd.h line 603 extern void _exit(signed int); // _handle_request // file connections.c line 327 static signed int _handle_request(struct connection *conn, unsigned int cmd, unsigned int flags, unsigned long int offset, unsigned int count, void *buf, unsigned int *error); // _handle_single_connection // file connections.c line 61 static signed int _handle_single_connection(signed int sockin, signed int sockout); // _negotiate_handshake // file connections.c line 150 static signed int _negotiate_handshake(struct connection *conn); // abort // file /usr/include/stdlib.h line 515 extern void abort(void); // accept // file /usr/include/x86_64-linux-gnu/sys/socket.h line 243 extern signed int accept(signed int, union anonymous$13, unsigned int *); // accept_connection // file sockets.c line 226 static void accept_connection(signed int listen_sock); // accept_incoming_connections // file internal.h line 111 extern void accept_incoming_connections(signed int *socks, unsigned long int nr_socks); // asprintf // file /usr/include/stdio.h line 405 extern signed int asprintf(char ** restrict , const char *, ...); // bind // file /usr/include/x86_64-linux-gnu/sys/socket.h line 123 extern signed int bind(signed int, union anonymous$13, unsigned int); // bind_tcpip_socket // file internal.h line 110 extern signed int * bind_tcpip_socket(unsigned long int *nr_socks); // bind_unix_socket // file internal.h line 109 extern signed int * bind_unix_socket(unsigned long int *nr_socks); // calloc // file /usr/include/stdlib.h line 468 extern void * calloc(unsigned long int, unsigned long int); // change_user // file main.c line 468 static void change_user(void); // chdir // file /usr/include/unistd.h line 497 extern signed int chdir(const char *); // cleanup_free // file cleanup.c line 45 extern void cleanup_free(void *ptr); // close // file /usr/include/unistd.h line 353 extern signed int close(signed int); // display_version // file main.c line 122 static void display_version(void); // dlclose // file /usr/include/dlfcn.h line 60 extern signed int dlclose(void *); // dlerror // file /usr/include/dlfcn.h line 82 extern char * dlerror(void); // dlopen // file /usr/include/dlfcn.h line 56 extern void * dlopen(const char *, signed int); // dlsym // file /usr/include/dlfcn.h line 64 extern void * dlsym(void *, const char *); // dump_config // file main.c line 128 static void dump_config(void); // dup2 // file /usr/include/unistd.h line 534 extern signed int dup2(signed int, signed int); // exit // file /usr/include/stdlib.h line 543 extern void exit(signed int); // fork // file /usr/include/unistd.h line 756 extern signed int fork(void); // fork_into_background // file main.c line 530 static void fork_into_background(void); // fprintf // file /usr/include/stdio.h line 356 extern signed int fprintf(struct _IO_FILE *, const char *, ...); // free // file /usr/include/stdlib.h line 483 extern void free(void *); // free_connection // file connections.c line 128 static void free_connection(struct connection *conn); // free_listening_sockets // file internal.h line 112 extern void free_listening_sockets(signed int *socks, unsigned long int nr_socks); // free_tls // file tls.c line 64 static void free_tls(void *tlsv); // freeaddrinfo // file /usr/include/netdb.h line 668 extern void freeaddrinfo(struct addrinfo *); // gai_strerror // file /usr/include/netdb.h line 671 extern const char * gai_strerror(signed int); // get_current_dir_name // file /usr/include/unistd.h line 517 extern char * get_current_dir_name(void); // getaddrinfo // file /usr/include/netdb.h line 662 extern signed int getaddrinfo(const char *, const char *, struct addrinfo *, struct addrinfo ** restrict ); // getgrnam // file /usr/include/grp.h line 110 extern struct group * getgrnam(const char *); // getopt_long // file /usr/include/getopt.h line 173 extern signed int getopt_long(signed int, char * const *, const char *, struct option *, signed int *); // getpid // file /usr/include/unistd.h line 628 extern signed int getpid(void); // getpwnam // file /usr/include/pwd.h line 116 extern struct passwd * getpwnam(const char *); // handle_quit // file main.c line 443 static void handle_quit(signed int sig); // handle_request // file connections.c line 389 static signed int handle_request(struct connection *conn, unsigned int cmd, unsigned int flags, unsigned long int offset, unsigned int count, void *buf, unsigned int *error); // handle_single_connection // file connections.c line 98 extern signed int handle_single_connection(signed int sockin, signed int sockout); // kill // file /usr/include/signal.h line 127 extern signed int kill(signed int, signed int); // listen // file /usr/include/x86_64-linux-gnu/sys/socket.h line 233 extern signed int listen(signed int, signed int); // make_random_fifo // file main.c line 323 static char * make_random_fifo(void); // malloc // file /usr/include/stdlib.h line 466 extern void * malloc(unsigned long int); // memcpy // file /usr/include/string.h line 46 extern void * memcpy(void *, const void *, unsigned long int); // memset // file /usr/include/string.h line 66 extern void * memset(void *, signed int, unsigned long int); // mkdtemp // file /usr/include/stdlib.h line 662 extern char * mkdtemp(char *); // nbdkit_absolute_path // file ../include/nbdkit-plugin.h line 91 extern char * nbdkit_absolute_path(const char *path); // nbdkit_debug // file ../include/nbdkit-plugin.h line 87 extern void nbdkit_debug(const char *fs, ...); // nbdkit_error // file ../include/nbdkit-plugin.h line 84 extern void nbdkit_error(const char *fs, ...); // nbdkit_parse_size // file utils.c line 86 extern signed long int nbdkit_parse_size(const char *str); // nbdkit_vdebug // file errors.c line 65 extern void nbdkit_vdebug(const char *fs, void **args); // nbdkit_verror // file errors.c line 104 extern void nbdkit_verror(const char *fs, void **args); // negotiate_handshake // file connections.c line 222 static signed int negotiate_handshake(struct connection *conn); // new_connection // file connections.c line 110 static struct connection * new_connection(signed int sockin, signed int sockout); // open // file /usr/include/fcntl.h line 146 extern signed int open(const char *, signed int, ...); // open_plugin_so // file main.c line 354 static void open_plugin_so(const char *name); // open_plugin_so::1::plugin_init$object // struct nbdkit_plugin * plugin_init$object(void); // parsegroup // file main.c line 673 static unsigned int parsegroup(const char *id); // parseuser // file main.c line 645 static unsigned int parseuser(const char *id); // perror // file /usr/include/stdio.h line 846 extern void perror(const char *); // plugin_can_flush // file internal.h line 100 extern signed int plugin_can_flush(struct connection *conn); // plugin_can_trim // file internal.h line 102 extern signed int plugin_can_trim(struct connection *conn); // plugin_can_write // file internal.h line 99 extern signed int plugin_can_write(struct connection *conn); // plugin_cleanup // file internal.h line 86 extern void plugin_cleanup(void); // plugin_close // file internal.h line 97 extern void plugin_close(struct connection *conn); // plugin_config // file internal.h line 90 extern void plugin_config(const char *key, const char *value); // plugin_config_complete // file internal.h line 91 extern void plugin_config_complete(void); // plugin_flush // file internal.h line 105 extern signed int plugin_flush(struct connection *conn); // plugin_get_size // file internal.h line 98 extern signed long int plugin_get_size(struct connection *conn); // plugin_is_rotational // file internal.h line 101 extern signed int plugin_is_rotational(struct connection *conn); // plugin_lock_connection // file internal.h line 92 extern void plugin_lock_connection(void); // plugin_lock_request // file internal.h line 94 extern void plugin_lock_request(struct connection *conn); // plugin_name // file internal.h line 87 extern const char * plugin_name(void); // plugin_open // file internal.h line 96 extern signed int plugin_open(struct connection *conn, signed int readonly); // plugin_pread // file internal.h line 103 extern signed int plugin_pread(struct connection *conn, void *buf, unsigned int count, unsigned long int offset); // plugin_pwrite // file internal.h line 104 extern signed int plugin_pwrite(struct connection *conn, void *buf, unsigned int count, unsigned long int offset); // plugin_register // file internal.h line 85 extern void plugin_register(const char *_filename, void *_dl, struct nbdkit_plugin * (*plugin_init)(void)); // plugin_register::plugin_init$object // struct nbdkit_plugin * plugin_init$object(void); // plugin_trim // file internal.h line 106 extern signed int plugin_trim(struct connection *conn, unsigned int count, unsigned long int offset); // plugin_unlock_connection // file internal.h line 93 extern void plugin_unlock_connection(void); // plugin_unlock_request // file internal.h line 95 extern void plugin_unlock_request(struct connection *conn); // plugin_usage // file internal.h line 88 extern void plugin_usage(void); // plugin_version // file internal.h line 89 extern void plugin_version(void); // poll // file /usr/include/x86_64-linux-gnu/sys/poll.h line 57 extern signed int poll(struct pollfd *, unsigned long int, signed int); // printf // file /usr/include/stdio.h line 362 extern signed int printf(const char *, ...); // prologue // file errors.c line 46 static void prologue(const char *type); // pthread_attr_destroy // file /usr/include/pthread.h line 292 extern signed int pthread_attr_destroy(union pthread_attr_t *); // pthread_attr_init // file /usr/include/pthread.h line 289 extern signed int pthread_attr_init(union pthread_attr_t *); // pthread_attr_setdetachstate // file /usr/include/pthread.h line 301 extern signed int pthread_attr_setdetachstate(union pthread_attr_t *, signed int); // pthread_create // file /usr/include/pthread.h line 235 extern signed int pthread_create(unsigned long int *, const union pthread_attr_t *, void * (*)(void *), void *); // pthread_getspecific // file /usr/include/pthread.h line 1121 extern void * pthread_getspecific(unsigned int); // pthread_key_create // file /usr/include/pthread.h line 1113 extern signed int pthread_key_create(unsigned int *, void (*)(void *)); // pthread_mutex_destroy // file /usr/include/pthread.h line 756 extern signed int pthread_mutex_destroy(union anonymous$6 *); // pthread_mutex_init // file /usr/include/pthread.h line 751 extern signed int pthread_mutex_init(union anonymous$6 *, const union anonymous$7 *); // pthread_mutex_lock // file /usr/include/pthread.h line 764 extern signed int pthread_mutex_lock(union anonymous$6 *); // pthread_mutex_unlock // file /usr/include/pthread.h line 775 extern signed int pthread_mutex_unlock(union anonymous$6 *); // pthread_setspecific // file /usr/include/pthread.h line 1124 extern signed int pthread_setspecific(unsigned int, const void *); // read // file /usr/include/unistd.h line 360 extern signed long int read(signed int, void *, unsigned long int); // realloc // file /usr/include/stdlib.h line 480 extern void * realloc(void *, unsigned long int); // recv_request_send_reply // file connections.c line 422 static signed int recv_request_send_reply(struct connection *conn); // rmdir // file /usr/include/unistd.h line 835 extern signed int rmdir(const char *); // run_command // file main.c line 562 static void run_command(void); // set_up_signals // file main.c line 449 static void set_up_signals(void); // setgid // file /usr/include/unistd.h line 717 extern signed int setgid(unsigned int); // setgroups // file /usr/include/grp.h line 179 extern signed int setgroups(unsigned long int, const unsigned int *); // setsockopt // file /usr/include/x86_64-linux-gnu/sys/socket.h line 226 extern signed int setsockopt(signed int, signed int, signed int, const void *, unsigned int); // setuid // file /usr/include/unistd.h line 700 extern signed int setuid(unsigned int); // sigaction // file /usr/include/signal.h line 259 extern signed int sigaction(signed int, struct sigaction *, struct sigaction *); // skip_over_write_buffer // file connections.c line 404 static void skip_over_write_buffer(signed int sock, unsigned long int count); // snprintf // file /usr/include/stdio.h line 386 extern signed int snprintf(char *, unsigned long int, const char *, ...); // socket // file /usr/include/x86_64-linux-gnu/sys/socket.h line 113 extern signed int socket(signed int, signed int, signed int); // sscanf // file /usr/include/stdio.h line 433 extern signed int sscanf(const char *, const char *, ...); // start_serving // file main.c line 397 static void start_serving(void); // start_thread // file sockets.c line 209 static void * start_thread(void *datav); // strchr // file /usr/include/string.h line 235 extern char * strchr(const char *, signed int); // strcmp // file /usr/include/string.h line 144 extern signed int strcmp(const char *, const char *); // strdup // file /usr/include/string.h line 175 extern char * strdup(const char *); // strerror // file /usr/include/string.h line 412 extern char * strerror(signed int); // strlen // file /usr/include/string.h line 398 extern unsigned long int strlen(const char *); // strstr // file /usr/include/string.h line 341 extern char * strstr(const char *, const char *); // system // file /usr/include/stdlib.h line 716 extern signed int system(const char *); // tls_get_instance_num // file internal.h line 121 extern unsigned long int tls_get_instance_num(void); // tls_get_name // file internal.h line 120 extern const char * tls_get_name(void); // tls_init // file internal.h line 115 extern void tls_init(void); // tls_new_server_thread // file internal.h line 116 extern void tls_new_server_thread(void); // tls_set_instance_num // file internal.h line 118 extern void tls_set_instance_num(unsigned long int instance_num); // tls_set_name // file internal.h line 117 extern void tls_set_name(const char *name); // tls_set_sockaddr // file internal.h line 119 extern void tls_set_sockaddr(struct sockaddr *addr, unsigned int addrlen); // unlink // file /usr/include/unistd.h line 826 extern signed int unlink(const char *); // usage // file main.c line 111 static void usage(void); // valid_range // file connections.c line 234 static signed int valid_range(struct connection *conn, unsigned long int offset, unsigned int count); // validate_request // file connections.c line 242 static signed int validate_request(struct connection *conn, unsigned int cmd, unsigned int flags, unsigned long int offset, unsigned int count, unsigned int *error); // vfprintf // file /usr/include/stdio.h line 371 extern signed int vfprintf(struct _IO_FILE *, const char *, void **); // write // file /usr/include/unistd.h line 366 extern signed long int write(signed int, const void *, unsigned long int); // write_pidfile // file main.c line 500 static void write_pidfile(void); // xread // file internal.h line 125 extern signed int xread(signed int sock, void *vbuf, unsigned long int len); // xwrite // file internal.h line 126 extern signed int xwrite(signed int sock, const void *vbuf, unsigned long int len); struct anonymous$4 { // _call_addr void *_call_addr; // _syscall signed int _syscall; // _arch unsigned int _arch; }; struct anonymous$2 { // si_addr void *si_addr; // si_addr_lsb signed short int si_addr_lsb; }; struct anonymous$9 { // __val unsigned long int __val[16l]; }; struct anonymous$14 { // si_pid signed int si_pid; // si_uid unsigned int si_uid; }; struct anonymous$1 { // si_pid signed int si_pid; // si_uid unsigned int si_uid; // si_status signed int si_status; // si_utime signed long int si_utime; // si_stime signed long int si_stime; }; union sigval { // sival_int signed int sival_int; // sival_ptr void *sival_ptr; }; struct anonymous { // si_pid signed int si_pid; // si_uid unsigned int si_uid; // si_sigval union sigval si_sigval; }; struct anonymous$15 { // si_tid signed int si_tid; // si_overrun signed int si_overrun; // si_sigval union sigval si_sigval; }; struct anonymous$3 { // si_band signed long int si_band; // si_fd signed int si_fd; }; union anonymous$5 { // _pad signed int _pad[28l]; // _kill struct anonymous$14 _kill; // _timer struct anonymous$15 _timer; // _rt struct anonymous _rt; // _sigchld struct anonymous$1 _sigchld; // _sigfault struct anonymous$2 _sigfault; // _sigpoll struct anonymous$3 _sigpoll; // _sigsys struct anonymous$4 _sigsys; }; struct anonymous$10 { // si_signo signed int si_signo; // si_errno signed int si_errno; // si_code signed int si_code; // _sifields union anonymous$5 _sifields; }; union anonymous$8 { // sa_handler void (*sa_handler)(signed int); // sa_sigaction void (*sa_sigaction)(signed int, struct anonymous$10 *, void *); }; union anonymous$12 { // __u6_addr8 unsigned char __u6_addr8[16l]; // __u6_addr16 unsigned short int __u6_addr16[8l]; // __u6_addr32 unsigned int __u6_addr32[4l]; }; union anonymous$7 { // __size char __size[4l]; // __align signed int __align; }; struct __pthread_internal_list { // __prev struct __pthread_internal_list *__prev; // __next struct __pthread_internal_list *__next; }; struct __pthread_mutex_s { // __lock signed int __lock; // __count unsigned int __count; // __owner signed int __owner; // __nusers unsigned int __nusers; // __kind signed int __kind; // __spins signed short int __spins; // __elision signed short int __elision; // __list struct __pthread_internal_list __list; }; union anonymous$6 { // __data struct __pthread_mutex_s __data; // __size char __size[40l]; // __align signed long int __align; }; union anonymous$0 { // __sockaddr__ struct sockaddr * restrict __sockaddr__; // __sockaddr_at__ struct sockaddr_at * restrict __sockaddr_at__; // __sockaddr_ax25__ struct sockaddr_ax25 * restrict __sockaddr_ax25__; // __sockaddr_dl__ struct sockaddr_dl * restrict __sockaddr_dl__; // __sockaddr_eon__ struct sockaddr_eon * restrict __sockaddr_eon__; // __sockaddr_in__ struct sockaddr_in * restrict __sockaddr_in__; // __sockaddr_in6__ struct sockaddr_in6 * restrict __sockaddr_in6__; // __sockaddr_inarp__ struct sockaddr_inarp * restrict __sockaddr_inarp__; // __sockaddr_ipx__ struct sockaddr_ipx * restrict __sockaddr_ipx__; // __sockaddr_iso__ struct sockaddr_iso * restrict __sockaddr_iso__; // __sockaddr_ns__ struct sockaddr_ns * restrict __sockaddr_ns__; // __sockaddr_un__ struct sockaddr_un * restrict __sockaddr_un__; // __sockaddr_x25__ struct sockaddr_x25 * restrict __sockaddr_x25__; }; union anonymous$13 { // __sockaddr__ struct sockaddr * restrict __sockaddr__; // __sockaddr_at__ struct sockaddr_at * restrict __sockaddr_at__; // __sockaddr_ax25__ struct sockaddr_ax25 * restrict __sockaddr_ax25__; // __sockaddr_dl__ struct sockaddr_dl * restrict __sockaddr_dl__; // __sockaddr_eon__ struct sockaddr_eon * restrict __sockaddr_eon__; // __sockaddr_in__ struct sockaddr_in * restrict __sockaddr_in__; // __sockaddr_in6__ struct sockaddr_in6 * restrict __sockaddr_in6__; // __sockaddr_inarp__ struct sockaddr_inarp * restrict __sockaddr_inarp__; // __sockaddr_ipx__ struct sockaddr_ipx * restrict __sockaddr_ipx__; // __sockaddr_iso__ struct sockaddr_iso * restrict __sockaddr_iso__; // __sockaddr_ns__ struct sockaddr_ns * restrict __sockaddr_ns__; // __sockaddr_un__ struct sockaddr_un * restrict __sockaddr_un__; // __sockaddr_x25__ struct sockaddr_x25 * restrict __sockaddr_x25__; } __attribute__ ((__transparent_union__)); struct _IO_FILE { // _flags signed int _flags; // _IO_read_ptr char *_IO_read_ptr; // _IO_read_end char *_IO_read_end; // _IO_read_base char *_IO_read_base; // _IO_write_base char *_IO_write_base; // _IO_write_ptr char *_IO_write_ptr; // _IO_write_end char *_IO_write_end; // _IO_buf_base char *_IO_buf_base; // _IO_buf_end char *_IO_buf_end; // _IO_save_base char *_IO_save_base; // _IO_backup_base char *_IO_backup_base; // _IO_save_end char *_IO_save_end; // _markers struct _IO_marker *_markers; // _chain struct _IO_FILE *_chain; // _fileno signed int _fileno; // _flags2 signed int _flags2; // _old_offset signed long int _old_offset; // _cur_column unsigned short int _cur_column; // _vtable_offset signed char _vtable_offset; // _shortbuf char _shortbuf[1l]; // _lock void *_lock; // _offset signed long int _offset; // __pad1 void *__pad1; // __pad2 void *__pad2; // __pad3 void *__pad3; // __pad4 void *__pad4; // __pad5 unsigned long int __pad5; // _mode signed int _mode; // _unused2 char _unused2[(signed long int)(sizeof(signed int) * 5) /*20l*/ ]; }; struct _IO_marker { // _next struct _IO_marker *_next; // _sbuf struct _IO_FILE *_sbuf; // _pos signed int _pos; }; struct addrinfo { // ai_flags signed int ai_flags; // ai_family signed int ai_family; // ai_socktype signed int ai_socktype; // ai_protocol signed int ai_protocol; // ai_addrlen unsigned int ai_addrlen; // ai_addr struct sockaddr *ai_addr; // ai_canonname char *ai_canonname; // ai_next struct addrinfo *ai_next; }; struct connection { // sockin signed int sockin; // sockout signed int sockout; // request_lock union anonymous$6 request_lock; // handle void *handle; // exportsize unsigned long int exportsize; // readonly signed int readonly; // can_flush signed int can_flush; // is_rotational signed int is_rotational; // can_trim signed int can_trim; }; struct group { // gr_name char *gr_name; // gr_passwd char *gr_passwd; // gr_gid unsigned int gr_gid; // gr_mem char **gr_mem; }; struct in6_addr { // __in6_u union anonymous$12 __in6_u; }; struct in_addr { // s_addr unsigned int s_addr; }; struct nbdkit_plugin { // _struct_size unsigned long int _struct_size; // _api_version signed int _api_version; // _thread_model signed int _thread_model; // name const char *name; // longname const char *longname; // version const char *version; // description const char *description; // load void (*load)(void); // unload void (*unload)(void); // config signed int (*config)(const char *, const char *); // config_complete signed int (*config_complete)(void); // config_help const char *config_help; // open void * (*open)(signed int); // close void (*close)(void *); // get_size signed long int (*get_size)(void *); // can_write signed int (*can_write)(void *); // can_flush signed int (*can_flush)(void *); // is_rotational signed int (*is_rotational)(void *); // can_trim signed int (*can_trim)(void *); // pread signed int (*pread)(void *, void *, unsigned int, unsigned long int); // pwrite signed int (*pwrite)(void *, const void *, unsigned int, unsigned long int); // flush signed int (*flush)(void *); // trim signed int (*trim)(void *, unsigned int, unsigned long int); }; struct old_handshake { // nbdmagic char nbdmagic[8l]; // version unsigned long int version; // exportsize unsigned long int exportsize; // gflags unsigned short int gflags; // eflags unsigned short int eflags; // zeroes char zeroes[124l]; } __attribute__ ((__packed__)); struct option { // name const char *name; // has_arg signed int has_arg; // flag signed int *flag; // val signed int val; }; struct passwd { // pw_name char *pw_name; // pw_passwd char *pw_passwd; // pw_uid unsigned int pw_uid; // pw_gid unsigned int pw_gid; // pw_gecos char *pw_gecos; // pw_dir char *pw_dir; // pw_shell char *pw_shell; }; struct pollfd { // fd signed int fd; // events signed short int events; // revents signed short int revents; }; union pthread_attr_t { // __size char __size[56l]; // __align signed long int __align; }; struct reply { // magic unsigned int magic; // error unsigned int error; // handle unsigned long int handle; } __attribute__ ((__packed__)); struct request { // magic unsigned int magic; // type unsigned int type; // handle unsigned long int handle; // offset unsigned long int offset; // count unsigned int count; } __attribute__ ((__packed__)); struct sigaction { // __sigaction_handler union anonymous$8 __sigaction_handler; // sa_mask struct anonymous$9 sa_mask; // sa_flags signed int sa_flags; // sa_restorer void (*sa_restorer)(void); }; struct sockaddr { // sa_family unsigned short int sa_family; // sa_data char sa_data[14l]; }; struct sockaddr_in { // sin_family unsigned short int sin_family; // sin_port unsigned short int sin_port; // sin_addr struct in_addr sin_addr; // sin_zero unsigned char sin_zero[8l]; }; struct sockaddr_in6 { // sin6_family unsigned short int sin6_family; // sin6_port unsigned short int sin6_port; // sin6_flowinfo unsigned int sin6_flowinfo; // sin6_addr struct in6_addr sin6_addr; // sin6_scope_id unsigned int sin6_scope_id; }; struct sockaddr_un { // sun_family unsigned short int sun_family; // sun_path char sun_path[108l]; }; struct thread_data { // sock signed int sock; // instance_num unsigned long int instance_num; // addr struct sockaddr addr; // addrlen unsigned int addrlen; }; struct tls { // name const char *name; // instance_num unsigned long int instance_num; // addr struct sockaddr *addr; // addrlen unsigned int addrlen; }; // all_requests_lock // file plugins.c line 49 static union anonymous$6 all_requests_lock = { .__data={ .__lock=0, .__count=(unsigned int)0, .__owner=0, .__nusers=(unsigned int)0, .__kind=0, .__spins=(signed short int)0, .__elision=(signed short int)0, .__list={ .__prev=((struct __pthread_internal_list *)NULL), .__next=((struct __pthread_internal_list *)NULL) } } }; // connection_lock // file plugins.c line 48 static union anonymous$6 connection_lock = { .__data={ .__lock=0, .__count=(unsigned int)0, .__owner=0, .__nusers=(unsigned int)0, .__kind=0, .__spins=(signed short int)0, .__elision=(signed short int)0, .__list={ .__prev=((struct __pthread_internal_list *)NULL), .__next=((struct __pthread_internal_list *)NULL) } } }; // dl // file plugins.c line 55 static void *dl; // filename // file plugins.c line 54 static char *filename; // foreground // file main.c line 68 signed int foreground; // group // file main.c line 76 const char *group; // ipaddr // file main.c line 69 const char *ipaddr; // listen_stdin // file main.c line 70 signed int listen_stdin; // long_options // file main.c line 87 static struct option long_options[20l] = { { .name="help", .has_arg=0, .flag=(signed int *)(void *)0, .val=128 }, { .name="dump-config", .has_arg=0, .flag=(signed int *)(void *)0, .val=0 }, { .name="foreground", .has_arg=0, .flag=(signed int *)(void *)0, .val=102 }, { .name="no-fork", .has_arg=0, .flag=(signed int *)(void *)0, .val=102 }, { .name="group", .has_arg=1, .flag=(signed int *)(void *)0, .val=103 }, { .name="ip-addr", .has_arg=1, .flag=(signed int *)(void *)0, .val=105 }, { .name="ipaddr", .has_arg=1, .flag=(signed int *)(void *)0, .val=105 }, { .name="pid-file", .has_arg=1, .flag=(signed int *)(void *)0, .val=80 }, { .name="pidfile", .has_arg=1, .flag=(signed int *)(void *)0, .val=80 }, { .name="port", .has_arg=1, .flag=(signed int *)(void *)0, .val=112 }, { .name="read-only", .has_arg=0, .flag=(signed int *)(void *)0, .val=114 }, { .name="readonly", .has_arg=0, .flag=(signed int *)(void *)0, .val=114 }, { .name="run", .has_arg=1, .flag=(signed int *)(void *)0, .val=0 }, { .name="single", .has_arg=0, .flag=(signed int *)(void *)0, .val=115 }, { .name="stdin", .has_arg=0, .flag=(signed int *)(void *)0, .val=115 }, { .name="unix", .has_arg=1, .flag=(signed int *)(void *)0, .val=85 }, { .name="user", .has_arg=1, .flag=(signed int *)(void *)0, .val=117 }, { .name="verbose", .has_arg=0, .flag=(signed int *)(void *)0, .val=118 }, { .name="version", .has_arg=0, .flag=(signed int *)(void *)0, .val=86 }, { .name=(const char *)(void *)0, .has_arg=0, .flag=((signed int *)NULL), .val=0 } }; // optarg // file /usr/include/getopt.h line 57 extern char *optarg; // optind // file /usr/include/getopt.h line 71 extern signed int optind; // pidfile // file main.c line 71 char *pidfile; // plugin // file plugins.c line 56 static struct nbdkit_plugin plugin; // port // file main.c line 72 const char *port; // program_invocation_short_name // file /usr/include/errno.h line 54 extern char *program_invocation_short_name; // quit // file main.c line 79 volatile signed int quit; // random_fifo // file main.c line 82 static char *random_fifo = (char *)(void *)0; // random_fifo_dir // file main.c line 81 static char *random_fifo_dir = (char *)(void *)0; // readonly // file main.c line 73 signed int readonly; // run // file main.c line 74 char *run; // short_options // file main.c line 86 static const char *short_options = "fg:i:p:P:rsu:U:vV"; // stderr // file /usr/include/stdio.h line 170 extern struct _IO_FILE *stderr; // tls_key // file tls.c line 61 static unsigned int tls_key; // unixsocket // file main.c line 75 char *unixsocket; // user // file main.c line 76 const char *user; // verbose // file main.c line 77 signed int verbose; // __bswap_32 // file /usr/include/x86_64-linux-gnu/bits/byteswap.h line 45 static inline unsigned int __bswap_32(unsigned int __bsx) { signed long int return_value___builtin_bswap32$1; return_value___builtin_bswap32$1=__builtin_bswap32((signed long int)__bsx); return (unsigned int)return_value___builtin_bswap32$1; } // __bswap_64 // file /usr/include/x86_64-linux-gnu/bits/byteswap.h line 109 static inline unsigned long int __bswap_64(unsigned long int __bsx) { signed long long int return_value___builtin_bswap64$1; return_value___builtin_bswap64$1=__builtin_bswap64((signed long long int)__bsx); return (unsigned long int)return_value___builtin_bswap64$1; } // _handle_request // file connections.c line 327 static signed int _handle_request(struct connection *conn, unsigned int cmd, unsigned int flags, unsigned long int offset, unsigned int count, void *buf, unsigned int *error) { _Bool flush_after_command; signed int r; flush_after_command = (flags & (unsigned int)(1 << 16)) != (unsigned int)0; _Bool tmp_if_expr$1; if(conn->can_flush == 0) tmp_if_expr$1 = (_Bool)1; else tmp_if_expr$1 = conn->readonly != 0 ? (_Bool)1 : (_Bool)0; if(tmp_if_expr$1) flush_after_command = (_Bool)0; signed int tmp_if_expr$4; signed int *return_value___errno_location$3; signed int tmp_if_expr$7; signed int *return_value___errno_location$6; signed int tmp_if_expr$10; signed int *return_value___errno_location$9; signed int tmp_if_expr$13; signed int *return_value___errno_location$12; switch(cmd) { case (unsigned int)0: { r=plugin_pread(conn, buf, count, offset); if(r == -1) { signed int *return_value___errno_location$2; return_value___errno_location$2=__errno_location(); if(!(*return_value___errno_location$2 == 0)) { return_value___errno_location$3=__errno_location(); tmp_if_expr$4 = *return_value___errno_location$3; } else tmp_if_expr$4 = 5; *error = (unsigned int)tmp_if_expr$4; return 0; } break; } case (unsigned int)1: { r=plugin_pwrite(conn, buf, count, offset); if(r == -1) { signed int *return_value___errno_location$5; return_value___errno_location$5=__errno_location(); if(!(*return_value___errno_location$5 == 0)) { return_value___errno_location$6=__errno_location(); tmp_if_expr$7 = *return_value___errno_location$6; } else tmp_if_expr$7 = 5; *error = (unsigned int)tmp_if_expr$7; return 0; } break; } case (unsigned int)3: { r=plugin_flush(conn); if(r == -1) { signed int *return_value___errno_location$8; return_value___errno_location$8=__errno_location(); if(!(*return_value___errno_location$8 == 0)) { return_value___errno_location$9=__errno_location(); tmp_if_expr$10 = *return_value___errno_location$9; } else tmp_if_expr$10 = 5; *error = (unsigned int)tmp_if_expr$10; return 0; } break; } case (unsigned int)4: { r=plugin_trim(conn, count, offset); if(r == -1) { signed int *return_value___errno_location$11; return_value___errno_location$11=__errno_location(); if(!(*return_value___errno_location$11 == 0)) { return_value___errno_location$12=__errno_location(); tmp_if_expr$13 = *return_value___errno_location$12; } else tmp_if_expr$13 = 5; *error = (unsigned int)tmp_if_expr$13; return 0; } break; } default: abort(); } signed int tmp_if_expr$16; signed int *return_value___errno_location$15; if(!(flush_after_command == (_Bool)0)) { r=plugin_flush(conn); if(r == -1) { signed int *return_value___errno_location$14; return_value___errno_location$14=__errno_location(); if(!(*return_value___errno_location$14 == 0)) { return_value___errno_location$15=__errno_location(); tmp_if_expr$16 = *return_value___errno_location$15; } else tmp_if_expr$16 = 5; *error = (unsigned int)tmp_if_expr$16; return 0; } } return 0; } // _handle_single_connection // file connections.c line 61 static signed int _handle_single_connection(signed int sockin, signed int sockout) { signed int r; struct connection *conn; conn=new_connection(sockin, sockout); signed int return_value_plugin_open$1; const char *return_value_plugin_name$2; signed int return_value_negotiate_handshake$3; if(!(conn == ((struct connection *)NULL))) { return_value_plugin_open$1=plugin_open(conn, readonly); if(return_value_plugin_open$1 == -1) goto err; return_value_plugin_name$2=plugin_name(); tls_set_name(return_value_plugin_name$2); return_value_negotiate_handshake$3=negotiate_handshake(conn); if(return_value_negotiate_handshake$3 == -1) goto err; while(quit == 0) { r=recv_request_send_reply(conn); if(r == -1) goto err; if(r == 0) break; } free_connection(conn); return 0; } else { err: ; free_connection(conn); return -1; } } // _negotiate_handshake // file connections.c line 150 static signed int _negotiate_handshake(struct connection *conn) { struct old_handshake handshake; signed long int r; unsigned long int exportsize; unsigned short int gflags; unsigned short int eflags; signed int fl; r=plugin_get_size(conn); unsigned short int tmp_statement_expression$1; unsigned short int tmp_statement_expression$2; if(r == -1l) return -1; else if(!(r >= 0l)) { nbdkit_error(".get_size function returned invalid value (%li)", r); return -1; } else { exportsize = (unsigned long int)r; conn->exportsize = exportsize; gflags = (unsigned short int)0; eflags = (unsigned short int)1; fl=plugin_can_write(conn); if(fl == -1) return -1; else { if(fl == 0 || !(readonly == 0)) { eflags = eflags | (unsigned short int)2; conn->readonly = 1; } fl=plugin_can_flush(conn); if(fl == -1) return -1; else { if(!(fl == 0)) { eflags = eflags | (unsigned short int)(4 | 8); conn->can_flush = 1; } fl=plugin_is_rotational(conn); if(fl == -1) return -1; else { if(!(fl == 0)) { eflags = eflags | (unsigned short int)16; conn->is_rotational = 1; } fl=plugin_can_trim(conn); if(fl == -1) return -1; else { if(!(fl == 0)) { eflags = eflags | (unsigned short int)32; conn->can_trim = 1; } nbdkit_debug("flags: global 0x%x export 0x%x", gflags, eflags); memset((void *)&handshake, 0, sizeof(struct old_handshake) /*152ul*/ ); memcpy((void *)handshake.nbdmagic, (const void *)"NBDMAGIC", (unsigned long int)8); handshake.version=__bswap_64(0x420281861253UL); handshake.exportsize=__bswap_64(exportsize); unsigned short int _negotiate_handshake$$1$$6$$__v; unsigned short int _negotiate_handshake$$1$$6$$__x = (unsigned short int)gflags; asm("rorw $8, %w0" : "=r"(_negotiate_handshake$$1$$6$$__v) : "0"(_negotiate_handshake$$1$$6$$__x) : "cc"); tmp_statement_expression$1 = _negotiate_handshake$$1$$6$$__v; handshake.gflags = tmp_statement_expression$1; unsigned short int __v; unsigned short int __x = (unsigned short int)eflags; asm("rorw $8, %w0" : "=r"(__v) : "0"(__x) : "cc"); tmp_statement_expression$2 = __v; handshake.eflags = tmp_statement_expression$2; signed int return_value_xwrite$3; return_value_xwrite$3=xwrite(conn->sockout, (const void *)&handshake, sizeof(struct old_handshake) /*152ul*/ ); if(return_value_xwrite$3 == -1) { nbdkit_error("write: %m"); return -1; } else return 0; } } } } } } // accept_connection // file sockets.c line 226 static void accept_connection(signed int listen_sock) { signed int err; union pthread_attr_t attrs; unsigned long int thread; struct thread_data thread_data; static unsigned long int instance_num = (unsigned long int)1; unsigned long int tmp_post$1 = instance_num; instance_num = instance_num + 1ul; thread_data.instance_num = tmp_post$1; thread_data.addrlen = (unsigned int)sizeof(struct sockaddr) /*16ul*/ ; signed int *return_value___errno_location$2; _Bool tmp_if_expr$4; signed int *return_value___errno_location$3; do { again: ; thread_data.sock=accept(listen_sock, &thread_data.addr, &thread_data.addrlen); if(!(thread_data.sock == -1)) goto __CPROVER_DUMP_L4; return_value___errno_location$2=__errno_location(); if(*return_value___errno_location$2 == 4) tmp_if_expr$4 = (_Bool)1; else { return_value___errno_location$3=__errno_location(); tmp_if_expr$4 = *return_value___errno_location$3 == 11 ? (_Bool)1 : (_Bool)0; } } while(tmp_if_expr$4); perror("accept"); goto __CPROVER_DUMP_L6; __CPROVER_DUMP_L4: ; pthread_attr_init(&attrs); pthread_attr_setdetachstate(&attrs, 1); err=pthread_create(&thread, &attrs, start_thread, (void *)&thread_data); pthread_attr_destroy(&attrs); if(!(err == 0)) { char *return_value_strerror$5; return_value_strerror$5=strerror(err); fprintf(stderr, "%s: pthread_create: %s\n", program_invocation_short_name, return_value_strerror$5); close(thread_data.sock); goto __CPROVER_DUMP_L6; } __CPROVER_DUMP_L6: ; } // accept_incoming_connections // file internal.h line 111 extern void accept_incoming_connections(signed int *socks, unsigned long int nr_socks) { const signed long int accept_incoming_connections$array_size0 = (signed long int)nr_socks; struct pollfd fds[accept_incoming_connections$array_size0]; unsigned long int i; signed int r; _Bool tmp_if_expr$3; signed int *return_value___errno_location$2; while(quit == 0) { i = (unsigned long int)0; for( ; !(i >= nr_socks); i = i + 1ul) { fds[(signed long int)i].fd = socks[(signed long int)i]; fds[(signed long int)i].events = (signed short int)0x001; fds[(signed long int)i].revents = (signed short int)0; } r=poll(fds, nr_socks, -1); if(r == -1) { signed int *return_value___errno_location$1; return_value___errno_location$1=__errno_location(); if(*return_value___errno_location$1 == 4) tmp_if_expr$3 = (_Bool)1; else { return_value___errno_location$2=__errno_location(); tmp_if_expr$3 = *return_value___errno_location$2 == 11 ? (_Bool)1 : (_Bool)0; } if(tmp_if_expr$3) continue; perror("poll"); exit(1); } i = (unsigned long int)0; for( ; !(i >= nr_socks); i = i + 1ul) if(!((0x001 & (signed int)fds[(signed long int)i].revents) == 0)) accept_connection(fds[(signed long int)i].fd); } } // bind_tcpip_socket // file internal.h line 110 extern signed int * bind_tcpip_socket(unsigned long int *nr_socks) { struct addrinfo *ai = (struct addrinfo *)(void *)0; struct addrinfo hints; struct addrinfo *a; signed int err; signed int opt; signed int *socks = (signed int *)(void *)0; _Bool addr_in_use; if(port == ((const char *)NULL)) port = "10809"; memset((void *)&hints, 0, sizeof(struct addrinfo) /*48ul*/ ); hints.ai_flags = 0x0001 | 0x0020; hints.ai_socktype = 1; err=getaddrinfo(ipaddr, port, &hints, &ai); if(!(err == 0)) { const char *return_value_gai_strerror$1; return_value_gai_strerror$1=gai_strerror(err); fprintf(stderr, "%s: getaddrinfo: %s: %s: %s", program_invocation_short_name, ipaddr != ((const char *)NULL) ? ipaddr : "<any>", port, return_value_gai_strerror$1); exit(1); } *nr_socks = (unsigned long int)0; a = ai; for( ; !(a == ((struct addrinfo *)NULL)); a = a->ai_next) { signed int sock; sock=socket(a->ai_family, a->ai_socktype, a->ai_protocol); if(sock == -1) { perror("socket"); exit(1); } opt = 1; signed int return_value_setsockopt$2; return_value_setsockopt$2=setsockopt(sock, 1, 2, (const void *)&opt, (unsigned int)sizeof(signed int) /*4ul*/ ); if(return_value_setsockopt$2 == -1) perror("setsockopt: SO_REUSEADDR"); if(a->ai_family == 10) { signed int return_value_setsockopt$3; return_value_setsockopt$3=setsockopt(sock, 41, 26, (const void *)&opt, (unsigned int)sizeof(signed int) /*4ul*/ ); if(return_value_setsockopt$3 == -1) perror("setsockopt: IPv6 only"); } signed int return_value_bind$5; return_value_bind$5=bind(sock, a->ai_addr, a->ai_addrlen); if(return_value_bind$5 == -1) { signed int *return_value___errno_location$4; return_value___errno_location$4=__errno_location(); if(*return_value___errno_location$4 == 98) { addr_in_use = (_Bool)1; close(sock); goto __CPROVER_DUMP_L12; } perror("bind"); exit(1); } signed int return_value_listen$6; return_value_listen$6=listen(sock, 128); if(return_value_listen$6 == -1) { perror("listen"); exit(1); } *nr_socks = *nr_socks + 1ul; void *return_value_realloc$7; return_value_realloc$7=realloc((void *)socks, sizeof(signed int) /*4ul*/ * *nr_socks); socks = (signed int *)return_value_realloc$7; if(socks == ((signed int *)NULL)) { perror("realloc"); exit(1); } socks[(signed long int)(*nr_socks - (unsigned long int)1)] = sock; __CPROVER_DUMP_L12: ; } freeaddrinfo(ai); if(*nr_socks == 0ul) { if(!(addr_in_use == (_Bool)0)) { char *return_value_strerror$8; return_value_strerror$8=strerror(98); fprintf(stderr, "%s: unable to bind to any sockets: %s\n", program_invocation_short_name, return_value_strerror$8); exit(1); } } nbdkit_debug("bound to IP address %s:%s (%zu socket(s))", ipaddr != ((const char *)NULL) ? ipaddr : "<any>", port, *nr_socks); return socks; } // bind_unix_socket // file internal.h line 109 extern signed int * bind_unix_socket(unsigned long int *nr_socks) { unsigned long int len; signed int sock; struct sockaddr_un addr; signed int *ret; /* assertion unixsocket */ assert(unixsocket != ((char *)NULL)); /* assertion unixsocket[0] == '/' */ assert((signed int)unixsocket[(signed long int)0] == 47); len=strlen(unixsocket); if(len >= 108ul) { fprintf(stderr, "%s: -U option: path too long (max is %d) bytes", program_invocation_short_name, 108 - 1); exit(1); } sock=socket(1, 1 | 524288, 0); if(sock == -1) { perror("socket"); exit(1); } addr.sun_family = (unsigned short int)1; memcpy((void *)addr.sun_path, (const void *)unixsocket, len + (unsigned long int)1); signed int return_value_bind$1; return_value_bind$1=bind(sock, (struct sockaddr *)&addr, (unsigned int)sizeof(struct sockaddr_un) /*110ul*/ ); if(return_value_bind$1 == -1) { perror(unixsocket); exit(1); } signed int return_value_listen$2; return_value_listen$2=listen(sock, 128); if(return_value_listen$2 == -1) { perror("listen"); exit(1); } void *return_value_malloc$3; return_value_malloc$3=malloc(sizeof(signed int) /*4ul*/ ); ret = (signed int *)return_value_malloc$3; if(ret == ((signed int *)NULL)) { perror("malloc"); exit(1); } ret[(signed long int)0] = sock; *nr_socks = (unsigned long int)1; nbdkit_debug("bound to unix socket %s", unixsocket); return ret; } // change_user // file main.c line 468 static void change_user(void) { if(!(group == ((const char *)NULL))) { unsigned int gid; gid=parsegroup(group); signed int return_value_setgid$1; return_value_setgid$1=setgid(gid); if(return_value_setgid$1 == -1) { perror("setgid"); exit(1); } signed int return_value_setgroups$2; return_value_setgroups$2=setgroups((unsigned long int)1, &gid); if(return_value_setgroups$2 == -1) { perror("setgroups"); exit(1); } nbdkit_debug("changed group to %s", group); } if(!(user == ((const char *)NULL))) { unsigned int uid; uid=parseuser(user); signed int return_value_setuid$3; return_value_setuid$3=setuid(uid); if(return_value_setuid$3 == -1) { perror("setuid"); exit(1); } nbdkit_debug("changed user to %s", user); } } // cleanup_free // file cleanup.c line 45 extern void cleanup_free(void *ptr) { free(*((void **)ptr)); } // display_version // file main.c line 122 static void display_version(void) { printf("%s %s\n", (const void *)"nbdkit", (const void *)"1.1.11"); } // dump_config // file main.c line 128 static void dump_config(void) { printf("%s=%s\n", (const void *)"bindir", (const void *)"/usr/bin"); printf("%s=%s\n", (const void *)"libdir", (const void *)"/usr/lib/x86_64-linux-gnu"); printf("%s=%s\n", (const void *)"name", (const void *)"nbdkit"); printf("%s=%s\n", (const void *)"plugindir", (const void *)"/usr/lib/x86_64-linux-gnu/nbdkit/plugins"); printf("%s=%s\n", (const void *)"sbindir", (const void *)"/usr/sbin"); printf("%s=%s\n", (const void *)"sysconfdir", (const void *)"/etc"); printf("%s=%s\n", (const void *)"version", (const void *)"1.1.11"); } // fork_into_background // file main.c line 530 static void fork_into_background(void) { signed int pid; if(foreground == 0) { pid=fork(); if(pid == -1) { perror("fork"); exit(1); } if(pid >= 1) exit(0); chdir("/"); close(0); close(1); open("/dev/null", 00); open("/dev/null", 01); if(verbose == 0) dup2(1, 2); signed int return_value_getpid$1; return_value_getpid$1=getpid(); nbdkit_debug("forked into background (new pid = %d)", return_value_getpid$1); } } // free_connection // file connections.c line 128 static void free_connection(struct connection *conn) { if(!(conn == ((struct connection *)NULL))) { if(conn->sockin >= 0) close(conn->sockin); if(conn->sockout >= 0) { if(!(conn->sockin == conn->sockout)) close(conn->sockout); } pthread_mutex_destroy(&conn->request_lock); if(!(conn->handle == NULL)) plugin_close(conn); free((void *)conn); } } // free_listening_sockets // file internal.h line 112 extern void free_listening_sockets(signed int *socks, unsigned long int nr_socks) { unsigned long int i = (unsigned long int)0; for( ; !(i >= nr_socks); i = i + 1ul) close(socks[(signed long int)i]); free((void *)socks); } // free_tls // file tls.c line 64 static void free_tls(void *tlsv) { struct tls *tls = (struct tls *)tlsv; free((void *)tls->addr); free((void *)tls); } // handle_quit // file main.c line 443 static void handle_quit(signed int sig) { quit = 1; } // handle_request // file connections.c line 389 static signed int handle_request(struct connection *conn, unsigned int cmd, unsigned int flags, unsigned long int offset, unsigned int count, void *buf, unsigned int *error) { signed int r; plugin_lock_request(conn); r=_handle_request(conn, cmd, flags, offset, count, buf, error); plugin_unlock_request(conn); return r; } // handle_single_connection // file connections.c line 98 extern signed int handle_single_connection(signed int sockin, signed int sockout) { signed int r; plugin_lock_connection(); r=_handle_single_connection(sockin, sockout); plugin_unlock_connection(); return r; } // main // file main.c line 140 signed int main(signed int argc, char **argv) { signed int c; signed int option_index; signed int help = 0; signed int version = 0; tls_init(); signed int return_value_strcmp$2; signed int return_value_strcmp$1; signed int return_value_strcmp$3; do { c=getopt_long(argc, argv, short_options, long_options, &option_index); if(c == -1) break; switch(c) { case 0: { return_value_strcmp$2=strcmp(long_options[(signed long int)option_index].name, "dump-config"); if(return_value_strcmp$2 == 0) { dump_config(); exit(0); } else { return_value_strcmp$1=strcmp(long_options[(signed long int)option_index].name, "run"); if(return_value_strcmp$1 == 0) { run = optarg; foreground = 1; } else { fprintf(stderr, "%s: unknown long option: %s (%d)\n", program_invocation_short_name, long_options[(signed long int)option_index].name, option_index); exit(1); } } break; } case 102: { foreground = 1; break; } case 103: { group = optarg; break; } case 105: { ipaddr = optarg; break; } case 80: { pidfile=nbdkit_absolute_path(optarg); if(pidfile == ((char *)NULL)) exit(1); break; } case 112: { port = optarg; break; } case 114: { readonly = 1; break; } case 115: { listen_stdin = 1; break; } case 85: { return_value_strcmp$3=strcmp(optarg, "-"); if(return_value_strcmp$3 == 0) unixsocket=make_random_fifo(); else unixsocket=nbdkit_absolute_path(optarg); if(unixsocket == ((char *)NULL)) exit(1); break; } case 117: { user = optarg; break; } case 118: { verbose = 1; break; } case 86: { version = 1; break; } case 128: { help = 1; break; } default: { usage(); exit(1); } } } while((_Bool)1); if(optind >= argc) { if(!(help == 0)) { usage(); exit(0); } if(!(version == 0)) { display_version(); exit(0); } fprintf(stderr, "%s: no plugins given on the command line.\nRead nbdkit(1) for documentation.\n", program_invocation_short_name); exit(1); } while(!(optind >= argc)) { const char *main$$1$$3$$filename = argv[(signed long int)optind]; char *p; open_plugin_so(main$$1$$3$$filename); optind = optind + 1; while(!(optind >= argc)) { p=strchr(argv[(signed long int)optind], 61); if(p == ((char *)NULL)) break; if(help == 0 && version == 0) { *p = (char)0; plugin_config(argv[(signed long int)optind], p + (signed long int)1); optind = optind + 1; } } if(!(help == 0)) { usage(); printf("\n%s:\n\n", main$$1$$3$$filename); plugin_usage(); exit(0); } if(!(version == 0)) { display_version(); plugin_version(); exit(0); } plugin_config_complete(); optind = optind + 1; if(!(optind >= argc)) { fprintf(stderr, "%s: this server only supports a single plugin\n", program_invocation_short_name); exit(1); } } start_serving(); plugin_cleanup(); free((void *)unixsocket); free((void *)pidfile); if(!(random_fifo == ((char *)NULL))) { unlink(random_fifo); free((void *)random_fifo); } if(!(random_fifo_dir == ((char *)NULL))) { rmdir(random_fifo_dir); free((void *)random_fifo_dir); } exit(0); } // make_random_fifo // file main.c line 323 static char * make_random_fifo(void) { char template[18l] = { '/', 't', 'm', 'p', '/', 'n', 'b', 'd', 'k', 'i', 't', 'X', 'X', 'X', 'X', 'X', 'X', 0 }; char *make_random_fifo$$1$$unixsocket; char *return_value_mkdtemp$1; return_value_mkdtemp$1=mkdtemp(template); if(return_value_mkdtemp$1 == ((char *)NULL)) { perror("mkdtemp"); return (char *)(void *)0; } else { random_fifo_dir=strdup(template); if(random_fifo_dir == ((char *)NULL)) { perror("strdup"); return (char *)(void *)0; } else { signed int return_value_asprintf$2; return_value_asprintf$2=asprintf(&random_fifo, "%s/socket", (const void *)template); if(return_value_asprintf$2 == -1) { perror("asprintf"); return (char *)(void *)0; } else { make_random_fifo$$1$$unixsocket=strdup(random_fifo); if(make_random_fifo$$1$$unixsocket == ((char *)NULL)) { perror("strdup"); return (char *)(void *)0; } else return make_random_fifo$$1$$unixsocket; } } } } // nbdkit_absolute_path // file ../include/nbdkit-plugin.h line 91 extern char * nbdkit_absolute_path(const char *path) { char *pwd = (char *)(void *)0; char *ret; _Bool tmp_if_expr$1; if(path == ((const char *)NULL)) tmp_if_expr$1 = (_Bool)1; else tmp_if_expr$1 = (signed int)*path == 0 ? (_Bool)1 : (_Bool)0; if(tmp_if_expr$1) { nbdkit_error("cannot convert null or empty path to an absolute path"); return (char *)(void *)0; } else if((signed int)*path == 47) { ret=strdup(path); if(ret == ((char *)NULL)) { nbdkit_error("strdup: %m"); return (char *)(void *)0; } return ret; } else { pwd=get_current_dir_name(); if(pwd == ((char *)NULL)) { nbdkit_error("get_current_dir_name: %m"); return (char *)(void *)0; } else { signed int return_value_asprintf$2; return_value_asprintf$2=asprintf(&ret, "%s/%s", pwd, path); if(return_value_asprintf$2 == -1) { nbdkit_error("asprintf: %m"); return (char *)(void *)0; } else return ret; } } } // nbdkit_debug // file ../include/nbdkit-plugin.h line 87 extern void nbdkit_debug(const char *fs, ...) { void **args; signed int err; signed int *return_value___errno_location$1; return_value___errno_location$1=__errno_location(); err = *return_value___errno_location$1; if(!(verbose == 0)) { prologue("debug"); args = (void **)&fs; vfprintf(stderr, fs, args); args = ((void **)NULL); fprintf(stderr, "\n"); signed int *return_value___errno_location$2; return_value___errno_location$2=__errno_location(); *return_value___errno_location$2 = err; } } // nbdkit_error // file ../include/nbdkit-plugin.h line 84 extern void nbdkit_error(const char *fs, ...) { void **args; signed int err; signed int *return_value___errno_location$1; return_value___errno_location$1=__errno_location(); err = *return_value___errno_location$1; prologue("error"); args = (void **)&fs; vfprintf(stderr, fs, args); args = ((void **)NULL); fprintf(stderr, "\n"); signed int *return_value___errno_location$2; return_value___errno_location$2=__errno_location(); *return_value___errno_location$2 = err; } // nbdkit_parse_size // file utils.c line 86 extern signed long int nbdkit_parse_size(const char *str) { unsigned long int size; char t; signed int return_value_sscanf$1; return_value_sscanf$1=sscanf(str, "%lu%c", &size, &t); if(return_value_sscanf$1 == 2) switch((signed int)t) { case 98: case 66: return (signed long int)size; case 107: case 75: return (signed long int)size * (signed long int)1024; case 109: case 77: return (signed long int)size * (signed long int)1024 * (signed long int)1024; case 103: case 71: return (signed long int)size * (signed long int)1024 * (signed long int)1024 * (signed long int)1024; case 116: case 84: return (signed long int)size * (signed long int)1024 * (signed long int)1024 * (signed long int)1024 * (signed long int)1024; case 112: case 80: return (signed long int)size * (signed long int)1024 * (signed long int)1024 * (signed long int)1024 * (signed long int)1024 * (signed long int)1024; case 101: case 69: return (signed long int)size * (signed long int)1024 * (signed long int)1024 * (signed long int)1024 * (signed long int)1024 * (signed long int)1024 * (signed long int)1024; case 115: case 83: return (signed long int)size * (signed long int)512; default: { nbdkit_error("could not parse size: unknown specifier '%c'", t); return (signed long int)-1; } } else { signed int return_value_sscanf$2; return_value_sscanf$2=sscanf(str, "%lu", &size); if(return_value_sscanf$2 == 1) return (signed long int)size; else { nbdkit_error("could not parse size string (%s)", str); return (signed long int)-1; } } } // nbdkit_vdebug // file errors.c line 65 extern void nbdkit_vdebug(const char *fs, void **args) { signed int err; signed int *return_value___errno_location$1; return_value___errno_location$1=__errno_location(); err = *return_value___errno_location$1; if(!(verbose == 0)) { prologue("debug"); vfprintf(stderr, fs, args); fprintf(stderr, "\n"); signed int *return_value___errno_location$2; return_value___errno_location$2=__errno_location(); *return_value___errno_location$2 = err; } } // nbdkit_verror // file errors.c line 104 extern void nbdkit_verror(const char *fs, void **args) { signed int err; signed int *return_value___errno_location$1; return_value___errno_location$1=__errno_location(); err = *return_value___errno_location$1; prologue("error"); vfprintf(stderr, fs, args); fprintf(stderr, "\n"); signed int *return_value___errno_location$2; return_value___errno_location$2=__errno_location(); *return_value___errno_location$2 = err; } // negotiate_handshake // file connections.c line 222 static signed int negotiate_handshake(struct connection *conn) { signed int r; plugin_lock_request(conn); r=_negotiate_handshake(conn); plugin_unlock_request(conn); return r; } // new_connection // file connections.c line 110 static struct connection * new_connection(signed int sockin, signed int sockout) { struct connection *conn; void *return_value_calloc$1; return_value_calloc$1=calloc((unsigned long int)1, sizeof(struct connection) /*80ul*/ ); conn = (struct connection *)return_value_calloc$1; if(conn == ((struct connection *)NULL)) { perror("malloc"); return (struct connection *)(void *)0; } else { conn->sockin = sockin; conn->sockout = sockout; pthread_mutex_init(&conn->request_lock, (const union anonymous$7 *)(void *)0); return conn; } } // open_plugin_so // file main.c line 354 static void open_plugin_so(const char *name) { char *open_plugin_so$$1$$filename = (char *)name; signed int free_filename = 0; void *open_plugin_so$$1$$dl; struct nbdkit_plugin * (*plugin_init)(void); char *error; char *return_value_strchr$3; return_value_strchr$3=strchr(name, 46); char *return_value_strchr$2; if(return_value_strchr$3 == ((char *)NULL)) { return_value_strchr$2=strchr(name, 47); if(return_value_strchr$2 == ((char *)NULL)) { signed int return_value_asprintf$1; return_value_asprintf$1=asprintf(&open_plugin_so$$1$$filename, "%s/nbdkit-%s-plugin.so", (const void *)"/usr/lib/x86_64-linux-gnu/nbdkit/plugins", name); if(return_value_asprintf$1 == -1) { perror("asprintf"); exit(1); } free_filename = 1; } } open_plugin_so$$1$$dl=dlopen(open_plugin_so$$1$$filename, 0x00002 | 0x00100); if(open_plugin_so$$1$$dl == NULL) { char *return_value_dlerror$4; return_value_dlerror$4=dlerror(); fprintf(stderr, "%s: %s: %s\n", program_invocation_short_name, open_plugin_so$$1$$filename, return_value_dlerror$4); exit(1); } dlerror(); *((void **)&plugin_init)=dlsym(open_plugin_so$$1$$dl, "plugin_init"); error=dlerror(); if(!(error == ((char *)NULL))) { fprintf(stderr, "%s: %s: %s\n", program_invocation_short_name, name, error); exit(1); } if(plugin_init == ((struct nbdkit_plugin * (*)(void))NULL)) { fprintf(stderr, "%s: %s: invalid plugin_init\n", program_invocation_short_name, name); exit(1); } plugin_register(open_plugin_so$$1$$filename, open_plugin_so$$1$$dl, plugin_init); if(!(free_filename == 0)) free((void *)open_plugin_so$$1$$filename); } // parsegroup // file main.c line 673 static unsigned int parsegroup(const char *id) { struct group *grp; signed int saved_errno; signed int *return_value___errno_location$1; return_value___errno_location$1=__errno_location(); *return_value___errno_location$1 = 0; grp=getgrnam(id); char *return_value_strerror$4; if(grp == ((struct group *)NULL)) { signed int val; signed int *return_value___errno_location$2; return_value___errno_location$2=__errno_location(); saved_errno = *return_value___errno_location$2; signed int return_value_sscanf$3; return_value_sscanf$3=sscanf(id, "%d", &val); if(return_value_sscanf$3 == 1) return (unsigned int)val; fprintf(stderr, "%s: -g option: %s is not a valid group name or gid", program_invocation_short_name, id); if(!(saved_errno == 0)) { return_value_strerror$4=strerror(saved_errno); fprintf(stderr, " (getgrnam error: %s)", return_value_strerror$4); } fprintf(stderr, "\n"); exit(1); } return grp->gr_gid; } // parseuser // file main.c line 645 static unsigned int parseuser(const char *id) { struct passwd *pwd; signed int saved_errno; signed int *return_value___errno_location$1; return_value___errno_location$1=__errno_location(); *return_value___errno_location$1 = 0; pwd=getpwnam(id); char *return_value_strerror$4; if(pwd == ((struct passwd *)NULL)) { signed int val; signed int *return_value___errno_location$2; return_value___errno_location$2=__errno_location(); saved_errno = *return_value___errno_location$2; signed int return_value_sscanf$3; return_value_sscanf$3=sscanf(id, "%d", &val); if(return_value_sscanf$3 == 1) return (unsigned int)val; fprintf(stderr, "%s: -u option: %s is not a valid user name or uid", program_invocation_short_name, id); if(!(saved_errno == 0)) { return_value_strerror$4=strerror(saved_errno); fprintf(stderr, " (getpwnam error: %s)", return_value_strerror$4); } fprintf(stderr, "\n"); exit(1); } return pwd->pw_uid; } // plugin_can_flush // file internal.h line 100 extern signed int plugin_can_flush(struct connection *conn) { /* assertion dl */ assert(dl != NULL); /* assertion conn->handle */ assert(conn->handle != NULL); nbdkit_debug("can_flush"); signed int return_value; if(!(plugin.can_flush == ((signed int (*)(void *))NULL))) { return_value=plugin.can_flush(conn->handle); return return_value; } else return (signed int)(plugin.flush != (signed int (*)(void *))(void *)0); } // plugin_can_trim // file internal.h line 102 extern signed int plugin_can_trim(struct connection *conn) { /* assertion dl */ assert(dl != NULL); /* assertion conn->handle */ assert(conn->handle != NULL); nbdkit_debug("can_trim"); signed int return_value; if(!(plugin.can_trim == ((signed int (*)(void *))NULL))) { return_value=plugin.can_trim(conn->handle); return return_value; } else return (signed int)(plugin.trim != (signed int (*)(void *, unsigned int, unsigned long int))(void *)0); } // plugin_can_write // file internal.h line 99 extern signed int plugin_can_write(struct connection *conn) { /* assertion dl */ assert(dl != NULL); /* assertion conn->handle */ assert(conn->handle != NULL); nbdkit_debug("can_write"); signed int return_value; if(!(plugin.can_write == ((signed int (*)(void *))NULL))) { return_value=plugin.can_write(conn->handle); return return_value; } else return (signed int)(plugin.pwrite != (signed int (*)(void *, const void *, unsigned int, unsigned long int))(void *)0); } // plugin_cleanup // file internal.h line 86 extern void plugin_cleanup(void) { if(!(dl == NULL)) { nbdkit_debug("%s: unload", filename); if(!(plugin.unload == ((void (*)(void))NULL))) plugin.unload(); dlclose(dl); dl = (void *)0; free((void *)filename); filename = (char *)(void *)0; } } // plugin_close // file internal.h line 97 extern void plugin_close(struct connection *conn) { /* assertion dl */ assert(dl != NULL); /* assertion conn->handle */ assert(conn->handle != NULL); nbdkit_debug("close"); if(!(plugin.close == ((void (*)(void *))NULL))) plugin.close(conn->handle); conn->handle = (void *)0; } // plugin_config // file internal.h line 90 extern void plugin_config(const char *key, const char *value) { /* assertion dl */ assert(dl != NULL); nbdkit_debug("%s: config key=%s, value=%s", filename, key, value); if(plugin.config == ((signed int (*)(const char *, const char *))NULL)) { fprintf(stderr, "%s: %s: this plugin does not need command line configuration\nTry using: %s --help %s\n", program_invocation_short_name, filename, program_invocation_short_name, filename); exit(1); } signed int return_value; return_value=plugin.config(key, value); if(return_value == -1) exit(1); } // plugin_config_complete // file internal.h line 91 extern void plugin_config_complete(void) { /* assertion dl */ assert(dl != NULL); nbdkit_debug("%s: config_complete", filename); if(!(plugin.config_complete == ((signed int (*)(void))NULL))) { signed int return_value; return_value=plugin.config_complete(); if(return_value == -1) exit(1); } } // plugin_flush // file internal.h line 105 extern signed int plugin_flush(struct connection *conn) { /* assertion dl */ assert(dl != NULL); /* assertion conn->handle */ assert(conn->handle != NULL); nbdkit_debug("flush"); signed int return_value; if(!(plugin.flush == ((signed int (*)(void *))NULL))) { return_value=plugin.flush(conn->handle); return return_value; } else { signed int *return_value___errno_location$1; return_value___errno_location$1=__errno_location(); *return_value___errno_location$1 = 22; return -1; } } // plugin_get_size // file internal.h line 98 extern signed long int plugin_get_size(struct connection *conn) { /* assertion dl */ assert(dl != NULL); /* assertion conn->handle */ assert(conn->handle != NULL); /* assertion plugin.get_size != ((void *)0) */ assert(plugin.get_size != (signed long int (*)(void *))(void *)0); nbdkit_debug("get_size"); signed long int return_value; return_value=plugin.get_size(conn->handle); return return_value; } // plugin_is_rotational // file internal.h line 101 extern signed int plugin_is_rotational(struct connection *conn) { /* assertion dl */ assert(dl != NULL); /* assertion conn->handle */ assert(conn->handle != NULL); nbdkit_debug("is_rotational"); signed int return_value; if(!(plugin.is_rotational == ((signed int (*)(void *))NULL))) { return_value=plugin.is_rotational(conn->handle); return return_value; } else return 0; } // plugin_lock_connection // file internal.h line 92 extern void plugin_lock_connection(void) { /* assertion dl */ assert(dl != NULL); if(!(plugin._thread_model >= 1)) { nbdkit_debug("%s: acquire connection lock", filename); pthread_mutex_lock(&connection_lock); } } // plugin_lock_request // file internal.h line 94 extern void plugin_lock_request(struct connection *conn) { /* assertion dl */ assert(dl != NULL); if(!(plugin._thread_model >= 2)) { nbdkit_debug("acquire global request lock"); pthread_mutex_lock(&all_requests_lock); } if(!(plugin._thread_model >= 3)) { nbdkit_debug("acquire per-connection request lock"); pthread_mutex_lock(&conn->request_lock); } } // plugin_name // file internal.h line 87 extern const char * plugin_name(void) { /* assertion dl */ assert(dl != NULL); return plugin.name; } // plugin_open // file internal.h line 96 extern signed int plugin_open(struct connection *conn, signed int readonly) { void *handle; /* assertion dl */ assert(dl != NULL); /* assertion conn->handle == ((void *)0) */ assert(conn->handle == (void *)0); /* assertion plugin.open != ((void *)0) */ assert(plugin.open != (void * (*)(signed int))(void *)0); nbdkit_debug("%s: open readonly=%d", filename, readonly); handle=plugin.open(readonly); if(handle == NULL) return -1; else { conn->handle = handle; return 0; } } // plugin_pread // file internal.h line 103 extern signed int plugin_pread(struct connection *conn, void *buf, unsigned int count, unsigned long int offset) { /* assertion dl */ assert(dl != NULL); /* assertion conn->handle */ assert(conn->handle != NULL); /* assertion plugin.pread != ((void *)0) */ assert(plugin.pread != (signed int (*)(void *, void *, unsigned int, unsigned long int))(void *)0); nbdkit_debug("pread count=%u offset=%lu", count, offset); signed int return_value; return_value=plugin.pread(conn->handle, buf, count, offset); return return_value; } // plugin_pwrite // file internal.h line 104 extern signed int plugin_pwrite(struct connection *conn, void *buf, unsigned int count, unsigned long int offset) { /* assertion dl */ assert(dl != NULL); /* assertion conn->handle */ assert(conn->handle != NULL); nbdkit_debug("pwrite count=%u offset=%lu", count, offset); signed int return_value; if(!(plugin.pwrite == ((signed int (*)(void *, const void *, unsigned int, unsigned long int))NULL))) { return_value=plugin.pwrite(conn->handle, buf, count, offset); return return_value; } else { signed int *return_value___errno_location$1; return_value___errno_location$1=__errno_location(); *return_value___errno_location$1 = 30; return -1; } } // plugin_register // file internal.h line 85 extern void plugin_register(const char *_filename, void *_dl, struct nbdkit_plugin * (*plugin_init)(void)) { struct nbdkit_plugin *_plugin; unsigned long int i; unsigned long int len; unsigned long int size; filename=strdup(_filename); if(filename == ((char *)NULL)) { perror("strdup"); exit(1); } dl = _dl; nbdkit_debug("registering %s", filename); _plugin=plugin_init(); if(_plugin == ((struct nbdkit_plugin *)NULL)) { fprintf(stderr, "%s: %s: plugin registration function failed\n", program_invocation_short_name, filename); exit(1); } if(!(_plugin->_api_version == 1)) { fprintf(stderr, "%s: %s: plugin is incompatible with this version of nbdkit (_api_version = %d)\n", program_invocation_short_name, filename, _plugin->_api_version); exit(1); } size = sizeof(struct nbdkit_plugin) /*176ul*/ ; memset((void *)&plugin, 0, size); if(!(_plugin->_struct_size >= size)) size = _plugin->_struct_size; memcpy((void *)&plugin, (const void *)_plugin, size); if(plugin.name == ((const char *)NULL)) { fprintf(stderr, "%s: %s: plugin must have a .name field\n", program_invocation_short_name, filename); exit(1); } if(plugin.open == ((void * (*)(signed int))NULL)) { fprintf(stderr, "%s: %s: plugin must have a .open callback\n", program_invocation_short_name, filename); exit(1); } if(plugin.get_size == ((signed long int (*)(void *))NULL)) { fprintf(stderr, "%s: %s: plugin must have a .get_size callback\n", program_invocation_short_name, filename); exit(1); } if(plugin.pread == ((signed int (*)(void *, void *, unsigned int, unsigned long int))NULL)) { fprintf(stderr, "%s: %s: plugin must have a .pread callback\n", program_invocation_short_name, filename); exit(1); } len=strlen(plugin.name); if(len == 0ul) { fprintf(stderr, "%s: %s: plugin.name field must not be empty\n", program_invocation_short_name, filename); exit(1); } i = (unsigned long int)0; _Bool tmp_if_expr$1; _Bool tmp_if_expr$3; _Bool tmp_if_expr$2; _Bool tmp_if_expr$5; _Bool tmp_if_expr$4; if(!(i >= len)) { if((signed int)plugin.name[(signed long int)i] >= 48) tmp_if_expr$1 = (signed int)plugin.name[(signed long int)i] <= 57 ? (_Bool)1 : (_Bool)0; else tmp_if_expr$1 = (_Bool)0; if(tmp_if_expr$1) tmp_if_expr$3 = (_Bool)1; else { if((signed int)plugin.name[(signed long int)i] >= 97) tmp_if_expr$2 = (signed int)plugin.name[(signed long int)i] <= 122 ? (_Bool)1 : (_Bool)0; else tmp_if_expr$2 = (_Bool)0; tmp_if_expr$3 = tmp_if_expr$2 ? (_Bool)1 : (_Bool)0; } if(tmp_if_expr$3) tmp_if_expr$5 = (_Bool)1; else { if((signed int)plugin.name[(signed long int)i] >= 65) tmp_if_expr$4 = (signed int)plugin.name[(signed long int)i] <= 90 ? (_Bool)1 : (_Bool)0; else tmp_if_expr$4 = (_Bool)0; tmp_if_expr$5 = tmp_if_expr$4 ? (_Bool)1 : (_Bool)0; } if(!tmp_if_expr$5) { fprintf(stderr, "%s: %s: plugin.name ('%s') field must contain only ASCII alphanumeric characters\n", program_invocation_short_name, filename, plugin.name); exit(1); } i = i + 1ul; } nbdkit_debug("registered %s (name %s)", filename, plugin.name); nbdkit_debug("%s: load", filename); if(!(plugin.load == ((void (*)(void))NULL))) plugin.load(); } // plugin_trim // file internal.h line 106 extern signed int plugin_trim(struct connection *conn, unsigned int count, unsigned long int offset) { /* assertion dl */ assert(dl != NULL); /* assertion conn->handle */ assert(conn->handle != NULL); nbdkit_debug("trim count=%u offset=%lu", count, offset); signed int return_value; if(!(plugin.trim == ((signed int (*)(void *, unsigned int, unsigned long int))NULL))) { return_value=plugin.trim(conn->handle, count, offset); return return_value; } else { signed int *return_value___errno_location$1; return_value___errno_location$1=__errno_location(); *return_value___errno_location$1 = 22; return -1; } } // plugin_unlock_connection // file internal.h line 93 extern void plugin_unlock_connection(void) { /* assertion dl */ assert(dl != NULL); if(!(plugin._thread_model >= 1)) { nbdkit_debug("%s: release connection lock", filename); pthread_mutex_unlock(&connection_lock); } } // plugin_unlock_request // file internal.h line 95 extern void plugin_unlock_request(struct connection *conn) { /* assertion dl */ assert(dl != NULL); if(!(plugin._thread_model >= 3)) { nbdkit_debug("release per-connection request lock"); pthread_mutex_unlock(&conn->request_lock); } if(!(plugin._thread_model >= 2)) { nbdkit_debug("release global request lock"); pthread_mutex_unlock(&all_requests_lock); } } // plugin_usage // file internal.h line 88 extern void plugin_usage(void) { /* assertion dl */ assert(dl != NULL); printf("%s", plugin.name); if(!(plugin.longname == ((const char *)NULL))) printf(" (%s)", plugin.longname); printf("\n"); if(!(plugin.description == ((const char *)NULL))) { printf("\n"); printf("%s\n", plugin.description); } if(!(plugin.config_help == ((const char *)NULL))) { printf("\n"); printf("%s\n", plugin.config_help); } } // plugin_version // file internal.h line 89 extern void plugin_version(void) { /* assertion dl */ assert(dl != NULL); printf("%s", plugin.name); if(!(plugin.version == ((const char *)NULL))) printf(" %s", plugin.version); printf("\n"); } // prologue // file errors.c line 46 static void prologue(const char *type) { const char *name; name=tls_get_name(); unsigned long int instance_num; instance_num=tls_get_instance_num(); fprintf(stderr, "%s: ", program_invocation_short_name); if(!(name == ((const char *)NULL))) { fprintf(stderr, "%s", name); if(instance_num >= 1ul) fprintf(stderr, "[%zu]", instance_num); fprintf(stderr, ": "); } fprintf(stderr, "%s: ", type); } // recv_request_send_reply // file connections.c line 422 static signed int recv_request_send_reply(struct connection *conn) { signed int r; struct request request; struct reply reply; unsigned int magic; unsigned int cmd; unsigned int flags; unsigned int count; unsigned int error = (unsigned int)0; unsigned long int offset; char *buf = (char *)(void *)0; r=xread(conn->sockin, (void *)&request, sizeof(struct request) /*28ul*/ ); if(r == -1) { nbdkit_error("read request: %m"); return -1; } else if(r == 0) { nbdkit_debug("client closed input socket, closing connection"); return 0; } else { magic=__bswap_32(request.magic); if(!(magic == 627086611u)) { nbdkit_error("invalid request: 'magic' field is incorrect (0x%x)", magic); return -1; } else { cmd=__bswap_32(request.type); flags = cmd; cmd = cmd & (unsigned int)0xffff; offset=__bswap_64(request.offset); count=__bswap_32(request.count); if(cmd == 2u) { nbdkit_debug("client sent disconnect command, closing connection"); return 0; } else { r=validate_request(conn, cmd, flags, offset, count, &error); if(r == -1) return -1; else { if(r == 0) { if(cmd == 1u) skip_over_write_buffer(conn->sockin, (unsigned long int)count); } else { if(cmd == 0u || cmd == 1u) { void *return_value_malloc$1; return_value_malloc$1=malloc((unsigned long int)count); buf = (char *)return_value_malloc$1; if(buf == ((char *)NULL)) { perror("malloc"); error = (unsigned int)12; if(cmd == 1u) skip_over_write_buffer(conn->sockin, (unsigned long int)count); goto send_reply; } } if(cmd == 1u) { r=xread(conn->sockin, (void *)buf, (unsigned long int)count); if(r == -1) { nbdkit_error("read data: %m"); return -1; } if(r == 0) { nbdkit_debug("client closed input unexpectedly, closing connection"); return 0; } } r=handle_request(conn, cmd, flags, offset, count, (void *)buf, &error); if(r == -1) return -1; } send_reply: ; reply.magic=__bswap_32((unsigned int)0x67446698); reply.handle = request.handle; reply.error=__bswap_32(error); r=xwrite(conn->sockout, (const void *)&reply, sizeof(struct reply) /*16ul*/ ); if(r == -1) { nbdkit_error("write reply: %m"); return -1; } else if(cmd == 0u) { r=xwrite(conn->sockout, (const void *)buf, (unsigned long int)count); if(!(r == -1)) goto __CPROVER_DUMP_L15; nbdkit_error("write data: %m"); return -1; } else { __CPROVER_DUMP_L15: ; return 1; } } } } } } // run_command // file main.c line 562 static void run_command(void) { char *url; char *cmd; signed int r; signed int pid; if(!(run == ((char *)NULL))) { char *return_value_strstr$1; return_value_strstr$1=strstr(run, "guestfish"); if(!(return_value_strstr$1 == ((char *)NULL))) { if(!(port == ((const char *)NULL))) r=asprintf(&url, "nbd://localhost:%s", port); else if(!(unixsocket == ((char *)NULL))) r=asprintf(&url, "nbd://?socket=%s", unixsocket); else abort(); } else if(!(port == ((const char *)NULL))) r=asprintf(&url, "nbd:localhost:%s", port); else if(!(unixsocket == ((char *)NULL))) r=asprintf(&url, "nbd:unix:%s", unixsocket); else abort(); if(r == -1) { perror("asprintf"); exit(1); } r=asprintf(&cmd, "nbd='%s'\nport='%s'\nunixsocket='%s'\n%s", url, port != ((const char *)NULL) ? port : "", unixsocket != ((char *)NULL) ? unixsocket : "", run); if(r == -1) { perror("asprintf"); exit(1); } free((void *)url); pid=fork(); if(pid == -1) { perror("fork"); exit(1); } if(pid >= 1) { r=system(cmd); /* tag-#anon#lUN[lS32'__in'||S32'__i'|] */ union anonymous$11 { // __in signed int __in; // __i signed int __i; }; /* */ ; if((0x7f & r) == 0) r = (((union anonymous$11){ .__in=r }).__i & 0xff00) >> 8; else if((signed int)((127 & (signed char)r) + 1) >> 1 >= 1) { fprintf(stderr, "%s: external command was killed by signal %d\n", program_invocation_short_name, ((union anonymous$11){ .__in=r }).__i & 0x7f); r = 1; } else if((0xff & r) == 0x7f) { fprintf(stderr, "%s: external command was stopped by signal %d\n", program_invocation_short_name, (((union anonymous$11){ .__in=r }).__i & 0xff00) >> 8); r = 1; } kill(pid, 15); _exit(r); } free((void *)cmd); signed int return_value_getpid$2; return_value_getpid$2=getpid(); nbdkit_debug("forked into background (new pid = %d)", return_value_getpid$2); } } // set_up_signals // file main.c line 449 static void set_up_signals(void) { struct sigaction sa; memset((void *)&sa, 0, sizeof(struct sigaction) /*152ul*/ ); sa.sa_flags = 0x10000000; sa.__sigaction_handler.sa_handler = handle_quit; sigaction(2, &sa, (struct sigaction *)(void *)0); sigaction(3, &sa, (struct sigaction *)(void *)0); sigaction(15, &sa, (struct sigaction *)(void *)0); sigaction(1, &sa, (struct sigaction *)(void *)0); memset((void *)&sa, 0, sizeof(struct sigaction) /*152ul*/ ); sa.sa_flags = 0x10000000; sa.__sigaction_handler.sa_handler = (void (*)(signed int))1; sigaction(13, &sa, (struct sigaction *)(void *)0); } // skip_over_write_buffer // file connections.c line 404 static void skip_over_write_buffer(signed int sock, unsigned long int count) { char buf[8192l]; signed long int r; for( ; count >= 1ul; count = count - (unsigned long int)r) { r=read(sock, (void *)buf, count > (unsigned long int)8192 ? (unsigned long int)8192 : count); if(r == -1l) { nbdkit_error("skipping write buffer: %m"); goto __CPROVER_DUMP_L5; } if(r == 0l) goto __CPROVER_DUMP_L5; } __CPROVER_DUMP_L5: ; } // start_serving // file main.c line 397 static void start_serving(void) { signed int *socks; unsigned long int nr_socks; if(!(port == ((const char *)NULL)) && !(unixsocket == ((char *)NULL)) || !(port == ((const char *)NULL)) && !(listen_stdin == 0) || !(run == ((char *)NULL)) && !(listen_stdin == 0) || !(unixsocket == ((char *)NULL)) && !(listen_stdin == 0)) { fprintf(stderr, "%s: -p, -U and -s options cannot appear at the same time\n", program_invocation_short_name); exit(1); } set_up_signals(); if(!(listen_stdin == 0)) { change_user(); write_pidfile(); tls_new_server_thread(); signed int return_value_handle_single_connection$1; return_value_handle_single_connection$1=handle_single_connection(0, 1); if(return_value_handle_single_connection$1 == -1) exit(1); goto __CPROVER_DUMP_L6; } if(!(unixsocket == ((char *)NULL))) socks=bind_unix_socket(&nr_socks); else socks=bind_tcpip_socket(&nr_socks); run_command(); change_user(); fork_into_background(); write_pidfile(); accept_incoming_connections(socks, nr_socks); free_listening_sockets(socks, nr_socks); __CPROVER_DUMP_L6: ; } // start_thread // file sockets.c line 209 static void * start_thread(void *datav) { struct thread_data *data = (struct thread_data *)datav; nbdkit_debug("accepted connection"); tls_new_server_thread(); tls_set_instance_num(data->instance_num); tls_set_sockaddr(&data->addr, data->addrlen); handle_single_connection(data->sock, data->sock); return (void *)0; } // tls_get_instance_num // file internal.h line 121 extern unsigned long int tls_get_instance_num(void) { struct tls *tls; void *return_value_pthread_getspecific$1; return_value_pthread_getspecific$1=pthread_getspecific(tls_key); tls = (struct tls *)return_value_pthread_getspecific$1; if(tls == ((struct tls *)NULL)) return (unsigned long int)0; else return tls->instance_num; } // tls_get_name // file internal.h line 120 extern const char * tls_get_name(void) { struct tls *tls; void *return_value_pthread_getspecific$1; return_value_pthread_getspecific$1=pthread_getspecific(tls_key); tls = (struct tls *)return_value_pthread_getspecific$1; if(tls == ((struct tls *)NULL)) return (const char *)(void *)0; else return tls->name; } // tls_init // file internal.h line 115 extern void tls_init(void) { signed int err; err=pthread_key_create(&tls_key, free_tls); if(!(err == 0)) { char *return_value_strerror$1; return_value_strerror$1=strerror(err); fprintf(stderr, "%s: pthread_key_create: %s\n", program_invocation_short_name, return_value_strerror$1); exit(1); } } // tls_new_server_thread // file internal.h line 116 extern void tls_new_server_thread(void) { struct tls *tls; void *return_value_calloc$1; return_value_calloc$1=calloc((unsigned long int)1, sizeof(struct tls) /*32ul*/ ); tls = (struct tls *)return_value_calloc$1; if(tls == ((struct tls *)NULL)) { perror("malloc"); exit(1); } pthread_setspecific(tls_key, (const void *)tls); } // tls_set_instance_num // file internal.h line 118 extern void tls_set_instance_num(unsigned long int instance_num) { struct tls *tls; void *return_value_pthread_getspecific$1; return_value_pthread_getspecific$1=pthread_getspecific(tls_key); tls = (struct tls *)return_value_pthread_getspecific$1; if(!(tls == ((struct tls *)NULL))) tls->instance_num = instance_num; } // tls_set_name // file internal.h line 117 extern void tls_set_name(const char *name) { struct tls *tls; void *return_value_pthread_getspecific$1; return_value_pthread_getspecific$1=pthread_getspecific(tls_key); tls = (struct tls *)return_value_pthread_getspecific$1; if(!(tls == ((struct tls *)NULL))) tls->name = name; } // tls_set_sockaddr // file internal.h line 119 extern void tls_set_sockaddr(struct sockaddr *addr, unsigned int addrlen) { struct tls *tls; void *return_value_pthread_getspecific$1; return_value_pthread_getspecific$1=pthread_getspecific(tls_key); tls = (struct tls *)return_value_pthread_getspecific$1; if(!(tls == ((struct tls *)NULL))) { free((void *)tls->addr); void *return_value_calloc$2; return_value_calloc$2=calloc((unsigned long int)1, (unsigned long int)addrlen); tls->addr = (struct sockaddr *)return_value_calloc$2; if(tls->addr == ((struct sockaddr *)NULL)) { perror("calloc"); exit(1); } memcpy((void *)tls->addr, (const void *)addr, (unsigned long int)addrlen); } } // usage // file main.c line 111 static void usage(void) { printf("nbdkit [--dump-config] [-f] [-g GROUP] [-i IPADDR]\n [-P PIDFILE] [-p PORT] [-r] [--run CMD] [-s]\n [-U SOCKET] [-u USER] [-v] [-V]\n PLUGIN [key=value [key=value [...]]]\n\nPlease read the nbdkit(1) manual page for full usage.\n"); } // valid_range // file connections.c line 234 static signed int valid_range(struct connection *conn, unsigned long int offset, unsigned int count) { unsigned long int exportsize = conn->exportsize; return (signed int)(count > (unsigned int)0 && offset <= exportsize && offset + (unsigned long int)count <= exportsize); } // validate_request // file connections.c line 242 static signed int validate_request(struct connection *conn, unsigned int cmd, unsigned int flags, unsigned long int offset, unsigned int count, unsigned int *error) { signed int r; switch(cmd) { case (unsigned int)0: case (unsigned int)1: case (unsigned int)4: { r=valid_range(conn, offset, count); if(r == -1) return -1; if(r == 0) { nbdkit_error("invalid request: offset and length are out of range"); *error = (unsigned int)5; return 0; } break; } case (unsigned int)3: { if(!(count == 0u) || !(offset == 0ul)) { nbdkit_error("invalid flush request: expecting offset and length == 0"); *error = (unsigned int)22; return 0; } break; } default: { nbdkit_error("invalid request: unknown command (%u) ignored", cmd); *error = (unsigned int)22; return 0; } } if(count >= 67108865u && (cmd == 0u || cmd == 1u)) { nbdkit_error("invalid request: data request is too large (%u > %d)", count, 64 * 1024 * 1024); *error = (unsigned int)12; return 0; } else if(!(conn->readonly == 0)) { if(!(cmd == 1u) && !(cmd == 3u) && !(cmd == 4u)) goto __CPROVER_DUMP_L9; nbdkit_error("invalid request: write request on readonly connection"); *error = (unsigned int)30; return 0; } else { __CPROVER_DUMP_L9: ; if(conn->can_flush == 0) { if(!(cmd == 3u)) goto __CPROVER_DUMP_L10; nbdkit_error("invalid request: flush operation not supported"); *error = (unsigned int)22; return 0; } else { __CPROVER_DUMP_L10: ; if(conn->can_trim == 0) { if(!(cmd == 4u)) goto __CPROVER_DUMP_L11; nbdkit_error("invalid request: trim operation not supported"); *error = (unsigned int)22; return 0; } else { __CPROVER_DUMP_L11: ; return 1; } } } } // write_pidfile // file main.c line 500 static void write_pidfile(void) { signed int fd; signed int pid; char pidstr[64l]; unsigned long int len; _Bool tmp_if_expr$3; signed int return_value_close$2; if(!(pidfile == ((char *)NULL))) { pid=getpid(); snprintf(pidstr, sizeof(char [64l]) /*64ul*/ , "%d\n", pid); len=strlen(pidstr); fd=open(pidfile, 01 | 01000 | 0100 | 02000000 | 0400, 0644); if(fd == -1) { perror(pidfile); exit(1); } signed long int return_value_write$1; return_value_write$1=write(fd, (const void *)pidstr, len); if(!((unsigned long int)return_value_write$1 >= len)) tmp_if_expr$3 = (_Bool)1; else { return_value_close$2=close(fd); tmp_if_expr$3 = return_value_close$2 == -1 ? (_Bool)1 : (_Bool)0; } if(tmp_if_expr$3) { perror(pidfile); exit(1); } nbdkit_debug("written pidfile %s", pidfile); } } // xread // file internal.h line 125 extern signed int xread(signed int sock, void *vbuf, unsigned long int len) { char *buf = (char *)vbuf; signed long int r; _Bool first_read = (_Bool)1; _Bool tmp_if_expr$3; signed int *return_value___errno_location$2; while(len >= 1ul) { r=read(sock, (void *)buf, len); if(r == -1l) { signed int *return_value___errno_location$1; return_value___errno_location$1=__errno_location(); if(*return_value___errno_location$1 == 4) tmp_if_expr$3 = (_Bool)1; else { return_value___errno_location$2=__errno_location(); tmp_if_expr$3 = *return_value___errno_location$2 == 11 ? (_Bool)1 : (_Bool)0; } if(tmp_if_expr$3) continue; return -1; } if(r == 0l) { if(!(first_read == (_Bool)0)) return 0; signed int *return_value___errno_location$4; return_value___errno_location$4=__errno_location(); *return_value___errno_location$4 = 74; return -1; } first_read = (_Bool)0; buf = buf + r; len = len - (unsigned long int)r; } return 1; } // xwrite // file internal.h line 126 extern signed int xwrite(signed int sock, const void *vbuf, unsigned long int len) { const char *buf = (const char *)vbuf; signed long int r; _Bool tmp_if_expr$3; signed int *return_value___errno_location$2; while(len >= 1ul) { r=write(sock, (const void *)buf, len); if(r == -1l) { signed int *return_value___errno_location$1; return_value___errno_location$1=__errno_location(); if(*return_value___errno_location$1 == 4) tmp_if_expr$3 = (_Bool)1; else { return_value___errno_location$2=__errno_location(); tmp_if_expr$3 = *return_value___errno_location$2 == 11 ? (_Bool)1 : (_Bool)0; } if(tmp_if_expr$3) continue; return -1; } buf = buf + r; len = len - (unsigned long int)r; } return 0; }
the_stack_data/20337.c
#include<stdio.h> #include<stdlib.h> #include<string.h> int n,top=-1,m,rqc=0,buffc=0,q,pct=0,z; int clk=-1,b=0; int arr[20][10],buffer[2][1000]; int rq[2][1000],ioex[1000],allex[1000], flag[1000], buffx[1000]; typedef struct proc { int no; int burst; }p; int getdata() { int i,j; for(i=1;i<=n;i++) for(j=1;j<=10;j++) arr[i][j]=0; for(i=1;i<=n;i++) arr[i][0]=i; printf("\nEnter the Arrival Times:\n"); for(i=1;i<=n;i++) scanf("%d",&arr[i][1]); printf("Enter the 1st CPU Burst Times:\n"); for(i=1;i<=n;i++) scanf("%d",&arr[i][2]); printf("Enter the I/O Burst Times:\n"); for(i=1;i<=n;i++) scanf("%d",&arr[i][3]); printf("Enter the 2nd CPU Burst Times:\n"); for(i=1;i<=n;i++) scanf("%d",&arr[i][4]); } void sortrq() { int i,j; for(i=0;i<top-1;i++) { for(j=1;j<=top-i-1;j++) { if(arr[rq[0][j]][8]>arr[rq[0][j+1]][8]) { rq[0][j]^=rq[0][j+1]^=rq[0][j]^=rq[0][j+1]; rq[1][j]^=rq[1][j+1]^=rq[1][j]^=rq[1][j+1]; } } } } void push(int x,int y) { int i=0,j; if(rq[0][1]==-1) { rq[0][1]=x; rq[1][1]=y; top=1; } else { top++; for(j=rqc;j>=1;j--) { rq[0][j+1]=rq[0][j]; //for name in 0th row rq[1][j+1]=rq[1][j]; //for burst in 1st row } rq[0][1]=x; rq[1][1]=y; } rqc++; if(top>1) sortrq(); } int pop() { int i=0,x; if(top>0) { x=rq[0][top]; z=rq[1][top]; top--; } else if(top<=0); return x; } void pushbuff(int x) { int i=0,j; buffc++; buffx[buffc]=x; if(x==buffer[0][b]); if(b<=0) { buffer[0][1]=x; buffer[1][1]=arr[x][3]; b=1; } else if(b>0) { b++; for(j=b;j>=1;j--) { buffer[0][j+1]=buffer[0][j]; buffer[1][j+1]=buffer[1][j]; } buffer[0][1]=x; buffer[1][1]=arr[x][3]; } for(i=1;i<=n-1 && b>1;i++) { for(j=1;j<=n-i-1;j++) { if(buffer[1][j]<buffer[1][j+1]) { buffer[0][j]^=buffer[0][j+1]^=buffer[0][j]^=buffer[0][j+1]; buffer[1][j]^=buffer[1][j+1]^=buffer[1][j]^=buffer[1][j+1]; } } } } int popbuff() { int x; if(b>0) { x=buffer[0][b]; b--; } else; return x; } int max() { int i,m=0; for(i=1;i<=n;i++) m+=arr[i][2]+arr[i][3]+arr[i][4]; return m; } void avg() { float a=0,b=0; int i; for(i=1;i<=n;i++) { a+=arr[i][5]; b+=arr[i][6]; } a=a/n; b=b/n; printf("Avg. WT = %.2f\nAvg. TAT = %.2f\n",a,b); } void flagging() { int i,j; for(i=1;i<100;i++) flag[i]=0; for(i=1;i<=n;i++) for(j=2;j<=4;j++) if(arr[i][j]>0) flag[i]+=1; } void display() { int i,j; printf("\n"); for(i=0;i<=80;i++) printf("-"); printf("\nThe output is:\n"); printf("Process\tAT\tBT-1\tI/OT\tBT-2\tPrt\tWT\tTAT\tCT\n"); for(i=1;i<=n;i++) { printf("P-%d\t",arr[i][0]); for(j=1;j<=4;j++) printf("%d\t", arr[i][j]); printf("%d\t",arr[i][8]); for(j=5;j<=7;j++) printf("%d\t", arr[i][j]); printf("\n"); } printf("\n"); for(i=0;i<=80;i++) printf("-"); printf("\n\nThe ready queue is:\n"); for(i=rqc;i>=1;i--) if(rq[0][i]!=0 && rq[0][i]!=-1) printf("P-%d:%d ",rq[0][i],rq[1][i]); printf("\n\nThe execution array is:\n"); for(i=0;i<=1000;i++) { if(allex[i]>0 && allex[i]!=allex[i-1]) printf("%d P-%d ",i, allex[i]); else if(allex[i]==-4 && allex[i]!=allex[i-1]) printf("%d -- ",i); } printf("\n\nThe buffer is:\n"); for(i=1;i<=buffc;i++) if(buffx[i]!=-1) printf("P-%d ", buffx[i]); printf("\n"); avg(); } int check() { int i; for(i=0;i<=n;i++) if(flag[i]>0) return 1; return 0; } void pr_pre() { int i,j,t,f,pc=0; p pro;j=4; printf("\nEnter the priorities of each process: \n"); for(i=1;i<=n;i++) scanf("%d",&arr[i][8]); m=max(); for(i=1;i<=m;i++) { rq[0][i]=-1; rq[1][i]=-1; buffer[0][i]=-1; buffer[1][i]=-1; buffx[i]=-1; } flagging(); clk=0; push(arr[1][0],arr[1][2]); clk=arr[rq[0][top]][1]; for(j=2;j<=n;j++) if(arr[j][1]==clk) push(arr[j][0],arr[j][2]); pc++; if(top>0) { pro.no=pop(); flag[pro.no]--; pro.burst=z; allex[clk]=pro.no; } clk++; while(clk<=m+1) { for(j=2;j<=n;j++) if(arr[j][1]==clk) push(arr[j][0],arr[j][2]); if(top>0) for(i=1;i<=top;i++) arr[rq[0][i]][5]++; if(pro.burst>1) { pro.burst--; allex[clk]=pro.no; push(pro.no,pro.burst); flag[pro.no]++; pro.burst=0; } if(pro.burst==1) { pro.burst--; allex[clk]=pro.no; pro.burst=0; } if(b>0) { for(i=b;i>=1;i--) { if(buffer[1][i]>0) buffer[1][i]--; if(buffer[1][i]==0) { f=popbuff(); push(f,arr[f][4]); } } } if(pro.burst==0) { int x=check(); if(top>0) { if(flag[pro.no]==2) { flag[pro.no]--; pushbuff(pro.no); } if(flag[pro.no]==0) { arr[pro.no][7]=clk; allex[clk]=pro.no; } if(flag[rq[0][top]]==3) { pro.no=pop(); flag[pro.no]--; pro.burst=z; allex[clk]=pro.no; } else if(flag[rq[0][top]]==1) { pro.no=pop(); pro.burst=z; flag[pro.no]--; allex[clk]=pro.no; } if(x==0) break; } else if(top<=0) { if(flag[pro.no]==2) { flag[pro.no]--; pushbuff(pro.no); allex[clk]=pro.no; } else if(flag[pro.no]==0) { arr[pro.no][7]=clk; allex[clk]=pro.no; } else if(flag[pro.no]==1) { flag[pro.no]--; allex[clk]=pro.no; } pro.no=0; pro.burst=0; allex[clk]=-4; if(x==0) break; } } if(flag[rq[1]==0]) break; clk++; } for(i=1;i<=n;i++) arr[i][6]=arr[i][7]-arr[i][1]; display(); } int main() { int i; printf("\n"); for(i=0;i<=80;i++) printf("-"); printf("\nEnter the number of processes: "); scanf("%d",&n); getdata(); pr_pre(); printf("\n"); for(i=0;i<=40;i++) printf("-x"); printf("\n"); char key = getch(); if(key=='T' || key=='t') exit(0); return 0; }
the_stack_data/747832.c
#include <stdio.h> #include <pthread.h> #include <semaphore.h> #include <unistd.h> #include <stdbool.h> /* In this system there are two kinds of threads - red threads and black threads. All of the threads need to enter a critical section. Only one thread may be in the critical section at once but there is an additional rule - the two types of threads should alternate if possible. That is if red finishes and there a black waiting, then a black should go (and vice versa). However, if no black is available red may invoke another red. HINT: you'll want a variable to track if something is in the critical section and a count of reds and blacks waiting. HINT 2: this one has some edge cases! Be careful! Example output: red thread 0 entering critical section red starts waiting red starts waiting red starts waiting red starts waiting red thread 0 leaving critical section red thread 1 entering critical section black starts waiting black starts waiting black starts waiting black starts waiting black starts waiting red thread 1 leaving critical section black thread 0 entering critical section black thread 0 leaving critical section red thread 2 entering critical section red thread 2 leaving critical section black thread 1 entering critical section black thread 1 leaving critical section red thread 3 entering critical section red thread 3 leaving critical section black thread 2 entering critical section black thread 2 leaving critical section red thread 4 entering critical section red thread 4 leaving critical section black thread 3 entering critical section black thread 3 leaving critical section black thread 4 entering critical section black thread 4 leaving critical section */ sem_t mutex, red_queue, black_queue; bool in_critical_section = false; int red_queue_waiting = 0; int black_queue_waiting = 0; #define NUM_THREADS 5 void* red_thread(void *num_p) { int num = *((int*) num_p); sem_wait(&mutex); if(in_critical_section) { red_queue_waiting++; printf("red starts waiting\n"); sem_post(&mutex); sem_wait(&red_queue); } else { in_critical_section = true; sem_post(&mutex); } printf("red thread %d entering critical section\n", num); sleep(1); printf("red thread %d leaving critical section\n", num); sem_wait(&mutex); if(black_queue_waiting > 0) { black_queue_waiting--; sem_post(&black_queue); sem_post(&mutex); return NULL; } if(red_queue_waiting > 0) { red_queue_waiting--; sem_post(&red_queue); sem_post(&mutex); return NULL; } in_critical_section = false; sem_post(&mutex); return NULL; } void* black_thread(void *num_p) { int num = *((int*) num_p); sem_wait(&mutex); if(in_critical_section) { black_queue_waiting++; printf("black starts waiting\n"); sem_post(&mutex); sem_wait(&black_queue); } else { in_critical_section = true; sem_post(&mutex); } printf("black thread %d entering critical section\n", num); sleep(1); printf("black thread %d leaving critical section\n", num); sem_wait(&mutex); if(red_queue_waiting > 0) { red_queue_waiting--; sem_post(&red_queue); sem_post(&mutex); return NULL; } if(black_queue_waiting > 0) { black_queue_waiting--; sem_post(&black_queue); sem_post(&mutex); return NULL; } in_critical_section = false; sem_post(&mutex); return NULL; } int main(int argc, char **argv) { int nums[NUM_THREADS]; pthread_t reds[NUM_THREADS]; pthread_t blacks[NUM_THREADS]; sem_init(&mutex, 0, 1); sem_init(&red_queue, 0, 0); sem_init(&black_queue, 0, 0); for(int i = 0; i < NUM_THREADS; i++) { nums[i] = i; pthread_create(&reds[i], NULL, red_thread, &nums[i]); } sleep(2); //wait a while before we start the blacks for(int i = 0; i < NUM_THREADS; i++) { pthread_create(&blacks[i], NULL, black_thread, &nums[i]); } for(int i = 0; i < NUM_THREADS; i++) { nums[i] = i; pthread_join(reds[i], NULL); pthread_join(blacks[i], NULL); } printf("done"); return 0; }
the_stack_data/234518551.c
#include <stdio.h> #include <stdlib.h> struct node { int value; struct node *next; struct node *prev; }; struct list { struct node *head; struct node *tail; }; void init(struct list* l) { l->head=NULL; l->tail=NULL; } void clear(struct list* l) { struct node* tmp1; struct node* tmp2; tmp1=l->head; while (tmp1->next!=NULL) { tmp2=tmp1; tmp1=tmp1->next; free(tmp2); } free(tmp1); init(l); } int isEmpty(struct list* l) { if (l->head==NULL) return 0; else return 1; } struct node* find(struct list* l, int val) { struct node* tmp; tmp=l->head; while (tmp->next!=NULL) { if (tmp->value==val) return tmp; tmp=tmp->next; } return NULL; } struct node* findk(struct list* l, int n) { int i=1; struct node* tmp; tmp=l->head; for(i=1; i<n; i++) tmp=tmp->next; return tmp; } int push_back(struct list* l, int val) { struct node* new_node; new_node=(struct node*)malloc(sizeof(struct node)); new_node->value = val; new_node->next = NULL; if (l->head==NULL) { new_node->prev = NULL; l->head=new_node; } else if (l->head->next==NULL) { new_node->prev = l->head; l->head->next = new_node; } else { new_node->prev = l->tail; l->tail->next = new_node; } l->tail=new_node; return 0; } int push_front(struct list* l, int val) { struct node* new_node; new_node=(struct node*)malloc(sizeof(struct node)); new_node->value = val; new_node->prev = NULL; if (l->head==NULL) { new_node->next = NULL; l->tail=new_node; } else if (l->head->next==NULL) { new_node->next = l->tail; l->tail->prev = new_node; } else { new_node->next = l->head; l->head->prev = new_node; } l->head=new_node; return 0; } int insertAfter(struct node* n, int val) { struct node* new_node; new_node=(struct node*)malloc(sizeof(struct node)); new_node->value = val; new_node->next = n->next; new_node->prev = n; n->next->prev = new_node; n->next = new_node; return 0; } int insertBefore(struct node* n, int val) { struct node* new_node; new_node=(struct node*)malloc(sizeof(struct node)); new_node->value = val; new_node->prev = n->prev; new_node->next = n; n->prev->next = new_node; n->prev = new_node; return 0; } int removeFirst(struct list* l, int val) { struct node* tmp; tmp=l->head; while(tmp->value!=val) tmp=tmp->next; if (tmp==l->head) { tmp->next->prev = NULL; l->head = tmp->next; } else if (tmp==l->tail) { tmp->prev->next = NULL; l->tail = tmp->prev; } else { tmp->prev->next = tmp->next; tmp->next->prev = tmp->prev; } free(tmp); return 0; } int removeLast(struct list* l, int val) { struct node* tmp; tmp=l->tail; while(tmp->value!=val) tmp=tmp->prev; if (tmp==l->head) { tmp->next->prev = NULL; l->head = tmp->next; } else if (tmp==l->tail) { tmp->prev->next = NULL; l->tail = tmp->prev; } else { tmp->prev->next = tmp->next; tmp->next->prev = tmp->prev; } free(tmp); return 0; } void print(struct list* l) { if (isEmpty(l)==1) { struct node* tmp; tmp=l->head; while (tmp->next!=NULL) { printf("%d ", tmp->value); tmp = tmp->next; } printf("%d\n", l->tail->value); } } void print_invers(struct list* l) { if (isEmpty(l)==1) { struct node* tmp; tmp=l->tail; while (tmp->prev!=NULL) { printf("%d ", tmp->value); tmp = tmp->prev; } printf("%d\n", l->head->value); } } int main() { int n, x, i, k1, k2, k3; struct list a; struct node* b; init(&a); scanf("%d", &n); for (i=1; i<=n; i=i+1) { scanf("%d", &x); push_back(&a, x); } print(&a); scanf("%d %d %d", &k1, &k2, &k3); b=find(&a, k1); if (b!=NULL) k1=1; else k1=0; b=find(&a, k2); if (b!=NULL) k2=1; else k2=0; b=find(&a, k3); if (b!=NULL) k3=1; else k3=0; printf("%d%d%d\n", k1, k2, k3); scanf("%d", &x); push_back(&a, x); print_invers(&a); scanf("%d", &x); push_front(&a, x); print(&a); scanf("%d %d", &n, &x); b=findk(&a, n); insertAfter(b, x); print_invers(&a); scanf("%d %d", &n, &x); b=findk(&a, n); insertBefore(b, x); print(&a); scanf("%d", &x); removeFirst(&a, x); print_invers(&a); scanf("%d", &x); removeLast(&a, x); print(&a); clear(&a); return 0; }
the_stack_data/182951683.c
/* @(#)l3.c 1.3 */ /*LINTLIBRARY*/ /* * Convert longs to and from 3-byte disk addresses */ void ltol3(cp, lp, n) char *cp; long *lp; int n; { register i; register char *a, *b; a = cp; b = (char *)lp; for(i=0; i < n; ++i) { #if besm *a++ = *b++; *a++ = *b++; *a++ = *b++; b += 3; #endif #if interdata || u370 || u3b || u3b5 b++; *a++ = *b++; *a++ = *b++; *a++ = *b++; #endif #if vax *a++ = *b++; *a++ = *b++; *a++ = *b++; b++; #endif #if pdp11 *a++ = *b++; b++; *a++ = *b++; *a++ = *b++; #endif } } void l3tol(lp, cp, n) long *lp; char *cp; int n; { register i; register char *a, *b; a = (char *)lp; b = cp; for(i=0; i < n; ++i) { #if besm *a++ = *b++; *a++ = *b++; *a++ = *b++; *a++ = 0; *a++ = 0; *a++ = 0; #endif #if interdata || u370 || u3b || u3b5 *a++ = 0; *a++ = *b++; *a++ = *b++; *a++ = *b++; #endif #if vax *a++ = *b++; *a++ = *b++; *a++ = *b++; *a++ = 0; #endif #if pdp11 *a++ = *b++; *a++ = 0; *a++ = *b++; *a++ = *b++; #endif } }
the_stack_data/1010826.c
typedef unsigned int size_t; void *malloc(size_t size); enum blockstate { S1, S2 }; typedef struct { enum blockstate bs; int id; int version; } block; typedef struct blocknode { block* b; struct blocknode* next; } blocknode; typedef blocknode *bl; int main () { block *bp = (block*)(malloc(sizeof(block))); bl l = (bl)(malloc(sizeof(blocknode))); bp->version = 1; l->b = bp; l->b->version = l->b->version+1; // this should fail assert ((l->b->version) == 1); }
the_stack_data/48975.c
// Exercício 08 - Inicialize um vetor de 10 posições e em seguida leia um valor X qualquer. // Seu programa devera fazer uma busca do valor de X no vetor lido e informar a posição em que // foi encontrado ou se não foi encontrado. # include <stdio.h> int linha(void) { char x = '-'; printf("\n\033[33m"); for (int count = 0; count < 30; count ++) { printf("%c", x); } printf("\033[m\n\n"); return 0; } int main(void) { int qtd = 0; linha(); printf("\033[32m## BUSCANDO NO VETOR.\033[m\n"); linha(); printf("Quantidade de números a serem digitados: "); scanf("%i", &qtd); int vetor[qtd]; linha(); for (int count = 0; count < qtd; count ++) { printf("Digite %i números [%i/%i]: ",qtd, count + 1, qtd); scanf("%i", &vetor[count]); } linha(); int busca = 0, count_busca = 0, lugar_busca[qtd]; printf("Número a ser buscado: "); scanf("%i", &busca); for (int count = 0; count < qtd; count ++) { if (vetor[count] == busca) { lugar_busca[count_busca] = count; count_busca ++; } } linha(); printf("Quantidade de número %i encontrados: %i\n", busca, count_busca); if (count_busca != 0) { printf((count_busca > 1) ? "Sendo encontrados nas posições " : "Sendo encontrado na posição "); for (int count = 0; count < count_busca; count ++) { printf("(%i) ", lugar_busca[count]); } printf("do vetor.\n"); } linha(); return 0; }
the_stack_data/7950442.c
#include <stdio.h> void scilab_rt_champ1_d2d2d2d2d0d2s0_(int in00, int in01, double matrixin0[in00][in01], int in10, int in11, double matrixin1[in10][in11], int in20, int in21, double matrixin2[in20][in21], int in30, int in31, double matrixin3[in30][in31], double scalarin0, int in40, int in41, double matrixin4[in40][in41], char* scalarin1) { int i; int j; double val0 = 0; double val1 = 0; double val2 = 0; double val3 = 0; double val4 = 0; for (i = 0; i < in00; ++i) { for (j = 0; j < in01; ++j) { val0 += matrixin0[i][j]; } } printf("%f", val0); for (i = 0; i < in10; ++i) { for (j = 0; j < in11; ++j) { val1 += matrixin1[i][j]; } } printf("%f", val1); for (i = 0; i < in20; ++i) { for (j = 0; j < in21; ++j) { val2 += matrixin2[i][j]; } } printf("%f", val2); for (i = 0; i < in30; ++i) { for (j = 0; j < in31; ++j) { val3 += matrixin3[i][j]; } } printf("%f", val3); printf("%f", scalarin0); for (i = 0; i < in40; ++i) { for (j = 0; j < in41; ++j) { val4 += matrixin4[i][j]; } } printf("%f", val4); printf("%s", scalarin1); }
the_stack_data/151705370.c
#include <unistd.h> #ifdef TEST_CMOV #define TEST_COND(N) \ int test_##N (long a) \ { \ int res = 1; \ \ asm ("cmov"#N" %1,$31,%0" \ : "+r" (res) : "r" (a)); \ return !res; \ } #else #define TEST_COND(N) \ int test_##N (long a) \ { \ int res = 1; \ \ asm ("b"#N" %1,1f\n\t" \ "addq $31,$31,%0\n\t" \ "1: unop\n" \ : "+r" (res) : "r" (a)); \ return res; \ } #endif TEST_COND(eq) TEST_COND(ne) TEST_COND(ge) TEST_COND(gt) TEST_COND(lbc) TEST_COND(lbs) TEST_COND(le) TEST_COND(lt) static struct { int (*func)(long); long v; int r; } vectors[] = { {test_eq, 0, 1}, {test_eq, 1, 0}, {test_ne, 0, 0}, {test_ne, 1, 1}, {test_ge, 0, 1}, {test_ge, 1, 1}, {test_ge, -1, 0}, {test_gt, 0, 0}, {test_gt, 1, 1}, {test_gt, -1, 0}, {test_lbc, 0, 1}, {test_lbc, 1, 0}, {test_lbc, -1, 0}, {test_lbs, 0, 0}, {test_lbs, 1, 1}, {test_lbs, -1, 1}, {test_le, 0, 1}, {test_le, 1, 0}, {test_le, -1, 1}, {test_lt, 0, 0}, {test_lt, 1, 0}, {test_lt, -1, 1}, }; int main (void) { int i; for (i = 0; i < sizeof (vectors)/sizeof(vectors[0]); i++) if ((*vectors[i].func)(vectors[i].v) != vectors[i].r) { write(1, "Failed\n", 7); return 1; } write(1, "OK\n", 3); return 0; }
the_stack_data/396356.c
#include <stdio.h> int main(void){ double height; printf("请输入你的身高(英寸):"); scanf("%lf",&height); printf("你的身高为:%.2f厘米\n",height * 2.54); return 0; }
the_stack_data/1148793.c
/* File: startup_ARMSC300.c * Purpose: startup file for Cortex-M3 Secure Core devices. * Should be used with GCC 'GNU Tools ARM Embedded' * Version: V1.01 * Date: 12 June 2014 * */ /* Copyright (c) 2011 - 2014 ARM LIMITED 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 ARM 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 COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------*/ #include <stdint.h> /*---------------------------------------------------------------------------- Linker generated Symbols *----------------------------------------------------------------------------*/ extern uint32_t __etext; extern uint32_t __data_start__; extern uint32_t __data_end__; extern uint32_t __copy_table_start__; extern uint32_t __copy_table_end__; extern uint32_t __zero_table_start__; extern uint32_t __zero_table_end__; extern uint32_t __bss_start__; extern uint32_t __bss_end__; extern uint32_t __StackTop; /*---------------------------------------------------------------------------- Exception / Interrupt Handler Function Prototype *----------------------------------------------------------------------------*/ typedef void( *pFunc )( void ); /*---------------------------------------------------------------------------- External References *----------------------------------------------------------------------------*/ #ifndef __START extern void _start(void) __attribute__((noreturn)); /* PreeMain (C library entry point) */ #else extern int __START(void) __attribute__((noreturn)); /* main entry point */ #endif #ifndef __NO_SYSTEM_INIT extern void SystemInit (void); /* CMSIS System Initialization */ #endif /*---------------------------------------------------------------------------- Internal References *----------------------------------------------------------------------------*/ void Default_Handler(void); /* Default empty handler */ void Reset_Handler(void); /* Reset Handler */ /*---------------------------------------------------------------------------- User Initial Stack & Heap *----------------------------------------------------------------------------*/ #ifndef __STACK_SIZE #define __STACK_SIZE 0x00000400 #endif static uint8_t stack[__STACK_SIZE] __attribute__ ((aligned(8), used, section(".stack"))); #ifndef __HEAP_SIZE #define __HEAP_SIZE 0x00000C00 #endif #if __HEAP_SIZE > 0 static uint8_t heap[__HEAP_SIZE] __attribute__ ((aligned(8), used, section(".heap"))); #endif /*---------------------------------------------------------------------------- Exception / Interrupt Handler *----------------------------------------------------------------------------*/ /* Cortex-M3 Processor Exceptions */ void NMI_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void HardFault_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void MemManage_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void BusFault_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void UsageFault_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void SVC_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void DebugMon_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void PendSV_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void SysTick_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); /* ARMSC300 Specific Interrupts */ void WDT_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); void RTC_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); void TIM0_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); void TIM2_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); void MCIA_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); void MCIB_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); void UART0_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); void UART1_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); void UART2_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); void UART4_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); void AACI_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); void CLCD_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); void ENET_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); void USBDC_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); void USBHC_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); void CHLCD_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); void FLEXRAY_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); void CAN_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); void LIN_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); void I2C_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); void CPU_CLCD_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); void UART3_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); void SPI_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); /*---------------------------------------------------------------------------- Exception / Interrupt Vector table *----------------------------------------------------------------------------*/ const pFunc __Vectors[] __attribute__ ((section(".vectors"))) = { /* Cortex-M3 Exceptions Handler */ (pFunc)&__StackTop, /* Initial Stack Pointer */ Reset_Handler, /* Reset Handler */ NMI_Handler, /* NMI Handler */ HardFault_Handler, /* Hard Fault Handler */ MemManage_Handler, /* MPU Fault Handler */ BusFault_Handler, /* Bus Fault Handler */ UsageFault_Handler, /* Usage Fault Handler */ 0, /* Reserved */ 0, /* Reserved */ 0, /* Reserved */ 0, /* Reserved */ SVC_Handler, /* SVCall Handler */ DebugMon_Handler, /* Debug Monitor Handler */ 0, /* Reserved */ PendSV_Handler, /* PendSV Handler */ SysTick_Handler, /* SysTick Handler */ /* External interrupts */ WDT_IRQHandler, /* 0: Watchdog Timer */ RTC_IRQHandler, /* 1: Real Time Clock */ TIM0_IRQHandler, /* 2: Timer0 / Timer1 */ TIM2_IRQHandler, /* 3: Timer2 / Timer3 */ MCIA_IRQHandler, /* 4: MCIa */ MCIB_IRQHandler, /* 5: MCIb */ UART0_IRQHandler, /* 6: UART0 - DUT FPGA */ UART1_IRQHandler, /* 7: UART1 - DUT FPGA */ UART2_IRQHandler, /* 8: UART2 - DUT FPGA */ UART4_IRQHandler, /* 9: UART4 - not connected */ AACI_IRQHandler, /* 10: AACI / AC97 */ CLCD_IRQHandler, /* 11: CLCD Combined Interrupt */ ENET_IRQHandler, /* 12: Ethernet */ USBDC_IRQHandler, /* 13: USB Device */ USBHC_IRQHandler, /* 14: USB Host Controller */ CHLCD_IRQHandler, /* 15: Character LCD */ FLEXRAY_IRQHandler, /* 16: Flexray */ CAN_IRQHandler, /* 17: CAN */ LIN_IRQHandler, /* 18: LIN */ I2C_IRQHandler, /* 19: I2C ADC/DAC */ 0, /* 20: Reserved */ 0, /* 21: Reserved */ 0, /* 22: Reserved */ 0, /* 23: Reserved */ 0, /* 24: Reserved */ 0, /* 25: Reserved */ 0, /* 26: Reserved */ 0, /* 27: Reserved */ CPU_CLCD_IRQHandler, /* 28: Reserved - CPU FPGA CLCD */ 0, /* 29: Reserved - CPU FPGA */ UART3_IRQHandler, /* 30: UART3 - CPU FPGA */ SPI_IRQHandler /* 31: SPI Touchscreen - CPU FPGA */ }; /*---------------------------------------------------------------------------- Reset Handler called on controller reset *----------------------------------------------------------------------------*/ void Reset_Handler(void) { uint32_t *pSrc, *pDest; uint32_t *pTable __attribute__((unused)); /* Firstly it copies data from read only memory to RAM. There are two schemes * to copy. One can copy more than one sections. Another can only copy * one section. The former scheme needs more instructions and read-only * data to implement than the latter. * Macro __STARTUP_COPY_MULTIPLE is used to choose between two schemes. */ #ifdef __STARTUP_COPY_MULTIPLE /* Multiple sections scheme. * * Between symbol address __copy_table_start__ and __copy_table_end__, * there are array of triplets, each of which specify: * offset 0: LMA of start of a section to copy from * offset 4: VMA of start of a section to copy to * offset 8: size of the section to copy. Must be multiply of 4 * * All addresses must be aligned to 4 bytes boundary. */ pTable = &__copy_table_start__; for (; pTable < &__copy_table_end__; pTable = pTable + 3) { pSrc = (uint32_t*)*(pTable + 0); pDest = (uint32_t*)*(pTable + 1); for (; pDest < (uint32_t*)(*(pTable + 1) + *(pTable + 2)) ; ) { *pDest++ = *pSrc++; } } #else /* Single section scheme. * * The ranges of copy from/to are specified by following symbols * __etext: LMA of start of the section to copy from. Usually end of text * __data_start__: VMA of start of the section to copy to * __data_end__: VMA of end of the section to copy to * * All addresses must be aligned to 4 bytes boundary. */ pSrc = &__etext; pDest = &__data_start__; for ( ; pDest < &__data_end__ ; ) { *pDest++ = *pSrc++; } #endif /*__STARTUP_COPY_MULTIPLE */ /* This part of work usually is done in C library startup code. Otherwise, * define this macro to enable it in this startup. * * There are two schemes too. One can clear multiple BSS sections. Another * can only clear one section. The former is more size expensive than the * latter. * * Define macro __STARTUP_CLEAR_BSS_MULTIPLE to choose the former. * Otherwise efine macro __STARTUP_CLEAR_BSS to choose the later. */ #ifdef __STARTUP_CLEAR_BSS_MULTIPLE /* Multiple sections scheme. * * Between symbol address __copy_table_start__ and __copy_table_end__, * there are array of tuples specifying: * offset 0: Start of a BSS section * offset 4: Size of this BSS section. Must be multiply of 4 */ pTable = &__zero_table_start__; for (; pTable < &__zero_table_end__; pTable = pTable + 2) { pDest = (uint32_t*)*(pTable + 0); for (; pDest < (uint32_t*)(*(pTable + 0) + *(pTable + 1)) ; ) { *pDest++ = 0; } } #elif defined (__STARTUP_CLEAR_BSS) /* Single BSS section scheme. * * The BSS section is specified by following symbols * __bss_start__: start of the BSS section. * __bss_end__: end of the BSS section. * * Both addresses must be aligned to 4 bytes boundary. */ pDest = &__bss_start__; for ( ; pDest < &__bss_end__ ; ) { *pDest++ = 0ul; } #endif /* __STARTUP_CLEAR_BSS_MULTIPLE || __STARTUP_CLEAR_BSS */ #ifndef __NO_SYSTEM_INIT SystemInit(); #endif #ifndef __START #define __START _start #endif __START(); } /*---------------------------------------------------------------------------- Default Handler for Exceptions / Interrupts *----------------------------------------------------------------------------*/ void Default_Handler(void) { while(1); }
the_stack_data/377598.c
// // Created by Rahul on 6/26/2019. // #include<ctype.h> double atof(char s[]) { double val,power; int i,sign; for(i=0;isspace(s[i]);i++) ; sign=(s[i]=='-')? -1:1; if(s[i]=='+'|| s[i]=='-') i++; for(val=0.0; isdigit(s[i]);++i) val=10.0*val+(s[i]-'0'); if(s[i]=='.') i++; for(power=1;isdigit(s[i]);i++) { val=10*val+(s[i]-'0'); power*=10; } return sign*val/power; }
the_stack_data/14200253.c
#include <stdio.h> void scilab_rt_bar_i0d2d0s0_(int scalarin0, int in00, int in01, double matrixin0[in00][in01], double scalarin1, char* scalarin2) { int i; int j; double val0 = 0; printf("%d", scalarin0); for (i = 0; i < in00; ++i) { for (j = 0; j < in01; ++j) { val0 += matrixin0[i][j]; } } printf("%f", val0); printf("%f", scalarin1); printf("%s", scalarin2); }
the_stack_data/28263187.c
#include <stdio.h> #include <stdlib.h> int f(int,int); int main() { int m,n; scanf("%d%d",&m,&n); printf("%d",f(m,n)); return 0; } int f(int x,int y) { if (y==1) return x; if (x<y||x==0||y==0) return 0; return f(x-1,y)+f(x-1,y-1); }
the_stack_data/57839.c
// hello.c #include <stdio.h> int main() { printf("Hello, world!\n"); return 0; }
the_stack_data/103265360.c
// Write a program to replace every element in the dynamic array with the next greatest element present in the same array. #include<stdio.h> #include<stdlib.h> int main(){ int size=0; printf("Enter the size of array: "); scanf("%d",&size); int *a = (int*)malloc(size*sizeof(int)); printf("Enter the elements of array: "); for(int i=0;i<size;i++)scanf("%d",&a[i]); for(int i=0;i<size-1;i++){ for(int j=i+1;j<size;j++){ if(a[j]>a[i]){ a[i]=a[j]; break; } if(j==size-1)a[i]=-1; } } a[size-1]=-1; printf("The replaced array is: "); for(int i=0;i<size;i++)printf("%d ",a[i]); printf("\n"); free(a); return 0; }
the_stack_data/111304.c
/** * @file lltoa.c * Copyright 2012, 2013 MinGW.org project * * 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 (including the next * paragraph) 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. */ #include <stdlib.h> char* lltoa(long long _n, char * _c, int _i) { return _i64toa (_n, _c, _i); }
the_stack_data/136442.c
#include <stdio.h> int main(void) { int count, num, *max = NULL; printf("何個入力しますか?: "); if (scanf("%d%*[^\n]", &count) != 1) { return 1; } for (int i = 0; i < count; ++i) { printf("入力%d: ", i + 1); if (scanf("%d%*[^\n]", &num) != 1) { break; } if (max == NULL || num > *max) { max = &(int){num}; } } if (max == NULL) { printf("最大値: 未定義\n"); } else { printf("最大値: %d\n", *max); } return 0; }
the_stack_data/98574238.c
/* Sysdep aRts sound dsp driver Copyright 2001 Manuel Teira This file and the acompanying files in this directory are free software; you can redistribute them and/or modify them under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. These files are distributed in the hope that they will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with these files; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* Changelog Version 0.1, April 2001 -initial release, based on the esound mame sound driver */ #ifdef SYSDEP_DSP_ARTS_TEIRA #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <sys/ioctl.h> #include <artsc.h> #include "sysdep/sysdep_dsp.h" #include "sysdep/sysdep_dsp_priv.h" #include "sysdep/plugin_manager.h" /* our per instance private data struct */ struct arts_dsp_priv_data { arts_stream_t stream; }; /* public methods prototypes (static but exported through the sysdep_dsp or plugin struct) */ static void *arts_dsp_create(const void *flags); static void arts_dsp_destroy(struct sysdep_dsp_struct *dsp); static int arts_dsp_write(struct sysdep_dsp_struct *dsp, unsigned char *data, int count); static int btime=10; struct rc_option arts_dsp_opts[] = { /* name, shortname, type, dest, */ /* deflt, min, max, func, help */ {"artsBufferTime","abt",rc_int, &btime, "10",1,1000,NULL,"aRts buffer delay time"}, {NULL,NULL,rc_end,NULL,NULL,0,0,NULL,NULL} }; /* public variables */ const struct plugin_struct sysdep_dsp_arts = { "arts", "sysdep_dsp", "aRts DSP plugin", arts_dsp_opts, NULL, /* no init */ NULL, /* no exit */ arts_dsp_create, 3 /* high priority */ }; /* private variables */ static int arts_dsp_bytes_per_sample[4] = SYSDEP_DSP_BYTES_PER_SAMPLE; /* public methods (static but exported through the sysdep_dsp or plugin struct) */ static void *arts_dsp_create(const void *flags) { struct sysdep_dsp_struct *dsp = NULL; struct arts_dsp_priv_data *priv = NULL; const struct sysdep_dsp_create_params *params = flags; /* allocate the dsp struct */ if (!(dsp = calloc(1, sizeof(struct sysdep_dsp_struct)))) { fprintf(stderr, "error malloc failed for struct sysdep_dsp_struct\n"); return NULL; } if(!(priv = calloc(1, sizeof(struct arts_dsp_priv_data)))) { fprintf(stderr, "error malloc failed for struct arts_dsp_priv_data\n"); return NULL; } /* fill in the functions and some data */ priv->stream=0; dsp->_priv = priv; dsp->write = arts_dsp_write; dsp->destroy = arts_dsp_destroy; dsp->hw_info.type = params->type; dsp->hw_info.samplerate = params->samplerate; dsp->hw_info.bufsize = 1024; /* open the sound device */ arts_init(); priv->stream=arts_play_stream(dsp->hw_info.samplerate, (dsp->hw_info.type&SYSDEP_DSP_16BIT)?16:8, (dsp->hw_info.type&SYSDEP_DSP_STEREO)?2:1, "xmame arts"); /* Set the buffering time */ arts_stream_set(priv->stream,ARTS_P_BUFFER_TIME,btime); /* set non-blocking mode if selected */ if(params->flags & SYSDEP_DSP_O_NONBLOCK) { arts_stream_set(priv->stream,ARTS_P_BLOCKING,0); } return dsp; } static void arts_dsp_destroy(struct sysdep_dsp_struct *dsp) { struct arts_dsp_priv_data *priv = dsp->_priv; if(priv) { arts_close_stream(priv->stream); arts_free(); free(priv); } free(dsp); } static int arts_dsp_write(struct sysdep_dsp_struct *dsp, unsigned char *data, int count) { int result; struct arts_dsp_priv_data *priv = dsp->_priv; result=arts_write(priv->stream, data, count * arts_dsp_bytes_per_sample[dsp->hw_info.type]); if (result<0) { fprintf(stderr, "error: arts_write error: %s\n", arts_error_text(result)); return -1; } return result/arts_dsp_bytes_per_sample[dsp->hw_info.type]; } #endif /* ifdef SYSDEP_DSP_ARTS_TEIRA */
the_stack_data/1067328.c
#include <stdarg.h> #include <stdlib.h> extern char *getenv(const char *name); static int fake_dopr(va_list args) { char *t1 = va_arg(args, char *); char *nt1 = va_arg(args, char *); char *t2 = va_arg(args, char *); char *nt2 = va_arg(args, char *); char *nt3 = va_arg(args, char *); return -1; } int fake_BIO_vprintf(int n, va_list args) { return fake_dopr(args); } int fake_BIO_printf(int n, ...) { va_list args; va_start(args, n); int rc = fake_BIO_vprintf(n, args); va_end(args); return rc; } int main() { char *not_tainted = "hello world"; char *tainted = getenv("gude"); int rc = fake_BIO_printf(6, tainted, not_tainted, tainted, not_tainted, not_tainted); return rc; }