file
stringlengths 18
26
| data
stringlengths 3
1.04M
|
---|---|
the_stack_data/86074165.c | /*
* $Id: msg_msgsnap.c,v 1.1 2021-01-26 19:42:41 clib2devs Exp $
*/
#ifdef HAVE_SYSV
#ifndef _SHM_HEADERS_H
#include "shm_headers.h"
#endif /* _SHM_HEADERS_H */
int
_msgsnap(int msqid, void *buf, size_t bufsz, long msgtyp)
{
DECLARE_SYSVYBASE();
int ret = -1;
if (__global_clib2->haveShm)
{
ret = msgsnap(msqid, buf, bufsz, msgtyp);
if (ret < 0)
{
__set_errno(GetIPCErr());
}
}
else
{
__set_errno(ENOSYS);
}
return ret;
}
#endif |
the_stack_data/1058678.c | /* This file is part of The Firekylin Operating System.
*
* Copyright 2016 Liuxiaofeng
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <time.h>
double difftime(time_t time1, time_t time0)
{
return (double) (time1 - time0);
}
|
the_stack_data/178266248.c | /*
* @@name: declare_target.5c
* @@type: C
* @@compilable: yes
* @@linkable: no
* @@expect: success
* @@version: omp_4.0
*/
#define N 10000
#define M 1024
#pragma omp declare target
float Q[N][N];
#pragma omp declare simd uniform(i) linear(k) notinbranch
float P(const int i, const int k)
{
return Q[i][k] * Q[k][i];
}
#pragma omp end declare target
float accum(void)
{
float tmp = 0.0;
int i, k;
#pragma omp target map(tofrom: tmp)
#pragma omp parallel for reduction(+:tmp)
for (i=0; i < N; i++) {
float tmp1 = 0.0;
#pragma omp simd reduction(+:tmp1)
for (k=0; k < M; k++) {
tmp1 += P(i,k);
}
tmp += tmp1;
}
return tmp;
}
/* Note: The variable tmp is now mapped with tofrom, for correct
execution with 4.5 (and pre-4.5) compliant compilers. See Devices Intro.
*/
|
the_stack_data/184517268.c | // array _u_x must not be scalarized at the loop level because
// its reference indices use __lv2 which is modified.
// it can nowever be scalarized at the inner statement level.
#include <stdio.h>
int __lv1;
int __lv2;
int main(int argc, char* argv[])
{
/* x = [0.1:0.1:1]; */
double _u_x[10][1];
_u_x[0][0]=0.1;
_u_x[1][0]=0.2;
_u_x[2][0]=0.3;
_u_x[3][0]=0.4;
_u_x[4][0]=0.5;
_u_x[5][0]=0.6;
_u_x[6][0]=0.7;
_u_x[7][0]=0.8;
_u_x[8][0]=0.9;
_u_x[9][0]=1;
double _u_c[10][1];
for (__lv1=0; __lv1<10; __lv1++)
{
// originaly generated by simplify_control_directly for loop
// for (__lv2=0; __lv2<1; __lv2++)
__lv2 = 0;
_u_c[__lv1][__lv2] = _u_x[__lv1][__lv2] + _u_x[__lv1][__lv2];
__lv2 = 0+1;
}
for (__lv1=0; __lv1<10; __lv1++)
for (__lv2=0; __lv2<1; __lv2++)
printf( "%lf\n",_u_c[__lv1][__lv2]);
return 0;
}
|
the_stack_data/109112.c | /*
This program is going to do the factorial in the normal way
*/
#include <stdio.h>
int fac_iterative (int n){
int fac=1;
while(n >0)
{
fac=fac*n;
n--;
printf("%d\n", fac);
}
return fac;
}
int main()
{
int n;
printf("Insert the desired number to calculate the factorial:\n");
scanf("%d",&n);
fac_iterative(n);
return 0;
}
|
the_stack_data/153269265.c | #include <stdio.h>
#include <stdlib.h>
#ifndef ARCH
#define ARCH "Undefined"
#endif
int main()
{
printf("\n === DevDay === \n\n");
printf("Hello, architecture from uname is %s\n", ARCH);
switch (sizeof(void *))
{
case 4:
printf("32-bit userspace\n\n");
break;
case 8:
printf("64-bit userspace\n\n");
break;
default:
printf("unknown userspace\n\n");
}
exit(0);
} |
the_stack_data/248580712.c | /* vendingmachine.c
A finite state machine as a vending machine */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MAX_SIZE 10
// define variables and default amounts
int products_total = 4;
int total_money_inserted;
int inserted_coin_value;
int product_selection;
int product_price;
int returned_money;
// define product structure
struct Products
{
char name[20];
int price;
};
struct Products arr_products[MAX_SIZE] =
{
{"Fritos", 25},
{"Cookie", 10},
{"Donuts", 5},
{"Starburst", 100},
};
// prototype functions
void add_product(struct Products arr_products[MAX_SIZE]);
void print_product(struct Products arr_products[MAX_SIZE]);
// int argc and char *argv[] allow arguments to be passed in CLI during init
int main(int argc, char *argv[])
{
int main_menu_selection;
while(1)
{
printf("Welcome to CoinOnly Vending!\n");
printf("Please choose an option by their corresponding number!\n");
printf("[1] Purchase product [2] Add new product [3] Turn off machine\n");
scanf("%d", &main_menu_selection);
if(main_menu_selection == 1)
{
// Reset product_price so multiple purchases will not add to price
int product_price = 0;
printf("Please choose from one of the available products below!\n");
print_product(arr_products);
printf("Please make a selection by typing the product number!\n");
scanf("%d", &product_selection);
product_price += arr_products[product_selection].price;
printf("Product selection: %d Product price in cents: %d\n", product_selection, product_price);
printf("Please insert one of the following coins with their numerical value.\n");
while(total_money_inserted < product_price)
{
printf("'1':penny, '5':nickle, '10':dime, '25':quarter\n");
scanf("%d", &inserted_coin_value);
total_money_inserted += inserted_coin_value;
inserted_coin_value = 0;
}
if(total_money_inserted==product_price)
{
printf("%s vended. Enjoy!\n", arr_products[product_selection].name);
total_money_inserted = 0;
inserted_coin_value = 0;
}
else if (total_money_inserted > product_price)
{
returned_money += total_money_inserted - product_price;
printf("%s vended. %d cents returned. Enjoy!\n", arr_products[product_selection].name, returned_money);
returned_money = 0;
total_money_inserted = 0;
inserted_coin_value = 0;
}
}
else if(main_menu_selection == 2)
{
add_product(arr_products);
}
else if(main_menu_selection == 3)
{
break;
}
else
{
printf("Invalid selection\n");
}
/* checks if command line argument was passed
if (argc == 2)
{
printf("The argument supplied is %s\n", argv[1]);
}
else if (argc > 2)
{
printf("Too many arguments supplied.\n");
}
else
{
printf("One argument expected.\n");
}*/
}
return 0;
}
void add_product(struct Products arr_products[MAX_SIZE])
{
int product_index = products_total;
printf("Enter product name: \n");
scanf("%s", arr_products[product_index].name);
printf("Enter product price: \n");
scanf("%d", &arr_products[product_index].price);
printf("%s added. price in cents: %d\n", arr_products[product_index].name, arr_products[product_index].price);
products_total += 1;
}
void print_product(struct Products arr_products[MAX_SIZE])
{
int i;
printf("List of products available\n");
for(i = 0; i < MAX_SIZE; i++)
{
printf("[%d] %s price: %d cents\n", i, arr_products[i].name, arr_products[i].price);
}
printf("%d total products in the vending machine.\n", products_total);
}
|
the_stack_data/61075869.c | #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <alloca.h>
int main(int argc, char **argv) {
size_t i=5000;
if(argc != 4) {
printf("call as: eatmem <stacksize(Kb)> <heapsize(Kb)> <period(sec)>\n");
exit(1);
}
int stacksize = atoi(argv[1]);
int heapsize = atoi(argv[2]);
int period = atoi(argv[3]);
if(stacksize==0 || heapsize==0 || period==0) {
printf("error in stacksize, heapsize or period\n");
exit(2);
}
printf("Starting with: stacksize=%d, heapsize=%d, period=%d\n", stacksize, heapsize, period);
int stackstep = stacksize / period;
int heapstep = stacksize / period;
int stackcur = 0;
int heapcur = 0;
int curperiod = 0;
char * buf;
for(curperiod=0; curperiod < period; curperiod++) {
buf = (char *) malloc(stackstep*1024);
if(buf == NULL) {
printf("no malloc buf");
exit(3);
}
buf = (char *) alloca(heapstep*1024);
if(buf == NULL) {
printf("no alloca buf");
exit(4);
}
sleep(1);
}
return 0;
}
|
the_stack_data/111078960.c | #include <stdio.h>
#include <stdlib.h>
#define ROWS 4
#define COLUMNS 10
void printArray(char arr[][COLUMNS]){
int i, e;
for (i=0; i < ROWS; i++){
for (e=0; e < COLUMNS; e++){
printf("%c", arr[i][e]);
};
printf("\n");
};
}
int pocetMin(int i, int e, char minovePole[][COLUMNS]){
int pocetMin = 0, y, w;
for (y=(i-1); y <= (i+1); y++){
for (w = (e-1); w <= (e+1); w++){
if(y==i && w==e){
pocetMin += 0;
};
if(y >= 0 && y <= ROWS && w >= 0 && w <= (COLUMNS - 1) && minovePole[y][w] == '*'){
pocetMin += 1;
};
};
};
return pocetMin;
}
int main(){
int i, e;
char minovePole[ROWS][COLUMNS];
for (i=0; i < ROWS; i++){
for (e=0; e < COLUMNS ; e++){
minovePole[i][e] = '.';
};
};
minovePole[0][5] = '*';
minovePole[1][2] = '*';
minovePole[1][5] = '*';
minovePole[2][5] = '*';
minovePole[2][8] = '*';
minovePole[3][2] = '*';
printArray(minovePole);
/*
char ** vypocet = (char **)malloc(ROWS * sizeof(char *));
for (i=0; i<ROWS; i++){
vypocet[i] = (char *)malloc(COLUMNS * sizeof(char));
};
for (i = 0; i < ROWS; i++){
for (e = 0; e < COLUMNS; e++){
vypocet[i][e] = '.';
};
};
*/
char vypocet[ROWS][COLUMNS];
for (i=0; i < ROWS; i++){
for (e=0; e < COLUMNS ; e++){
vypocet[i][e] = '.';
};
};
for (i=0; i < ROWS; i++){
for (e=0; e < COLUMNS; e++){
if (minovePole[i][e] == '*'){
vypocet[i][e] = '*';
}else {
if (pocetMin(i, e, minovePole) == 0){
vypocet[i][e] = '.';
}else {
char str[2];
sprintf(str, "%d", pocetMin(i, e, minovePole));
vypocet[i][e] = str[0];
};
};
};
};
printf("\n");
printArray(vypocet);
/*
for (i=0; i < ROWS; i++){
for (e=0; e < COLUMNS; e++){
printf("%c", vypocet[i][e]);
};
printf("\n");
};
free(vypocet);
*/
return 0;
}
|
the_stack_data/933575.c | extern void __VERIFIER_error() __attribute__ ((__noreturn__));
void __VERIFIER_assert(int expression) { if (!expression) { ERROR: __VERIFIER_error(); }; return; }
int __global_lock;
void __VERIFIER_atomic_begin() { __VERIFIER_assume(__global_lock==0); __global_lock=1; return; }
void __VERIFIER_atomic_end() { __VERIFIER_assume(__global_lock==1); __global_lock=0; return; }
#include <assert.h>
#include <pthread.h>
#ifndef TRUE
#define TRUE (_Bool)1
#endif
#ifndef FALSE
#define FALSE (_Bool)0
#endif
#ifndef NULL
#define NULL ((void*)0)
#endif
#ifndef FENCE
#define FENCE(x) ((void)0)
#endif
#ifndef IEEE_FLOAT_EQUAL
#define IEEE_FLOAT_EQUAL(x,y) (x==y)
#endif
#ifndef IEEE_FLOAT_NOTEQUAL
#define IEEE_FLOAT_NOTEQUAL(x,y) (x!=y)
#endif
void * P0(void *arg);
void * P1(void *arg);
void * P2(void *arg);
void fence();
void isync();
void lwfence();
int __unbuffered_cnt;
int __unbuffered_cnt = 0;
int __unbuffered_p2_EAX;
int __unbuffered_p2_EAX = 0;
_Bool main$tmp_guard0;
_Bool main$tmp_guard1;
int x;
int x = 0;
int y;
int y = 0;
_Bool y$flush_delayed;
int y$mem_tmp;
_Bool y$r_buff0_thd0;
_Bool y$r_buff0_thd1;
_Bool y$r_buff0_thd2;
_Bool y$r_buff0_thd3;
_Bool y$r_buff1_thd0;
_Bool y$r_buff1_thd1;
_Bool y$r_buff1_thd2;
_Bool y$r_buff1_thd3;
_Bool y$read_delayed;
int *y$read_delayed_var;
int y$w_buff0;
_Bool y$w_buff0_used;
int y$w_buff1;
_Bool y$w_buff1_used;
int z;
int z = 0;
_Bool weak$$choice0;
_Bool weak$$choice2;
void * P0(void *arg)
{
__VERIFIER_atomic_begin();
z = 1;
__VERIFIER_atomic_end();
__VERIFIER_atomic_begin();
x = 1;
__VERIFIER_atomic_end();
__VERIFIER_atomic_begin();
__VERIFIER_atomic_end();
__VERIFIER_atomic_begin();
__unbuffered_cnt = __unbuffered_cnt + 1;
__VERIFIER_atomic_end();
return nondet_0();
}
void * P1(void *arg)
{
__VERIFIER_atomic_begin();
x = 2;
__VERIFIER_atomic_end();
__VERIFIER_atomic_begin();
y = 1;
__VERIFIER_atomic_end();
__VERIFIER_atomic_begin();
y = y$w_buff0_used && y$r_buff0_thd2 ? y$w_buff0 : (y$w_buff1_used && y$r_buff1_thd2 ? y$w_buff1 : y);
y$w_buff0_used = y$w_buff0_used && y$r_buff0_thd2 ? FALSE : y$w_buff0_used;
y$w_buff1_used = y$w_buff0_used && y$r_buff0_thd2 || y$w_buff1_used && y$r_buff1_thd2 ? FALSE : y$w_buff1_used;
y$r_buff0_thd2 = y$w_buff0_used && y$r_buff0_thd2 ? FALSE : y$r_buff0_thd2;
y$r_buff1_thd2 = y$w_buff0_used && y$r_buff0_thd2 || y$w_buff1_used && y$r_buff1_thd2 ? FALSE : y$r_buff1_thd2;
__VERIFIER_atomic_end();
__VERIFIER_atomic_begin();
__unbuffered_cnt = __unbuffered_cnt + 1;
__VERIFIER_atomic_end();
return nondet_0();
}
void * P2(void *arg)
{
__VERIFIER_atomic_begin();
y$w_buff1 = y$w_buff0;
y$w_buff0 = 2;
y$w_buff1_used = y$w_buff0_used;
y$w_buff0_used = TRUE;
__VERIFIER_assert(!(y$w_buff1_used && y$w_buff0_used));
y$r_buff1_thd0 = y$r_buff0_thd0;
y$r_buff1_thd1 = y$r_buff0_thd1;
y$r_buff1_thd2 = y$r_buff0_thd2;
y$r_buff1_thd3 = y$r_buff0_thd3;
y$r_buff0_thd3 = TRUE;
__VERIFIER_atomic_end();
__VERIFIER_atomic_begin();
__unbuffered_p2_EAX = z;
__VERIFIER_atomic_end();
__VERIFIER_atomic_begin();
y = y$w_buff0_used && y$r_buff0_thd3 ? y$w_buff0 : (y$w_buff1_used && y$r_buff1_thd3 ? y$w_buff1 : y);
y$w_buff0_used = y$w_buff0_used && y$r_buff0_thd3 ? FALSE : y$w_buff0_used;
y$w_buff1_used = y$w_buff0_used && y$r_buff0_thd3 || y$w_buff1_used && y$r_buff1_thd3 ? FALSE : y$w_buff1_used;
y$r_buff0_thd3 = y$w_buff0_used && y$r_buff0_thd3 ? FALSE : y$r_buff0_thd3;
y$r_buff1_thd3 = y$w_buff0_used && y$r_buff0_thd3 || y$w_buff1_used && y$r_buff1_thd3 ? FALSE : y$r_buff1_thd3;
__VERIFIER_atomic_end();
__VERIFIER_atomic_begin();
__unbuffered_cnt = __unbuffered_cnt + 1;
__VERIFIER_atomic_end();
return nondet_0();
}
void fence()
{
}
void isync()
{
}
void lwfence()
{
}
int main()
{
pthread_create(NULL, NULL, P0, NULL);
pthread_create(NULL, NULL, P1, NULL);
pthread_create(NULL, NULL, P2, NULL);
__VERIFIER_atomic_begin();
main$tmp_guard0 = __unbuffered_cnt == 3;
__VERIFIER_atomic_end();
__VERIFIER_assume(main$tmp_guard0);
__VERIFIER_atomic_begin();
y = y$w_buff0_used && y$r_buff0_thd0 ? y$w_buff0 : (y$w_buff1_used && y$r_buff1_thd0 ? y$w_buff1 : y);
y$w_buff0_used = y$w_buff0_used && y$r_buff0_thd0 ? FALSE : y$w_buff0_used;
y$w_buff1_used = y$w_buff0_used && y$r_buff0_thd0 || y$w_buff1_used && y$r_buff1_thd0 ? FALSE : y$w_buff1_used;
y$r_buff0_thd0 = y$w_buff0_used && y$r_buff0_thd0 ? FALSE : y$r_buff0_thd0;
y$r_buff1_thd0 = y$w_buff0_used && y$r_buff0_thd0 || y$w_buff1_used && y$r_buff1_thd0 ? FALSE : y$r_buff1_thd0;
__VERIFIER_atomic_end();
__VERIFIER_atomic_begin();
/* Program proven to be relaxed for X86, model checker says YES. */
weak$$choice0 = nondet_1();
/* Program proven to be relaxed for X86, model checker says YES. */
weak$$choice2 = nondet_1();
/* Program proven to be relaxed for X86, model checker says YES. */
y$flush_delayed = weak$$choice2;
/* Program proven to be relaxed for X86, model checker says YES. */
y$mem_tmp = y;
/* Program proven to be relaxed for X86, model checker says YES. */
y = !y$w_buff0_used || !y$r_buff0_thd0 && !y$w_buff1_used || !y$r_buff0_thd0 && !y$r_buff1_thd0 ? y : (y$w_buff0_used && y$r_buff0_thd0 ? y$w_buff0 : y$w_buff1);
/* Program proven to be relaxed for X86, model checker says YES. */
y$w_buff0 = weak$$choice2 ? y$w_buff0 : (!y$w_buff0_used || !y$r_buff0_thd0 && !y$w_buff1_used || !y$r_buff0_thd0 && !y$r_buff1_thd0 ? y$w_buff0 : (y$w_buff0_used && y$r_buff0_thd0 ? y$w_buff0 : y$w_buff0));
/* Program proven to be relaxed for X86, model checker says YES. */
y$w_buff1 = weak$$choice2 ? y$w_buff1 : (!y$w_buff0_used || !y$r_buff0_thd0 && !y$w_buff1_used || !y$r_buff0_thd0 && !y$r_buff1_thd0 ? y$w_buff1 : (y$w_buff0_used && y$r_buff0_thd0 ? y$w_buff1 : y$w_buff1));
/* Program proven to be relaxed for X86, model checker says YES. */
y$w_buff0_used = weak$$choice2 ? y$w_buff0_used : (!y$w_buff0_used || !y$r_buff0_thd0 && !y$w_buff1_used || !y$r_buff0_thd0 && !y$r_buff1_thd0 ? y$w_buff0_used : (y$w_buff0_used && y$r_buff0_thd0 ? FALSE : y$w_buff0_used));
/* Program proven to be relaxed for X86, model checker says YES. */
y$w_buff1_used = weak$$choice2 ? y$w_buff1_used : (!y$w_buff0_used || !y$r_buff0_thd0 && !y$w_buff1_used || !y$r_buff0_thd0 && !y$r_buff1_thd0 ? y$w_buff1_used : (y$w_buff0_used && y$r_buff0_thd0 ? FALSE : FALSE));
/* Program proven to be relaxed for X86, model checker says YES. */
y$r_buff0_thd0 = weak$$choice2 ? y$r_buff0_thd0 : (!y$w_buff0_used || !y$r_buff0_thd0 && !y$w_buff1_used || !y$r_buff0_thd0 && !y$r_buff1_thd0 ? y$r_buff0_thd0 : (y$w_buff0_used && y$r_buff0_thd0 ? FALSE : y$r_buff0_thd0));
/* Program proven to be relaxed for X86, model checker says YES. */
y$r_buff1_thd0 = weak$$choice2 ? y$r_buff1_thd0 : (!y$w_buff0_used || !y$r_buff0_thd0 && !y$w_buff1_used || !y$r_buff0_thd0 && !y$r_buff1_thd0 ? y$r_buff1_thd0 : (y$w_buff0_used && y$r_buff0_thd0 ? FALSE : FALSE));
/* Program proven to be relaxed for X86, model checker says YES. */
main$tmp_guard1 = !(x == 2 && y == 2 && __unbuffered_p2_EAX == 0);
/* Program proven to be relaxed for X86, model checker says YES. */
y = y$flush_delayed ? y$mem_tmp : y;
/* Program proven to be relaxed for X86, model checker says YES. */
y$flush_delayed = FALSE;
__VERIFIER_atomic_end();
/* Program proven to be relaxed for X86, model checker says YES. */
__VERIFIER_assert(main$tmp_guard1);
return 0;
}
|
the_stack_data/173577636.c | int foo(int a){
return a - 1;
}
int main(){
int i,j = 0;
#pragma spf transform inline
for(i = 100; i > 0; i = foo(i)){
j++;
}
return 0;
}
//CHECK: inline_39.c:9:26: warning: disable inline expansion in the third section of for-loop
//CHECK: for(i = 100; i > 0; i = foo(i)){
//CHECK: ^
//CHECK: 1 warning generated.
|
the_stack_data/482890.c | static long foo(long a, long b, long c)
{
return a? b:c;
}
static long foo_bool(_Bool a, long b, long c)
{
return a? b:c;
}
static long bar(long a, long b, long c)
{
if (a)
return b;
else
return b + c;
}
static long bar_bool(_Bool a, long b, long c)
{
if (a)
return b;
else
return b + c;
}
/*
* check-name: Non-bool condition values in branch/select
* check-command: sparsec -c $file -o tmp.o
*/
|
the_stack_data/26701153.c | /* In one state, single residents are subject to the following income tax:
Income Amount of tax
Not over $750 1% of income
$750-$2,250 $7.50 plus 2% of amount over $750
$2,250-$3,750 $37.50 plus 3% of amount over $2,250
$3,750-$5,250 $82.50 plus 4% of amount over $3,750
$5,250-$7,000 $142.50 plus 5% ol amount over $5,250
Over $7,000 $230.00 plus 6% of amount over $7,000
Write a program that asks the user to enter the amount of taxable income, then displays the tax due. */
#include <stdio.h>
int main() {
float income, tax;
printf("\nEnter amount of income: ");
scanf("%f", &income);
if (income < 750)
tax = income * 0.01f;
else if (income <= 2250)
tax = 7.50f + ((income - 750) * 0.02f);
else if (income <= 3750)
tax = 37.50f + ((income - 2250) * 0.03f);
else if (income <= 5250)
tax = 82.50f + ((income - 3750) * 0.04f);
else if (income <= 7000)
tax = 142.50f + ((income - 5250) * 0.05f);
else
tax = 230.00f + ((income - 7000) * 0.06f);
printf("Tax due: $%.2f\n\n", tax);
return 0;
} |
the_stack_data/877557.c | #include <stdio.h>
#include <stdlib.h>
/*
https://www.infoq.com/news/2020/08/c2rust-transpiler
C type systems hide so much relevant information required to make even basic assumptions.
For example, if we take strncpy declaration, it really requires its two arguments destination and source to be arrays,
but its signature hides this fact behind the generic notion of a pointer to a character:
char* strncpy (char* destination, const char* source, size_t num);
Even though some languages are context-sensitive, context-sensitive grammars are rarely used for describing computer languages.
For instance, C is slightly context-sensitive because of the way it handles identifiers and type,
but this context-sensitivity is resolved by a special convention, rather than by introducing context-sensitivity into the grammar.
http://matt.might.net/articles/grammars-bnf-ebnf
*/
//characters
void functionxyz_char(char** outVariable)
{
*outVariable = malloc( 2 * sizeof(char) );
(*outVariable)[0] = 'A';
(*outVariable)[1] = 'B';
printf("Inside functionxyz_char \n");
printf("theVariablechar[0] = %c \n",(*outVariable)[0]);
printf("theVariablechar[1] = %c \n",(*outVariable)[1]);
printf("Address[0] = %p \n", &( (*outVariable)[0] ) );
printf("Address[1] = %p \n", &( (*outVariable)[1] ) );
}
//strings
void functionxyz_string(char*** outVariable)
{
*outVariable = malloc( 2 * sizeof(char*) );
(*outVariable)[0] = "A";
(*outVariable)[1] = "B";
printf("Inside functionxyz_string \n");
printf("theVariablestring[0] = %s \n",(*outVariable)[0]);
printf("theVariablestring[1] = %s \n",(*outVariable)[1]);
printf("Address[0] = %p \n", &((*outVariable)[0]));
printf("Address[1] = %p \n", &((*outVariable)[1]));
}
int main() {
/*
foo[x] = *(foo + x)
*(foo[x]) = *( *(foo + x) )
(*foo)[x] = *( *foo + x )
if you do *outVariable[0] it works necause *outVariable[0] is basically **outVariable
So &theVariable[1] is & (theVariable[1]) and not (&theVariable)[1]
variable char = character value => char x = 'A';
variable char* = character pointer / character array => char *x = { 'A', 'B', 'C', 0 };
function argument char** = reference value to character array
variable char* = string => char *y = "ABC";
variable char** = string pointer / string array => char **y = {"ABC", "DEF", "GHI", 123};
function argument char*** = reference value to string array
char** reference to character array
char*** reference to string array
The last digit is number of items
const char *a[2];
a[0] = "blah";
a[1] = "hmm";
Here the last digit become number of character for each item
char a[2][14];
strcpy(a[0], "blah");
strcpy(a[1], "hmm");
*/
char* theVariablechar = NULL;
functionxyz_char(&theVariablechar);
printf("after function return, Address[0] = %p \n", &theVariablechar[0]);
printf("after function return, Address[1] = %p \n", &theVariablechar[1]);
printf("theVariablechar[0] = %c \n",theVariablechar[0]);
printf("theVariablechar[1] = %c \n",theVariablechar[1]);
printf("\n --------- \n\n");
char** theVariablestring = NULL;
functionxyz_string(&theVariablestring);
printf("after function return, Address[0] = %p \n", &theVariablestring[0]);
printf("after function return, Address[1] = %p \n", &theVariablestring[1]);
printf("theVariablestring[0] = %s \n",theVariablestring[0]);
printf("theVariablestring[1] = %s \n",theVariablestring[1]);
return 0;
}
/*
Inside functionxyz_char
theVariablechar[0] = A
theVariablechar[1] = B
Address[0] = 0x5634e70382a0
Address[1] = 0x5634e70382a1
after function return, Address[0] = 0x5634e70382a0
after function return, Address[1] = 0x5634e70382a1
theVariablechar[0] = A
theVariablechar[1] = B
---------
Inside functionxyz_string
theVariablestring[0] = A
theVariablestring[1] = B
Address[0] = 0x5634e70386d0
Address[1] = 0x5634e70386d8
after function return, Address[0] = 0x5634e70386d0
after function return, Address[1] = 0x5634e70386d8
theVariablestring[0] = A
theVariablestring[1] = B
*/
|
the_stack_data/165768117.c | // check fifo size
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#define BUFFER_SIZE (0xFF + 1)
#define DEBUG_DUMP(string) \
do \
{ \
printf("reader: %s\n", #string); \
} \
while(0)
int write_pid(const int pid, const int fifo_fd)
{
char* buffer = (char*)calloc(BUFFER_SIZE, sizeof(char)); // ATTENTION! MAYBE IT'LL BE BETTER TO USE A STACK ALLOCATION
if(buffer == NULL)
{
perror("calloc");
exit(EXIT_FAILURE);
}
// int read_size = 0;
int ret_val = snprintf(buffer, BUFFER_SIZE, "%d%c", pid, ' ');
// printf("retVal = %d\nsizeof(pid) = %ld\n", ret_val, sizeof(pid));
if(ret_val < 0)
{
perror("printf");
return EXIT_FAILURE;
}
printf("buffer: %s\n", buffer);
// write buffer into fifo
ret_val = write(fifo_fd, buffer, strlen(buffer));
if(ret_val != strlen(buffer)) // double counting of str length
{
perror("write");
exit(EXIT_FAILURE);
}
free(buffer);
buffer = NULL;
return 0;
}
// open fifo -> read line from fifo -> convert pid into int -> return pid
// Should It open fifo?
int read_pid(/*const char* fifo_name*/ const int fifo_fd)
{
/*int fd = open(fifo_name, O_RDONLY | O_CREAT);
if(fd < 0)
{
perror("open");
exit(EXIT_FAILURE);
}*/
char line[BUFFER_SIZE + 1] = {};
int read_size = read(fifo_fd, line, BUFFER_SIZE);
if(read_size < 0)
{
perror("read");
exit(EXIT_FAILURE);
}
line[read_size] = '\0'; // ATTENTION!
pid_t pid = 0;
int scanf_size = sscanf(line, "%d", &pid);
if(scanf_size <= 0)
{
perror("sscanf");
exit(EXIT_FAILURE);
}
printf("PID = %d\n", pid);
char* cat_ptr = strncat(line,".fifo", 6);
if(cat_ptr == 0)
{
perror("strncat");
exit(EXIT_FAILURE);
}
printf("line = %s\n", line);
return 0;
}
int main()
{
char fifo_name[] = "fifo";
int retVal = mkfifo(fifo_name, 0666);
if(retVal < 0)
{
if(errno == EEXIST)
{
DEBUG_DUMP(mknod: fifo already exists);
}
else
{
perror("mkfifo");
exit(EXIT_FAILURE);
}
}
int fifo_fd = open(fifo_name, O_RDWR | O_CREAT);
if(fifo_fd < 0)
{
perror("open");
exit(EXIT_FAILURE);
}
int i = 0;
for(i = 0; i < 10; i++)
{
write_pid(i, fifo_fd);
read_pid(fifo_fd);
}
retVal = close(fifo_fd);
if(retVal < 0)
{
perror("close");
exit(EXIT_FAILURE);
}
unlink(fifo_name);
return 0;
} |
the_stack_data/117328420.c | int main(void)
{
int a = 5;
int b = 10;
int c = a + b;
printf ("%d + %d = %d\n", a, b, c);
}
|
the_stack_data/67325529.c | #include <stdbool.h>
int
main()
{
int bees, fleas;
unsigned int foo = (unsigned int*)&bees;
unsigned int bar = (unsigned int*)&fleas;
bool baz = nondet_bool();
__ESBMC_assume(baz == true);
unsigned int qux = (baz) ? foo : bar;
int *fin = (int *)qux;
assert (fin == &bees);
*fin = 0;
assert(bees == 0);
return 0;
}
|
the_stack_data/89199814.c | /**
* @license Apache-2.0
*
* Copyright (c) 2018 The Stdlib Authors.
*
* 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.
*/
/**
* Benchmark Cephes `beta`.
*/
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <sys/time.h>
#define NAME "beta"
#define ITERATIONS 1000000
#define REPEATS 3
/**
* Define prototypes for external functions.
*/
extern double beta( double a, double b );
/**
* Prints the TAP version.
*/
void print_version() {
printf( "TAP version 13\n" );
}
/**
* Prints the TAP summary.
*
* @param total total number of tests
* @param passing total number of passing tests
*/
void print_summary( int total, int passing ) {
printf( "#\n" );
printf( "1..%d\n", total ); // TAP plan
printf( "# total %d\n", total );
printf( "# pass %d\n", passing );
printf( "#\n" );
printf( "# ok\n" );
}
/**
* Prints benchmarks results.
*
* @param elapsed elapsed time in seconds
*/
void print_results( double elapsed ) {
double rate = (double)ITERATIONS / elapsed;
printf( " ---\n" );
printf( " iterations: %d\n", ITERATIONS );
printf( " elapsed: %0.9f\n", elapsed );
printf( " rate: %0.9f\n", rate );
printf( " ...\n" );
}
/**
* Returns a clock time.
*
* @return clock time
*/
double tic() {
struct timeval now;
gettimeofday( &now, NULL );
return (double)now.tv_sec + (double)now.tv_usec/1.0e6;
}
/**
* Generates a random number on the interval [0,1].
*
* @return random number
*/
double rand_double() {
int r = rand();
return (double)r / ( (double)RAND_MAX + 1.0 );
}
/**
* Runs a benchmark.
*
* @return elapsed time in seconds
*/
double benchmark() {
double elapsed;
double x;
double y;
double z;
double t;
int i;
t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = ( 1000.0*rand_double() ) + 0.0;
y = ( 1000.0*rand_double() ) + 0.0;
z = beta( x, y );
if ( z != z ) {
printf( "should not return NaN\n" );
break;
}
}
elapsed = tic() - t;
if ( z != z ) {
printf( "should not return NaN\n" );
}
return elapsed;
}
/**
* Main execution sequence.
*/
int main( void ) {
double elapsed;
int i;
// Use the current time to seed the random number generator:
srand( time( NULL ) );
print_version();
for ( i = 0; i < REPEATS; i++ ) {
printf( "# c::cephes::%s\n", NAME );
elapsed = benchmark();
print_results( elapsed );
printf( "ok %d benchmark finished\n", i+1 );
}
print_summary( REPEATS, REPEATS );
}
|
the_stack_data/163603.c | #include <stdio.h>
#include <stdlib.h>
int main()
{
char map[10] = {
' ', '.', '\'', ':', '~',
'*', '=', ' ', '%', '#'
};
FILE *finput = fopen("Exer_13_12_input.txt", "r"), *foutput = fopen("Exer_13_12_output.txt", "w");
if (finput == NULL || foutput == NULL) {
printf("Can't open file.\n");
exit(EXIT_FAILURE);
}
int numbers[20][30];
for (int i = 0; i < 20; i++)
for (int j = 0; j < 30; j++)
fscanf(finput, "%d", &numbers[i][j]);
char digits[20][31];
for (int i = 0; i < 20; i++) {
for (int j = 0; j < 30; j++)
digits[i][j] = map[numbers[i][j]];
digits[i][30] = '\0';
}
for (int i = 0; i < 20; i++)
fprintf(foutput, "%s\n", digits[i]);
fclose(finput);
fclose(foutput);
return 0;
} |
the_stack_data/144145.c | //
// Created by zhangrongxiang on 2017/9/22 11:16
//
#include <stdarg.h>
#include <stdio.h>
/*
*计算平均值
*/
float average(int n_values, ...) {
// va_list类型用于声明一个变量,该变量将依次引用各参数。
va_list var_arg;
int count;
float sum = 0;
// Ava_start宏将va_list声明的变量初始化为指向第一个无名参数的指针。
// 在使用变量之前,该宏必须被调用一次。参数表必须至少包括一个有名参数,va_start将最后一个有名参数作为起点。
va_start(var_arg, n_values); /*准备访问可变参数 */
for (count = 0; count < n_values; count += 1) {
// va_start宏将va_list声明的变量初始化为指向第一个无名参数的指针。
// 在使用变量之前,该宏必须被调用一次。参数表必须至少包括一个有名参数,va_start将最后一个有名参数作为起点。
sum += va_arg(var_arg, int);/*添加取自可变参数列表的值 ֵ*/
}
// va_end宏,该宏必须在函数返回之前调用,以完成一些必要的清理工作。
va_end(var_arg); /*完成处理可变参数 */
return sum / n_values;
}
void main(int argc, char **argv) {
printf("the average of 3 and 8 is %f\n", average(2, 3, 8));
printf("the average of 3 and 8 and 11 is %f\n", average(3, 3, 8, 11));
return;
}
|
the_stack_data/502469.c | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: angmarti <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/26 13:01:55 by mkreivi #+# #+# */
/* Updated: 2021/08/26 16:19:51 by angmarti ### ########.fr */
/* */
/* ************************************************************************** */
int ft_strncmp(char *s1, char *s2, unsigned int n);
int ft_strncmp(char *s1, char *s2, unsigned int n)
{
unsigned int i;
if (n == 0)
return (0);
i = 0;
while (s1[i] == s2[i] && s1[i] != '\0' && s2[i] != '\0' && i != (n - 1))
++i;
return (s1[i] - s2[i]);
}
#include <stdio.h>
#include <string.h>
void test(int test, char s1[], char s2[], int n)
{
int expected;
int obtained;
expected = strncmp(&s1[0], &s2[0], n);
obtained = ft_strncmp(&s1[0], &s2[0], n);
if (obtained != expected)
{
printf("\nTest %d: Error!\n", test);
printf("s1: %s\ns2: %s\n", s1, s2);
printf("Reultado expected: %d\n", expected);
printf("Reultado obtained: %d\n", obtained);
printf("\n");
}
else
{
printf("Test %d: OK!\n", test);
}
}
int main(void)
{
int t;
t = 1;
test(t++, "hola", "hola", 10);
test(t++, "hola", "hol?", 10);
test(t++, "hola", "ho??", 10);
test(t++, "hol\0", "hol\0", 10);
test(t++, "ho\0a", "ho\0a", 10);
test(t++, "ho\0a", "hol\0", 10);
test(t++, "\0ola", "\0ola", 10);
test(t++, "ho\tla!", "ho\tla!", 10);
test(t++, "ho\tla!", "hola!", 10);
test(t++, "hol\0a!", "hol\0a!", 10);
test(t++, "ho\tla!", "ho\tla!", 10);
test(t++, "ho\tla!", "hola!", 10);
test(t++, "\0\0\0\0", "\0\0\0\0", 10);
test(t++, "hola\0\0\0\0", "hola\0\0\0\0", 10);
test(t++, "hola\0\0\0\0", "hol\0\0\0\0", 10);
test(t++, "hola", "hola", 6);
test(t++, "hola", "hol?", 6);
test(t++, "hola", "ho??", 6);
test(t++, "hol\0", "hol\0", 6);
test(t++, "ho\0a", "ho\0a", 6);
test(t++, "ho\0a", "hol\0", 6);
test(t++, "\0ola", "\0ola", 6);
test(t++, "ho\tla!", "ho\tla!", 6);
test(t++, "ho\tla!", "hola!", 6);
test(t++, "hol\0a!", "hol\0a!", 6);
test(t++, "ho\tla!", "ho\tla!", 6);
test(t++, "ho\tla!", "hola!", 6);
test(t++, "\0\0\0\0", "\0\0\0\0", 6);
test(t++, "hola\0\0\0\0", "hola\0\0\0\0", 6);
test(t++, "hola\0\0\0\0", "hol\0\0\0\0", 6);
}
|
the_stack_data/693502.c | int count = 0; // global counter for red lights
int run = 1; // global, used to increment/not the count variable
int main(void) {
volatile int * LED_ptr = (int *)0xFF200000;
set_A9_IRQ_stack(); // initialize the stack pointer for IRQ mode
config_GIC(); // configure the general interrupt controller
config_HPS_timer(); // configure HPS Timer 0
config_KEYs(); // configure pushbutton KEYs to generate
// interrupts
enable_A9_interrupts(); // enable interrupts in the A9 processor
while (1) // wait for an interrupt
*LED_ptr = count;
}
/* Initialize the banked stack pointer register for IRQ mode */
void set_A9_IRQ_stack(void)
{
// code not shown
}
/* Configure the Generic Interrupt Controller (GIC) */
void config_GIC(void)
{
// code not shown
}
/* setup HPS timer */
void config_HPS_timer()
{
// code not shown
}
/* Set up the pushbutton KEYs port in the FPGA */
void config_KEYs(void)
{
// code not shown
}
/* Turn on interrupts in the ARM processor */
void enable_A9_interrupts(void)
{
// code not shown
}
|
the_stack_data/87637817.c | /*
This is a version (aka dlmalloc) of malloc/free/realloc written by
Doug Lea and released to the public domain, as explained at
http://creativecommons.org/publicdomain/zero/1.0/ Send questions,
comments, complaints, performance data, etc to [email protected]
* Version 2.8.6 Wed Aug 29 06:57:58 2012 Doug Lea
Note: There may be an updated version of this malloc obtainable at
ftp://gee.cs.oswego.edu/pub/misc/malloc.c
Check before installing!
* Quickstart
This library is all in one file to simplify the most common usage:
ftp it, compile it (-O3), and link it into another program. All of
the compile-time options default to reasonable values for use on
most platforms. You might later want to step through various
compile-time and dynamic tuning options.
For convenience, an include file for code using this malloc is at:
ftp://gee.cs.oswego.edu/pub/misc/malloc-2.8.6.h
You don't really need this .h file unless you call functions not
defined in your system include files. The .h file contains only the
excerpts from this file needed for using this malloc on ANSI C/C++
systems, so long as you haven't changed compile-time options about
naming and tuning parameters. If you do, then you can create your
own malloc.h that does include all settings by cutting at the point
indicated below. Note that you may already by default be using a C
library containing a malloc that is based on some version of this
malloc (for example in linux). You might still want to use the one
in this file to customize settings or to avoid overheads associated
with library versions.
* Vital statistics:
Supported pointer/size_t representation: 4 or 8 bytes
size_t MUST be an unsigned type of the same width as
pointers. (If you are using an ancient system that declares
size_t as a signed type, or need it to be a different width
than pointers, you can use a previous release of this malloc
(e.g. 2.7.2) supporting these.)
Alignment: 8 bytes (minimum)
This suffices for nearly all current machines and C compilers.
However, you can define MALLOC_ALIGNMENT to be wider than this
if necessary (up to 128bytes), at the expense of using more space.
Minimum overhead per allocated chunk: 4 or 8 bytes (if 4byte sizes)
8 or 16 bytes (if 8byte sizes)
Each malloced chunk has a hidden word of overhead holding size
and status information, and additional cross-check word
if FOOTERS is defined.
Minimum allocated size: 4-byte ptrs: 16 bytes (including overhead)
8-byte ptrs: 32 bytes (including overhead)
Even a request for zero bytes (i.e., malloc(0)) returns a
pointer to something of the minimum allocatable size.
The maximum overhead wastage (i.e., number of extra bytes
allocated than were requested in malloc) is less than or equal
to the minimum size, except for requests >= mmap_threshold that
are serviced via mmap(), where the worst case wastage is about
32 bytes plus the remainder from a system page (the minimal
mmap unit); typically 4096 or 8192 bytes.
Security: static-safe; optionally more or less
The "security" of malloc refers to the ability of malicious
code to accentuate the effects of errors (for example, freeing
space that is not currently malloc'ed or overwriting past the
ends of chunks) in code that calls malloc. This malloc
guarantees not to modify any memory locations below the base of
heap, i.e., static variables, even in the presence of usage
errors. The routines additionally detect most improper frees
and reallocs. All this holds as long as the static bookkeeping
for malloc itself is not corrupted by some other means. This
is only one aspect of security -- these checks do not, and
cannot, detect all possible programming errors.
If FOOTERS is defined nonzero, then each allocated chunk
carries an additional check word to verify that it was malloced
from its space. These check words are the same within each
execution of a program using malloc, but differ across
executions, so externally crafted fake chunks cannot be
freed. This improves security by rejecting frees/reallocs that
could corrupt heap memory, in addition to the checks preventing
writes to statics that are always on. This may further improve
security at the expense of time and space overhead. (Note that
FOOTERS may also be worth using with MSPACES.)
By default detected errors cause the program to abort (calling
"abort()"). You can override this to instead proceed past
errors by defining PROCEED_ON_ERROR. In this case, a bad free
has no effect, and a malloc that encounters a bad address
caused by user overwrites will ignore the bad address by
dropping pointers and indices to all known memory. This may
be appropriate for programs that should continue if at all
possible in the face of programming errors, although they may
run out of memory because dropped memory is never reclaimed.
If you don't like either of these options, you can define
CORRUPTION_ERROR_ACTION and USAGE_ERROR_ACTION to do anything
else. And if if you are sure that your program using malloc has
no errors or vulnerabilities, you can define INSECURE to 1,
which might (or might not) provide a small performance improvement.
It is also possible to limit the maximum total allocatable
space, using malloc_set_footprint_limit. This is not
designed as a security feature in itself (calls to set limits
are not screened or privileged), but may be useful as one
aspect of a secure implementation.
Thread-safety: NOT thread-safe unless USE_LOCKS defined non-zero
When USE_LOCKS is defined, each public call to malloc, free,
etc is surrounded with a lock. By default, this uses a plain
pthread mutex, win32 critical section, or a spin-lock if if
available for the platform and not disabled by setting
USE_SPIN_LOCKS=0. However, if USE_RECURSIVE_LOCKS is defined,
recursive versions are used instead (which are not required for
base functionality but may be needed in layered extensions).
Using a global lock is not especially fast, and can be a major
bottleneck. It is designed only to provide minimal protection
in concurrent environments, and to provide a basis for
extensions. If you are using malloc in a concurrent program,
consider instead using nedmalloc
(http://www.nedprod.com/programs/portable/nedmalloc/) or
ptmalloc (See http://www.malloc.de), which are derived from
versions of this malloc.
System requirements: Any combination of MORECORE and/or MMAP/MUNMAP
This malloc can use unix sbrk or any emulation (invoked using
the CALL_MORECORE macro) and/or mmap/munmap or any emulation
(invoked using CALL_MMAP/CALL_MUNMAP) to get and release system
memory. On most unix systems, it tends to work best if both
MORECORE and MMAP are enabled. On Win32, it uses emulations
based on VirtualAlloc. It also uses common C library functions
like memset.
Compliance: I believe it is compliant with the Single Unix Specification
(See http://www.unix.org). Also SVID/XPG, ANSI C, and probably
others as well.
* Overview of algorithms
This is not the fastest, most space-conserving, most portable, or
most tunable malloc ever written. However it is among the fastest
while also being among the most space-conserving, portable and
tunable. Consistent balance across these factors results in a good
general-purpose allocator for malloc-intensive programs.
In most ways, this malloc is a best-fit allocator. Generally, it
chooses the best-fitting existing chunk for a request, with ties
broken in approximately least-recently-used order. (This strategy
normally maintains low fragmentation.) However, for requests less
than 256bytes, it deviates from best-fit when there is not an
exactly fitting available chunk by preferring to use space adjacent
to that used for the previous small request, as well as by breaking
ties in approximately most-recently-used order. (These enhance
locality of series of small allocations.) And for very large requests
(>= 256Kb by default), it relies on system memory mapping
facilities, if supported. (This helps avoid carrying around and
possibly fragmenting memory used only for large chunks.)
All operations (except malloc_stats and mallinfo) have execution
times that are bounded by a constant factor of the number of bits in
a size_t, not counting any clearing in calloc or copying in realloc,
or actions surrounding MORECORE and MMAP that have times
proportional to the number of non-contiguous regions returned by
system allocation routines, which is often just 1. In real-time
applications, you can optionally suppress segment traversals using
NO_SEGMENT_TRAVERSAL, which assures bounded execution even when
system allocators return non-contiguous spaces, at the typical
expense of carrying around more memory and increased fragmentation.
The implementation is not very modular and seriously overuses
macros. Perhaps someday all C compilers will do as good a job
inlining modular code as can now be done by brute-force expansion,
but now, enough of them seem not to.
Some compilers issue a lot of warnings about code that is
dead/unreachable only on some platforms, and also about intentional
uses of negation on unsigned types. All known cases of each can be
ignored.
For a longer but out of date high-level description, see
http://gee.cs.oswego.edu/dl/html/malloc.html
* MSPACES
If MSPACES is defined, then in addition to malloc, free, etc.,
this file also defines mspace_malloc, mspace_free, etc. These
are versions of malloc routines that take an "mspace" argument
obtained using create_mspace, to control all internal bookkeeping.
If ONLY_MSPACES is defined, only these versions are compiled.
So if you would like to use this allocator for only some allocations,
and your system malloc for others, you can compile with
ONLY_MSPACES and then do something like...
static mspace mymspace = create_mspace(0,0); // for example
#define mymalloc(bytes) mspace_malloc(mymspace, bytes)
(Note: If you only need one instance of an mspace, you can instead
use "USE_DL_PREFIX" to relabel the global malloc.)
You can similarly create thread-local allocators by storing
mspaces as thread-locals. For example:
static __thread mspace tlms = 0;
void* tlmalloc(size_t bytes) {
if (tlms == 0) tlms = create_mspace(0, 0);
return mspace_malloc(tlms, bytes);
}
void tlfree(void* mem) { mspace_free(tlms, mem); }
Unless FOOTERS is defined, each mspace is completely independent.
You cannot allocate from one and free to another (although
conformance is only weakly checked, so usage errors are not always
caught). If FOOTERS is defined, then each chunk carries around a tag
indicating its originating mspace, and frees are directed to their
originating spaces. Normally, this requires use of locks.
------------------------- Compile-time options ---------------------------
Be careful in setting #define values for numerical constants of type
size_t. On some systems, literal values are not automatically extended
to size_t precision unless they are explicitly casted. You can also
use the symbolic values MAX_SIZE_T, SIZE_T_ONE, etc below.
WIN32 default: defined if _WIN32 defined
Defining WIN32 sets up defaults for MS environment and compilers.
Otherwise defaults are for unix. Beware that there seem to be some
cases where this malloc might not be a pure drop-in replacement for
Win32 malloc: Random-looking failures from Win32 GDI API's (eg;
SetDIBits()) may be due to bugs in some video driver implementations
when pixel buffers are malloc()ed, and the region spans more than
one VirtualAlloc()ed region. Because dlmalloc uses a small (64Kb)
default granularity, pixel buffers may straddle virtual allocation
regions more often than when using the Microsoft allocator. You can
avoid this by using VirtualAlloc() and VirtualFree() for all pixel
buffers rather than using malloc(). If this is not possible,
recompile this malloc with a larger DEFAULT_GRANULARITY. Note:
in cases where MSC and gcc (cygwin) are known to differ on WIN32,
conditions use _MSC_VER to distinguish them.
DLMALLOC_EXPORT default: extern
Defines how public APIs are declared. If you want to export via a
Windows DLL, you might define this as
#define DLMALLOC_EXPORT extern __declspec(dllexport)
If you want a POSIX ELF shared object, you might use
#define DLMALLOC_EXPORT extern __attribute__((visibility("default")))
MALLOC_ALIGNMENT default: (size_t)(2 * sizeof(void *))
Controls the minimum alignment for malloc'ed chunks. It must be a
power of two and at least 8, even on machines for which smaller
alignments would suffice. It may be defined as larger than this
though. Note however that code and data structures are optimized for
the case of 8-byte alignment.
MSPACES default: 0 (false)
If true, compile in support for independent allocation spaces.
This is only supported if HAVE_MMAP is true.
ONLY_MSPACES default: 0 (false)
If true, only compile in mspace versions, not regular versions.
USE_LOCKS default: 0 (false)
Causes each call to each public routine to be surrounded with
pthread or WIN32 mutex lock/unlock. (If set true, this can be
overridden on a per-mspace basis for mspace versions.) If set to a
non-zero value other than 1, locks are used, but their
implementation is left out, so lock functions must be supplied manually,
as described below.
USE_SPIN_LOCKS default: 1 iff USE_LOCKS and spin locks available
If true, uses custom spin locks for locking. This is currently
supported only gcc >= 4.1, older gccs on x86 platforms, and recent
MS compilers. Otherwise, posix locks or win32 critical sections are
used.
USE_RECURSIVE_LOCKS default: not defined
If defined nonzero, uses recursive (aka reentrant) locks, otherwise
uses plain mutexes. This is not required for malloc proper, but may
be needed for layered allocators such as nedmalloc.
LOCK_AT_FORK default: not defined
If defined nonzero, performs pthread_atfork upon initialization
to initialize child lock while holding parent lock. The implementation
assumes that pthread locks (not custom locks) are being used. In other
cases, you may need to customize the implementation.
FOOTERS default: 0
If true, provide extra checking and dispatching by placing
information in the footers of allocated chunks. This adds
space and time overhead.
INSECURE default: 0
If true, omit checks for usage errors and heap space overwrites.
USE_DL_PREFIX default: NOT defined
Causes compiler to prefix all public routines with the string 'dl'.
This can be useful when you only want to use this malloc in one part
of a program, using your regular system malloc elsewhere.
MALLOC_INSPECT_ALL default: NOT defined
If defined, compiles malloc_inspect_all and mspace_inspect_all, that
perform traversal of all heap space. Unless access to these
functions is otherwise restricted, you probably do not want to
include them in secure implementations.
ABORT default: defined as abort()
Defines how to abort on failed checks. On most systems, a failed
check cannot die with an "assert" or even print an informative
message, because the underlying print routines in turn call malloc,
which will fail again. Generally, the best policy is to simply call
abort(). It's not very useful to do more than this because many
errors due to overwriting will show up as address faults (null, odd
addresses etc) rather than malloc-triggered checks, so will also
abort. Also, most compilers know that abort() does not return, so
can better optimize code conditionally calling it.
PROCEED_ON_ERROR default: defined as 0 (false)
Controls whether detected bad addresses cause them to bypassed
rather than aborting. If set, detected bad arguments to free and
realloc are ignored. And all bookkeeping information is zeroed out
upon a detected overwrite of freed heap space, thus losing the
ability to ever return it from malloc again, but enabling the
application to proceed. If PROCEED_ON_ERROR is defined, the
static variable malloc_corruption_error_count is compiled in
and can be examined to see if errors have occurred. This option
generates slower code than the default abort policy.
DEBUG default: NOT defined
The DEBUG setting is mainly intended for people trying to modify
this code or diagnose problems when porting to new platforms.
However, it may also be able to better isolate user errors than just
using runtime checks. The assertions in the check routines spell
out in more detail the assumptions and invariants underlying the
algorithms. The checking is fairly extensive, and will slow down
execution noticeably. Calling malloc_stats or mallinfo with DEBUG
set will attempt to check every non-mmapped allocated and free chunk
in the course of computing the summaries.
ABORT_ON_ASSERT_FAILURE default: defined as 1 (true)
Debugging assertion failures can be nearly impossible if your
version of the assert macro causes malloc to be called, which will
lead to a cascade of further failures, blowing the runtime stack.
ABORT_ON_ASSERT_FAILURE cause assertions failures to call abort(),
which will usually make debugging easier.
MALLOC_FAILURE_ACTION default: sets errno to ENOMEM, or no-op on win32
The action to take before "return 0" when malloc fails to be able to
return memory because there is none available.
HAVE_MORECORE default: 1 (true) unless win32 or ONLY_MSPACES
True if this system supports sbrk or an emulation of it.
MORECORE default: sbrk
The name of the sbrk-style system routine to call to obtain more
memory. See below for guidance on writing custom MORECORE
functions. The type of the argument to sbrk/MORECORE varies across
systems. It cannot be size_t, because it supports negative
arguments, so it is normally the signed type of the same width as
size_t (sometimes declared as "intptr_t"). It doesn't much matter
though. Internally, we only call it with arguments less than half
the max value of a size_t, which should work across all reasonable
possibilities, although sometimes generating compiler warnings.
MORECORE_CONTIGUOUS default: 1 (true) if HAVE_MORECORE
If true, take advantage of fact that consecutive calls to MORECORE
with positive arguments always return contiguous increasing
addresses. This is true of unix sbrk. It does not hurt too much to
set it true anyway, since malloc copes with non-contiguities.
Setting it false when definitely non-contiguous saves time
and possibly wasted space it would take to discover this though.
MORECORE_CANNOT_TRIM default: NOT defined
True if MORECORE cannot release space back to the system when given
negative arguments. This is generally necessary only if you are
using a hand-crafted MORECORE function that cannot handle negative
arguments.
NO_SEGMENT_TRAVERSAL default: 0
If non-zero, suppresses traversals of memory segments
returned by either MORECORE or CALL_MMAP. This disables
merging of segments that are contiguous, and selectively
releasing them to the OS if unused, but bounds execution times.
HAVE_MMAP default: 1 (true)
True if this system supports mmap or an emulation of it. If so, and
HAVE_MORECORE is not true, MMAP is used for all system
allocation. If set and HAVE_MORECORE is true as well, MMAP is
primarily used to directly allocate very large blocks. It is also
used as a backup strategy in cases where MORECORE fails to provide
space from system. Note: A single call to MUNMAP is assumed to be
able to unmap memory that may have be allocated using multiple calls
to MMAP, so long as they are adjacent.
HAVE_MREMAP default: 1 on linux, else 0
If true realloc() uses mremap() to re-allocate large blocks and
extend or shrink allocation spaces.
MMAP_CLEARS default: 1 except on WINCE.
True if mmap clears memory so calloc doesn't need to. This is true
for standard unix mmap using /dev/zero and on WIN32 except for WINCE.
USE_BUILTIN_FFS default: 0 (i.e., not used)
Causes malloc to use the builtin ffs() function to compute indices.
Some compilers may recognize and intrinsify ffs to be faster than the
supplied C version. Also, the case of x86 using gcc is special-cased
to an asm instruction, so is already as fast as it can be, and so
this setting has no effect. Similarly for Win32 under recent MS compilers.
(On most x86s, the asm version is only slightly faster than the C version.)
malloc_getpagesize default: derive from system includes, or 4096.
The system page size. To the extent possible, this malloc manages
memory from the system in page-size units. This may be (and
usually is) a function rather than a constant. This is ignored
if WIN32, where page size is determined using getSystemInfo during
initialization.
USE_DEV_RANDOM default: 0 (i.e., not used)
Causes malloc to use /dev/random to initialize secure magic seed for
stamping footers. Otherwise, the current time is used.
NO_MALLINFO default: 0
If defined, don't compile "mallinfo". This can be a simple way
of dealing with mismatches between system declarations and
those in this file.
MALLINFO_FIELD_TYPE default: size_t
The type of the fields in the mallinfo struct. This was originally
defined as "int" in SVID etc, but is more usefully defined as
size_t. The value is used only if HAVE_USR_INCLUDE_MALLOC_H is not set
NO_MALLOC_STATS default: 0
If defined, don't compile "malloc_stats". This avoids calls to
fprintf and bringing in stdio dependencies you might not want.
REALLOC_ZERO_BYTES_FREES default: not defined
This should be set if a call to realloc with zero bytes should
be the same as a call to free. Some people think it should. Otherwise,
since this malloc returns a unique pointer for malloc(0), so does
realloc(p, 0).
LACKS_UNISTD_H, LACKS_FCNTL_H, LACKS_SYS_PARAM_H, LACKS_SYS_MMAN_H
LACKS_STRINGS_H, LACKS_STRING_H, LACKS_SYS_TYPES_H, LACKS_ERRNO_H
LACKS_STDLIB_H LACKS_SCHED_H LACKS_TIME_H default: NOT defined unless on WIN32
Define these if your system does not have these header files.
You might need to manually insert some of the declarations they provide.
DEFAULT_GRANULARITY default: page size if MORECORE_CONTIGUOUS,
system_info.dwAllocationGranularity in WIN32,
otherwise 64K.
Also settable using mallopt(M_GRANULARITY, x)
The unit for allocating and deallocating memory from the system. On
most systems with contiguous MORECORE, there is no reason to
make this more than a page. However, systems with MMAP tend to
either require or encourage larger granularities. You can increase
this value to prevent system allocation functions to be called so
often, especially if they are slow. The value must be at least one
page and must be a power of two. Setting to 0 causes initialization
to either page size or win32 region size. (Note: In previous
versions of malloc, the equivalent of this option was called
"TOP_PAD")
DEFAULT_TRIM_THRESHOLD default: 2MB
Also settable using mallopt(M_TRIM_THRESHOLD, x)
The maximum amount of unused top-most memory to keep before
releasing via malloc_trim in free(). Automatic trimming is mainly
useful in long-lived programs using contiguous MORECORE. Because
trimming via sbrk can be slow on some systems, and can sometimes be
wasteful (in cases where programs immediately afterward allocate
more large chunks) the value should be high enough so that your
overall system performance would improve by releasing this much
memory. As a rough guide, you might set to a value close to the
average size of a process (program) running on your system.
Releasing this much memory would allow such a process to run in
memory. Generally, it is worth tuning trim thresholds when a
program undergoes phases where several large chunks are allocated
and released in ways that can reuse each other's storage, perhaps
mixed with phases where there are no such chunks at all. The trim
value must be greater than page size to have any useful effect. To
disable trimming completely, you can set to MAX_SIZE_T. Note that the trick
some people use of mallocing a huge space and then freeing it at
program startup, in an attempt to reserve system memory, doesn't
have the intended effect under automatic trimming, since that memory
will immediately be returned to the system.
DEFAULT_MMAP_THRESHOLD default: 256K
Also settable using mallopt(M_MMAP_THRESHOLD, x)
The request size threshold for using MMAP to directly service a
request. Requests of at least this size that cannot be allocated
using already-existing space will be serviced via mmap. (If enough
normal freed space already exists it is used instead.) Using mmap
segregates relatively large chunks of memory so that they can be
individually obtained and released from the host system. A request
serviced through mmap is never reused by any other request (at least
not directly; the system may just so happen to remap successive
requests to the same locations). Segregating space in this way has
the benefits that: Mmapped space can always be individually released
back to the system, which helps keep the system level memory demands
of a long-lived program low. Also, mapped memory doesn't become
`locked' between other chunks, as can happen with normally allocated
chunks, which means that even trimming via malloc_trim would not
release them. However, it has the disadvantage that the space
cannot be reclaimed, consolidated, and then used to service later
requests, as happens with normal chunks. The advantages of mmap
nearly always outweigh disadvantages for "large" chunks, but the
value of "large" may vary across systems. The default is an
empirically derived value that works well in most systems. You can
disable mmap by setting to MAX_SIZE_T.
MAX_RELEASE_CHECK_RATE default: 4095 unless not HAVE_MMAP
The number of consolidated frees between checks to release
unused segments when freeing. When using non-contiguous segments,
especially with multiple mspaces, checking only for topmost space
doesn't always suffice to trigger trimming. To compensate for this,
free() will, with a period of MAX_RELEASE_CHECK_RATE (or the
current number of segments, if greater) try to release unused
segments to the OS when freeing chunks that result in
consolidation. The best value for this parameter is a compromise
between slowing down frees with relatively costly checks that
rarely trigger versus holding on to unused memory. To effectively
disable, set to MAX_SIZE_T. This may lead to a very slight speed
improvement at the expense of carrying around more memory.
*/
#define ONLY_MSPACES 1
/* Version identifier to allow people to support multiple versions */
#ifndef DLMALLOC_VERSION
#define DLMALLOC_VERSION 20806
#endif /* DLMALLOC_VERSION */
#ifndef DLMALLOC_EXPORT
#define DLMALLOC_EXPORT extern
#endif
#ifndef WIN32
#ifdef _WIN32
#define WIN32 1
#endif /* _WIN32 */
#ifdef _WIN32_WCE
#define LACKS_FCNTL_H
#define WIN32 1
#endif /* _WIN32_WCE */
#endif /* WIN32 */
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <tchar.h>
#define HAVE_MMAP 1
#define HAVE_MORECORE 0
#define LACKS_UNISTD_H
#define LACKS_SYS_PARAM_H
#define LACKS_SYS_MMAN_H
#define LACKS_STRING_H
#define LACKS_STRINGS_H
#define LACKS_SYS_TYPES_H
#define LACKS_ERRNO_H
#define LACKS_SCHED_H
#ifndef MALLOC_FAILURE_ACTION
#define MALLOC_FAILURE_ACTION
#endif /* MALLOC_FAILURE_ACTION */
#ifndef MMAP_CLEARS
#ifdef _WIN32_WCE /* WINCE reportedly does not clear */
#define MMAP_CLEARS 0
#else
#define MMAP_CLEARS 1
#endif /* _WIN32_WCE */
#endif /*MMAP_CLEARS */
#endif /* WIN32 */
#if defined(DARWIN) || defined(_DARWIN) || defined(__MACH__) && defined(__APPLE__)
/* Mac OSX docs advise not to use sbrk; it seems better to use mmap */
#ifndef HAVE_MORECORE
#define HAVE_MORECORE 0
#define HAVE_MMAP 1
/* OSX allocators provide 16 byte alignment */
#ifndef MALLOC_ALIGNMENT
#define MALLOC_ALIGNMENT ((size_t)16U)
#endif
#endif /* HAVE_MORECORE */
#endif /* DARWIN */
#ifndef LACKS_SYS_TYPES_H
#include <sys/types.h> /* For size_t */
#endif /* LACKS_SYS_TYPES_H */
/* The maximum possible size_t value has all bits set */
#define MAX_SIZE_T (~(size_t)0)
#ifndef USE_LOCKS /* ensure true if spin or recursive locks set */
#define USE_LOCKS ((defined(USE_SPIN_LOCKS) && USE_SPIN_LOCKS != 0) || \
(defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0))
#endif /* USE_LOCKS */
#if USE_LOCKS /* Spin locks for gcc >= 4.1, older gcc on x86, MSC >= 1310 */
#if ((defined(__GNUC__) && \
((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) || \
defined(__i386__) || defined(__x86_64__))) || \
(defined(_MSC_VER) && _MSC_VER>=1310))
#ifndef USE_SPIN_LOCKS
#define USE_SPIN_LOCKS 1
#endif /* USE_SPIN_LOCKS */
#elif USE_SPIN_LOCKS
#error "USE_SPIN_LOCKS defined without implementation"
#endif /* ... locks available... */
#elif !defined(USE_SPIN_LOCKS)
#define USE_SPIN_LOCKS 0
#endif /* USE_LOCKS */
#ifndef ONLY_MSPACES
#define ONLY_MSPACES 0
#endif /* ONLY_MSPACES */
#ifndef MSPACES
#if ONLY_MSPACES
#define MSPACES 1
#else /* ONLY_MSPACES */
#define MSPACES 0
#endif /* ONLY_MSPACES */
#endif /* MSPACES */
#ifndef MALLOC_ALIGNMENT
#define MALLOC_ALIGNMENT ((size_t)(2 * sizeof(void *)))
#endif /* MALLOC_ALIGNMENT */
#ifndef FOOTERS
#define FOOTERS 0
#endif /* FOOTERS */
#ifndef ABORT
#define ABORT abort()
#endif /* ABORT */
#ifndef ABORT_ON_ASSERT_FAILURE
#define ABORT_ON_ASSERT_FAILURE 1
#endif /* ABORT_ON_ASSERT_FAILURE */
#ifndef PROCEED_ON_ERROR
#define PROCEED_ON_ERROR 0
#endif /* PROCEED_ON_ERROR */
#ifndef INSECURE
#define INSECURE 0
#endif /* INSECURE */
#ifndef MALLOC_INSPECT_ALL
#define MALLOC_INSPECT_ALL 0
#endif /* MALLOC_INSPECT_ALL */
#ifndef HAVE_MMAP
#define HAVE_MMAP 1
#endif /* HAVE_MMAP */
#ifndef MMAP_CLEARS
#define MMAP_CLEARS 1
#endif /* MMAP_CLEARS */
#ifndef HAVE_MREMAP
#ifdef linux
#define HAVE_MREMAP 1
#define _GNU_SOURCE /* Turns on mremap() definition */
#else /* linux */
#define HAVE_MREMAP 0
#endif /* linux */
#endif /* HAVE_MREMAP */
#ifndef MALLOC_FAILURE_ACTION
#define MALLOC_FAILURE_ACTION errno = ENOMEM;
#endif /* MALLOC_FAILURE_ACTION */
#ifndef HAVE_MORECORE
#if ONLY_MSPACES
#define HAVE_MORECORE 0
#else /* ONLY_MSPACES */
#define HAVE_MORECORE 1
#endif /* ONLY_MSPACES */
#endif /* HAVE_MORECORE */
#if !HAVE_MORECORE
#define MORECORE_CONTIGUOUS 0
#else /* !HAVE_MORECORE */
#define MORECORE_DEFAULT sbrk
#ifndef MORECORE_CONTIGUOUS
#define MORECORE_CONTIGUOUS 1
#endif /* MORECORE_CONTIGUOUS */
#endif /* HAVE_MORECORE */
#ifndef DEFAULT_GRANULARITY
#if (MORECORE_CONTIGUOUS || defined(WIN32))
#define DEFAULT_GRANULARITY (0) /* 0 means to compute in init_mparams */
#else /* MORECORE_CONTIGUOUS */
#define DEFAULT_GRANULARITY ((size_t)64U * (size_t)1024U)
#endif /* MORECORE_CONTIGUOUS */
#endif /* DEFAULT_GRANULARITY */
#ifndef DEFAULT_TRIM_THRESHOLD
#ifndef MORECORE_CANNOT_TRIM
#define DEFAULT_TRIM_THRESHOLD ((size_t)2U * (size_t)1024U * (size_t)1024U)
#else /* MORECORE_CANNOT_TRIM */
#define DEFAULT_TRIM_THRESHOLD MAX_SIZE_T
#endif /* MORECORE_CANNOT_TRIM */
#endif /* DEFAULT_TRIM_THRESHOLD */
#ifndef DEFAULT_MMAP_THRESHOLD
#if HAVE_MMAP
#define DEFAULT_MMAP_THRESHOLD ((size_t)256U * (size_t)1024U)
#else /* HAVE_MMAP */
#define DEFAULT_MMAP_THRESHOLD MAX_SIZE_T
#endif /* HAVE_MMAP */
#endif /* DEFAULT_MMAP_THRESHOLD */
#ifndef MAX_RELEASE_CHECK_RATE
#if HAVE_MMAP
#define MAX_RELEASE_CHECK_RATE 4095
#else
#define MAX_RELEASE_CHECK_RATE MAX_SIZE_T
#endif /* HAVE_MMAP */
#endif /* MAX_RELEASE_CHECK_RATE */
#ifndef USE_BUILTIN_FFS
#define USE_BUILTIN_FFS 0
#endif /* USE_BUILTIN_FFS */
#ifndef USE_DEV_RANDOM
#define USE_DEV_RANDOM 0
#endif /* USE_DEV_RANDOM */
#ifndef NO_MALLINFO
#define NO_MALLINFO 0
#endif /* NO_MALLINFO */
#ifndef MALLINFO_FIELD_TYPE
#define MALLINFO_FIELD_TYPE size_t
#endif /* MALLINFO_FIELD_TYPE */
#ifndef NO_MALLOC_STATS
#define NO_MALLOC_STATS 0
#endif /* NO_MALLOC_STATS */
#ifndef NO_SEGMENT_TRAVERSAL
#define NO_SEGMENT_TRAVERSAL 0
#endif /* NO_SEGMENT_TRAVERSAL */
/*
mallopt tuning options. SVID/XPG defines four standard parameter
numbers for mallopt, normally defined in malloc.h. None of these
are used in this malloc, so setting them has no effect. But this
malloc does support the following options.
*/
#define M_TRIM_THRESHOLD (-1)
#define M_GRANULARITY (-2)
#define M_MMAP_THRESHOLD (-3)
/* ------------------------ Mallinfo declarations ------------------------ */
#if !NO_MALLINFO
/*
This version of malloc supports the standard SVID/XPG mallinfo
routine that returns a struct containing usage properties and
statistics. It should work on any system that has a
/usr/include/malloc.h defining struct mallinfo. The main
declaration needed is the mallinfo struct that is returned (by-copy)
by mallinfo(). The malloinfo struct contains a bunch of fields that
are not even meaningful in this version of malloc. These fields are
are instead filled by mallinfo() with other numbers that might be of
interest.
HAVE_USR_INCLUDE_MALLOC_H should be set if you have a
/usr/include/malloc.h file that includes a declaration of struct
mallinfo. If so, it is included; else a compliant version is
declared below. These must be precisely the same for mallinfo() to
work. The original SVID version of this struct, defined on most
systems with mallinfo, declares all fields as ints. But some others
define as unsigned long. If your system defines the fields using a
type of different width than listed here, you MUST #include your
system version and #define HAVE_USR_INCLUDE_MALLOC_H.
*/
/* #define HAVE_USR_INCLUDE_MALLOC_H */
#ifdef HAVE_USR_INCLUDE_MALLOC_H
#include "/usr/include/malloc.h"
#else /* HAVE_USR_INCLUDE_MALLOC_H */
#ifndef STRUCT_MALLINFO_DECLARED
/* HP-UX (and others?) redefines mallinfo unless _STRUCT_MALLINFO is defined */
#define _STRUCT_MALLINFO
#define STRUCT_MALLINFO_DECLARED 1
struct mallinfo {
MALLINFO_FIELD_TYPE arena; /* non-mmapped space allocated from system */
MALLINFO_FIELD_TYPE ordblks; /* number of free chunks */
MALLINFO_FIELD_TYPE smblks; /* always 0 */
MALLINFO_FIELD_TYPE hblks; /* always 0 */
MALLINFO_FIELD_TYPE hblkhd; /* space in mmapped regions */
MALLINFO_FIELD_TYPE usmblks; /* maximum total allocated space */
MALLINFO_FIELD_TYPE fsmblks; /* always 0 */
MALLINFO_FIELD_TYPE uordblks; /* total allocated space */
MALLINFO_FIELD_TYPE fordblks; /* total free space */
MALLINFO_FIELD_TYPE keepcost; /* releasable (via malloc_trim) space */
};
#endif /* STRUCT_MALLINFO_DECLARED */
#endif /* HAVE_USR_INCLUDE_MALLOC_H */
#endif /* NO_MALLINFO */
/*
Try to persuade compilers to inline. The most critical functions for
inlining are defined as macros, so these aren't used for them.
*/
#ifndef FORCEINLINE
#if defined(__GNUC__)
#define FORCEINLINE __inline __attribute__ ((always_inline))
#elif defined(_MSC_VER)
#define FORCEINLINE __forceinline
#endif
#endif
#ifndef NOINLINE
#if defined(__GNUC__)
#define NOINLINE __attribute__ ((noinline))
#elif defined(_MSC_VER)
#define NOINLINE __declspec(noinline)
#else
#define NOINLINE
#endif
#endif
#ifdef __cplusplus
extern "C" {
#ifndef FORCEINLINE
#define FORCEINLINE inline
#endif
#endif /* __cplusplus */
#ifndef FORCEINLINE
#define FORCEINLINE
#endif
#if !ONLY_MSPACES
/* ------------------- Declarations of public routines ------------------- */
#ifndef USE_DL_PREFIX
#define dlcalloc calloc
#define dlfree free
#define dlmalloc malloc
#define dlmemalign memalign
#define dlposix_memalign posix_memalign
#define dlrealloc realloc
#define dlrealloc_in_place realloc_in_place
#define dlvalloc valloc
#define dlpvalloc pvalloc
#define dlmallinfo mallinfo
#define dlmallopt mallopt
#define dlmalloc_trim malloc_trim
#define dlmalloc_stats malloc_stats
#define dlmalloc_usable_size malloc_usable_size
#define dlmalloc_footprint malloc_footprint
#define dlmalloc_max_footprint malloc_max_footprint
#define dlmalloc_footprint_limit malloc_footprint_limit
#define dlmalloc_set_footprint_limit malloc_set_footprint_limit
#define dlmalloc_inspect_all malloc_inspect_all
#define dlindependent_calloc independent_calloc
#define dlindependent_comalloc independent_comalloc
#define dlbulk_free bulk_free
#endif /* USE_DL_PREFIX */
/*
malloc(size_t n)
Returns a pointer to a newly allocated chunk of at least n bytes, or
null if no space is available, in which case errno is set to ENOMEM
on ANSI C systems.
If n is zero, malloc returns a minimum-sized chunk. (The minimum
size is 16 bytes on most 32bit systems, and 32 bytes on 64bit
systems.) Note that size_t is an unsigned type, so calls with
arguments that would be negative if signed are interpreted as
requests for huge amounts of space, which will often fail. The
maximum supported value of n differs across systems, but is in all
cases less than the maximum representable value of a size_t.
*/
DLMALLOC_EXPORT void* dlmalloc(size_t);
/*
free(void* p)
Releases the chunk of memory pointed to by p, that had been previously
allocated using malloc or a related routine such as realloc.
It has no effect if p is null. If p was not malloced or already
freed, free(p) will by default cause the current program to abort.
*/
DLMALLOC_EXPORT void dlfree(void*);
/*
calloc(size_t n_elements, size_t element_size);
Returns a pointer to n_elements * element_size bytes, with all locations
set to zero.
*/
DLMALLOC_EXPORT void* dlcalloc(size_t, size_t);
/*
realloc(void* p, size_t n)
Returns a pointer to a chunk of size n that contains the same data
as does chunk p up to the minimum of (n, p's size) bytes, or null
if no space is available.
The returned pointer may or may not be the same as p. The algorithm
prefers extending p in most cases when possible, otherwise it
employs the equivalent of a malloc-copy-free sequence.
If p is null, realloc is equivalent to malloc.
If space is not available, realloc returns null, errno is set (if on
ANSI) and p is NOT freed.
if n is for fewer bytes than already held by p, the newly unused
space is lopped off and freed if possible. realloc with a size
argument of zero (re)allocates a minimum-sized chunk.
The old unix realloc convention of allowing the last-free'd chunk
to be used as an argument to realloc is not supported.
*/
DLMALLOC_EXPORT void* dlrealloc(void*, size_t);
/*
realloc_in_place(void* p, size_t n)
Resizes the space allocated for p to size n, only if this can be
done without moving p (i.e., only if there is adjacent space
available if n is greater than p's current allocated size, or n is
less than or equal to p's size). This may be used instead of plain
realloc if an alternative allocation strategy is needed upon failure
to expand space; for example, reallocation of a buffer that must be
memory-aligned or cleared. You can use realloc_in_place to trigger
these alternatives only when needed.
Returns p if successful; otherwise null.
*/
DLMALLOC_EXPORT void* dlrealloc_in_place(void*, size_t);
/*
memalign(size_t alignment, size_t n);
Returns a pointer to a newly allocated chunk of n bytes, aligned
in accord with the alignment argument.
The alignment argument should be a power of two. If the argument is
not a power of two, the nearest greater power is used.
8-byte alignment is guaranteed by normal malloc calls, so don't
bother calling memalign with an argument of 8 or less.
Overreliance on memalign is a sure way to fragment space.
*/
DLMALLOC_EXPORT void* dlmemalign(size_t, size_t);
/*
int posix_memalign(void** pp, size_t alignment, size_t n);
Allocates a chunk of n bytes, aligned in accord with the alignment
argument. Differs from memalign only in that it (1) assigns the
allocated memory to *pp rather than returning it, (2) fails and
returns EINVAL if the alignment is not a power of two (3) fails and
returns ENOMEM if memory cannot be allocated.
*/
DLMALLOC_EXPORT int dlposix_memalign(void**, size_t, size_t);
/*
valloc(size_t n);
Equivalent to memalign(pagesize, n), where pagesize is the page
size of the system. If the pagesize is unknown, 4096 is used.
*/
DLMALLOC_EXPORT void* dlvalloc(size_t);
/*
mallopt(int parameter_number, int parameter_value)
Sets tunable parameters The format is to provide a
(parameter-number, parameter-value) pair. mallopt then sets the
corresponding parameter to the argument value if it can (i.e., so
long as the value is meaningful), and returns 1 if successful else
0. To workaround the fact that mallopt is specified to use int,
not size_t parameters, the value -1 is specially treated as the
maximum unsigned size_t value.
SVID/XPG/ANSI defines four standard param numbers for mallopt,
normally defined in malloc.h. None of these are use in this malloc,
so setting them has no effect. But this malloc also supports other
options in mallopt. See below for details. Briefly, supported
parameters are as follows (listed defaults are for "typical"
configurations).
Symbol param # default allowed param values
M_TRIM_THRESHOLD -1 2*1024*1024 any (-1 disables)
M_GRANULARITY -2 page size any power of 2 >= page size
M_MMAP_THRESHOLD -3 256*1024 any (or 0 if no MMAP support)
*/
DLMALLOC_EXPORT int dlmallopt(int, int);
/*
malloc_footprint();
Returns the number of bytes obtained from the system. The total
number of bytes allocated by malloc, realloc etc., is less than this
value. Unlike mallinfo, this function returns only a precomputed
result, so can be called frequently to monitor memory consumption.
Even if locks are otherwise defined, this function does not use them,
so results might not be up to date.
*/
DLMALLOC_EXPORT size_t dlmalloc_footprint(void);
/*
malloc_max_footprint();
Returns the maximum number of bytes obtained from the system. This
value will be greater than current footprint if deallocated space
has been reclaimed by the system. The peak number of bytes allocated
by malloc, realloc etc., is less than this value. Unlike mallinfo,
this function returns only a precomputed result, so can be called
frequently to monitor memory consumption. Even if locks are
otherwise defined, this function does not use them, so results might
not be up to date.
*/
DLMALLOC_EXPORT size_t dlmalloc_max_footprint(void);
/*
malloc_footprint_limit();
Returns the number of bytes that the heap is allowed to obtain from
the system, returning the last value returned by
malloc_set_footprint_limit, or the maximum size_t value if
never set. The returned value reflects a permission. There is no
guarantee that this number of bytes can actually be obtained from
the system.
*/
DLMALLOC_EXPORT size_t dlmalloc_footprint_limit();
/*
malloc_set_footprint_limit();
Sets the maximum number of bytes to obtain from the system, causing
failure returns from malloc and related functions upon attempts to
exceed this value. The argument value may be subject to page
rounding to an enforceable limit; this actual value is returned.
Using an argument of the maximum possible size_t effectively
disables checks. If the argument is less than or equal to the
current malloc_footprint, then all future allocations that require
additional system memory will fail. However, invocation cannot
retroactively deallocate existing used memory.
*/
DLMALLOC_EXPORT size_t dlmalloc_set_footprint_limit(size_t bytes);
#if MALLOC_INSPECT_ALL
/*
malloc_inspect_all(void(*handler)(void *start,
void *end,
size_t used_bytes,
void* callback_arg),
void* arg);
Traverses the heap and calls the given handler for each managed
region, skipping all bytes that are (or may be) used for bookkeeping
purposes. Traversal does not include include chunks that have been
directly memory mapped. Each reported region begins at the start
address, and continues up to but not including the end address. The
first used_bytes of the region contain allocated data. If
used_bytes is zero, the region is unallocated. The handler is
invoked with the given callback argument. If locks are defined, they
are held during the entire traversal. It is a bad idea to invoke
other malloc functions from within the handler.
For example, to count the number of in-use chunks with size greater
than 1000, you could write:
static int count = 0;
void count_chunks(void* start, void* end, size_t used, void* arg) {
if (used >= 1000) ++count;
}
then:
malloc_inspect_all(count_chunks, NULL);
malloc_inspect_all is compiled only if MALLOC_INSPECT_ALL is defined.
*/
DLMALLOC_EXPORT void dlmalloc_inspect_all(void(*handler)(void*, void *, size_t, void*),
void* arg);
#endif /* MALLOC_INSPECT_ALL */
#if !NO_MALLINFO
/*
mallinfo()
Returns (by copy) a struct containing various summary statistics:
arena: current total non-mmapped bytes allocated from system
ordblks: the number of free chunks
smblks: always zero.
hblks: current number of mmapped regions
hblkhd: total bytes held in mmapped regions
usmblks: the maximum total allocated space. This will be greater
than current total if trimming has occurred.
fsmblks: always zero
uordblks: current total allocated space (normal or mmapped)
fordblks: total free space
keepcost: the maximum number of bytes that could ideally be released
back to system via malloc_trim. ("ideally" means that
it ignores page restrictions etc.)
Because these fields are ints, but internal bookkeeping may
be kept as longs, the reported values may wrap around zero and
thus be inaccurate.
*/
DLMALLOC_EXPORT struct mallinfo dlmallinfo(void);
#endif /* NO_MALLINFO */
/*
independent_calloc(size_t n_elements, size_t element_size, void* chunks[]);
independent_calloc is similar to calloc, but instead of returning a
single cleared space, it returns an array of pointers to n_elements
independent elements that can hold contents of size elem_size, each
of which starts out cleared, and can be independently freed,
realloc'ed etc. The elements are guaranteed to be adjacently
allocated (this is not guaranteed to occur with multiple callocs or
mallocs), which may also improve cache locality in some
applications.
The "chunks" argument is optional (i.e., may be null, which is
probably the most typical usage). If it is null, the returned array
is itself dynamically allocated and should also be freed when it is
no longer needed. Otherwise, the chunks array must be of at least
n_elements in length. It is filled in with the pointers to the
chunks.
In either case, independent_calloc returns this pointer array, or
null if the allocation failed. If n_elements is zero and "chunks"
is null, it returns a chunk representing an array with zero elements
(which should be freed if not wanted).
Each element must be freed when it is no longer needed. This can be
done all at once using bulk_free.
independent_calloc simplifies and speeds up implementations of many
kinds of pools. It may also be useful when constructing large data
structures that initially have a fixed number of fixed-sized nodes,
but the number is not known at compile time, and some of the nodes
may later need to be freed. For example:
struct Node { int item; struct Node* next; };
struct Node* build_list() {
struct Node** pool;
int n = read_number_of_nodes_needed();
if (n <= 0) return 0;
pool = (struct Node**)(independent_calloc(n, sizeof(struct Node), 0);
if (pool == 0) die();
// organize into a linked list...
struct Node* first = pool[0];
for (i = 0; i < n-1; ++i)
pool[i]->next = pool[i+1];
free(pool); // Can now free the array (or not, if it is needed later)
return first;
}
*/
DLMALLOC_EXPORT void** dlindependent_calloc(size_t, size_t, void**);
/*
independent_comalloc(size_t n_elements, size_t sizes[], void* chunks[]);
independent_comalloc allocates, all at once, a set of n_elements
chunks with sizes indicated in the "sizes" array. It returns
an array of pointers to these elements, each of which can be
independently freed, realloc'ed etc. The elements are guaranteed to
be adjacently allocated (this is not guaranteed to occur with
multiple callocs or mallocs), which may also improve cache locality
in some applications.
The "chunks" argument is optional (i.e., may be null). If it is null
the returned array is itself dynamically allocated and should also
be freed when it is no longer needed. Otherwise, the chunks array
must be of at least n_elements in length. It is filled in with the
pointers to the chunks.
In either case, independent_comalloc returns this pointer array, or
null if the allocation failed. If n_elements is zero and chunks is
null, it returns a chunk representing an array with zero elements
(which should be freed if not wanted).
Each element must be freed when it is no longer needed. This can be
done all at once using bulk_free.
independent_comallac differs from independent_calloc in that each
element may have a different size, and also that it does not
automatically clear elements.
independent_comalloc can be used to speed up allocation in cases
where several structs or objects must always be allocated at the
same time. For example:
struct Head { ... }
struct Foot { ... }
void send_message(char* msg) {
int msglen = strlen(msg);
size_t sizes[3] = { sizeof(struct Head), msglen, sizeof(struct Foot) };
void* chunks[3];
if (independent_comalloc(3, sizes, chunks) == 0)
die();
struct Head* head = (struct Head*)(chunks[0]);
char* body = (char*)(chunks[1]);
struct Foot* foot = (struct Foot*)(chunks[2]);
// ...
}
In general though, independent_comalloc is worth using only for
larger values of n_elements. For small values, you probably won't
detect enough difference from series of malloc calls to bother.
Overuse of independent_comalloc can increase overall memory usage,
since it cannot reuse existing noncontiguous small chunks that
might be available for some of the elements.
*/
DLMALLOC_EXPORT void** dlindependent_comalloc(size_t, size_t*, void**);
/*
bulk_free(void* array[], size_t n_elements)
Frees and clears (sets to null) each non-null pointer in the given
array. This is likely to be faster than freeing them one-by-one.
If footers are used, pointers that have been allocated in different
mspaces are not freed or cleared, and the count of all such pointers
is returned. For large arrays of pointers with poor locality, it
may be worthwhile to sort this array before calling bulk_free.
*/
DLMALLOC_EXPORT size_t dlbulk_free(void**, size_t n_elements);
/*
pvalloc(size_t n);
Equivalent to valloc(minimum-page-that-holds(n)), that is,
round up n to nearest pagesize.
*/
DLMALLOC_EXPORT void* dlpvalloc(size_t);
/*
malloc_trim(size_t pad);
If possible, gives memory back to the system (via negative arguments
to sbrk) if there is unused memory at the `high' end of the malloc
pool or in unused MMAP segments. You can call this after freeing
large blocks of memory to potentially reduce the system-level memory
requirements of a program. However, it cannot guarantee to reduce
memory. Under some allocation patterns, some large free blocks of
memory will be locked between two used chunks, so they cannot be
given back to the system.
The `pad' argument to malloc_trim represents the amount of free
trailing space to leave untrimmed. If this argument is zero, only
the minimum amount of memory to maintain internal data structures
will be left. Non-zero arguments can be supplied to maintain enough
trailing space to service future expected allocations without having
to re-obtain memory from the system.
Malloc_trim returns 1 if it actually released any memory, else 0.
*/
DLMALLOC_EXPORT int dlmalloc_trim(size_t);
/*
malloc_stats();
Prints on stderr the amount of space obtained from the system (both
via sbrk and mmap), the maximum amount (which may be more than
current if malloc_trim and/or munmap got called), and the current
number of bytes allocated via malloc (or realloc, etc) but not yet
freed. Note that this is the number of bytes allocated, not the
number requested. It will be larger than the number requested
because of alignment and bookkeeping overhead. Because it includes
alignment wastage as being in use, this figure may be greater than
zero even when no user-level chunks are allocated.
The reported current and maximum system memory can be inaccurate if
a program makes other calls to system memory allocation functions
(normally sbrk) outside of malloc.
malloc_stats prints only the most commonly interesting statistics.
More information can be obtained by calling mallinfo.
*/
DLMALLOC_EXPORT void dlmalloc_stats(void);
/*
malloc_usable_size(void* p);
Returns the number of bytes you can actually use in
an allocated chunk, which may be more than you requested (although
often not) due to alignment and minimum size constraints.
You can use this many bytes without worrying about
overwriting other allocated objects. This is not a particularly great
programming practice. malloc_usable_size can be more useful in
debugging and assertions, for example:
p = malloc(n);
assert(malloc_usable_size(p) >= 256);
*/
size_t dlmalloc_usable_size(void*);
#endif /* ONLY_MSPACES */
#if MSPACES
/*
mspace is an opaque type representing an independent
region of space that supports mspace_malloc, etc.
*/
typedef void* mspace;
/*
create_mspace creates and returns a new independent space with the
given initial capacity, or, if 0, the default granularity size. It
returns null if there is no system memory available to create the
space. If argument locked is non-zero, the space uses a separate
lock to control access. The capacity of the space will grow
dynamically as needed to service mspace_malloc requests. You can
control the sizes of incremental increases of this space by
compiling with a different DEFAULT_GRANULARITY or dynamically
setting with mallopt(M_GRANULARITY, value).
*/
DLMALLOC_EXPORT mspace create_mspace(size_t capacity, int locked);
/*
destroy_mspace destroys the given space, and attempts to return all
of its memory back to the system, returning the total number of
bytes freed. After destruction, the results of access to all memory
used by the space become undefined.
*/
DLMALLOC_EXPORT size_t destroy_mspace(mspace msp);
/*
create_mspace_with_base uses the memory supplied as the initial base
of a new mspace. Part (less than 128*sizeof(size_t) bytes) of this
space is used for bookkeeping, so the capacity must be at least this
large. (Otherwise 0 is returned.) When this initial space is
exhausted, additional memory will be obtained from the system.
Destroying this space will deallocate all additionally allocated
space (if possible) but not the initial base.
*/
DLMALLOC_EXPORT mspace create_mspace_with_base(void* base, size_t capacity, int locked);
/*
mspace_track_large_chunks controls whether requests for large chunks
are allocated in their own untracked mmapped regions, separate from
others in this mspace. By default large chunks are not tracked,
which reduces fragmentation. However, such chunks are not
necessarily released to the system upon destroy_mspace. Enabling
tracking by setting to true may increase fragmentation, but avoids
leakage when relying on destroy_mspace to release all memory
allocated using this space. The function returns the previous
setting.
*/
DLMALLOC_EXPORT int mspace_track_large_chunks(mspace msp, int enable);
/*
mspace_malloc behaves as malloc, but operates within
the given space.
*/
DLMALLOC_EXPORT void* mspace_malloc(mspace msp, size_t bytes);
/*
mspace_free behaves as free, but operates within
the given space.
If compiled with FOOTERS==1, mspace_free is not actually needed.
free may be called instead of mspace_free because freed chunks from
any space are handled by their originating spaces.
*/
DLMALLOC_EXPORT void mspace_free(mspace msp, void* mem);
/*
mspace_realloc behaves as realloc, but operates within
the given space.
If compiled with FOOTERS==1, mspace_realloc is not actually
needed. realloc may be called instead of mspace_realloc because
realloced chunks from any space are handled by their originating
spaces.
*/
DLMALLOC_EXPORT void* mspace_realloc(mspace msp, void* mem, size_t newsize);
/*
mspace_calloc behaves as calloc, but operates within
the given space.
*/
DLMALLOC_EXPORT void* mspace_calloc(mspace msp, size_t n_elements, size_t elem_size);
/*
mspace_memalign behaves as memalign, but operates within
the given space.
*/
DLMALLOC_EXPORT void* mspace_memalign(mspace msp, size_t alignment, size_t bytes);
/*
mspace_independent_calloc behaves as independent_calloc, but
operates within the given space.
*/
DLMALLOC_EXPORT void** mspace_independent_calloc(mspace msp, size_t n_elements,
size_t elem_size, void* chunks[]);
/*
mspace_independent_comalloc behaves as independent_comalloc, but
operates within the given space.
*/
DLMALLOC_EXPORT void** mspace_independent_comalloc(mspace msp, size_t n_elements,
size_t sizes[], void* chunks[]);
/*
mspace_footprint() returns the number of bytes obtained from the
system for this space.
*/
DLMALLOC_EXPORT size_t mspace_footprint(mspace msp);
/*
mspace_max_footprint() returns the peak number of bytes obtained from the
system for this space.
*/
DLMALLOC_EXPORT size_t mspace_max_footprint(mspace msp);
#if !NO_MALLINFO
/*
mspace_mallinfo behaves as mallinfo, but reports properties of
the given space.
*/
DLMALLOC_EXPORT struct mallinfo mspace_mallinfo(mspace msp);
#endif /* NO_MALLINFO */
/*
malloc_usable_size(void* p) behaves the same as malloc_usable_size;
*/
DLMALLOC_EXPORT size_t mspace_usable_size(const void* mem);
/*
mspace_malloc_stats behaves as malloc_stats, but reports
properties of the given space.
*/
DLMALLOC_EXPORT void mspace_malloc_stats(mspace msp);
/*
mspace_trim behaves as malloc_trim, but
operates within the given space.
*/
DLMALLOC_EXPORT int mspace_trim(mspace msp, size_t pad);
/*
An alias for mallopt.
*/
DLMALLOC_EXPORT int mspace_mallopt(int, int);
#endif /* MSPACES */
#ifdef __cplusplus
} /* end of extern "C" */
#endif /* __cplusplus */
/*
========================================================================
To make a fully customizable malloc.h header file, cut everything
above this line, put into file malloc.h, edit to suit, and #include it
on the next line, as well as in programs that use this malloc.
========================================================================
*/
/* #include "malloc.h" */
/*------------------------------ internal #includes ---------------------- */
#ifdef _MSC_VER
#pragma warning( disable : 4146 ) /* no "unsigned" warnings */
#endif /* _MSC_VER */
#if !NO_MALLOC_STATS
#include <stdio.h> /* for printing in malloc_stats */
#endif /* NO_MALLOC_STATS */
#ifndef LACKS_ERRNO_H
#include <errno.h> /* for MALLOC_FAILURE_ACTION */
#endif /* LACKS_ERRNO_H */
#ifdef DEBUG
#if ABORT_ON_ASSERT_FAILURE
#undef assert
#define assert(x) if(!(x)) ABORT
#else /* ABORT_ON_ASSERT_FAILURE */
#include <assert.h>
#endif /* ABORT_ON_ASSERT_FAILURE */
#else /* DEBUG */
#ifndef assert
#define assert(x)
#endif
#define DEBUG 0
#endif /* DEBUG */
#if !defined(WIN32) && !defined(LACKS_TIME_H)
#include <time.h> /* for magic initialization */
#endif /* WIN32 */
#ifndef LACKS_STDLIB_H
#include <stdlib.h> /* for abort() */
#endif /* LACKS_STDLIB_H */
#ifndef LACKS_STRING_H
#include <string.h> /* for memset etc */
#endif /* LACKS_STRING_H */
#if USE_BUILTIN_FFS
#ifndef LACKS_STRINGS_H
#include <strings.h> /* for ffs */
#endif /* LACKS_STRINGS_H */
#endif /* USE_BUILTIN_FFS */
#if HAVE_MMAP
#ifndef LACKS_SYS_MMAN_H
/* On some versions of linux, mremap decl in mman.h needs __USE_GNU set */
#if (defined(linux) && !defined(__USE_GNU))
#define __USE_GNU 1
#include <sys/mman.h> /* for mmap */
#undef __USE_GNU
#else
#include <sys/mman.h> /* for mmap */
#endif /* linux */
#endif /* LACKS_SYS_MMAN_H */
#ifndef LACKS_FCNTL_H
#include <fcntl.h>
#endif /* LACKS_FCNTL_H */
#endif /* HAVE_MMAP */
#ifndef LACKS_UNISTD_H
#include <unistd.h> /* for sbrk, sysconf */
#else /* LACKS_UNISTD_H */
#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__)
extern void* sbrk(ptrdiff_t);
#endif /* FreeBSD etc */
#endif /* LACKS_UNISTD_H */
/* Declarations for locking */
#if USE_LOCKS
#ifndef WIN32
#if defined (__SVR4) && defined (__sun) /* solaris */
#include <thread.h>
#elif !defined(LACKS_SCHED_H)
#include <sched.h>
#endif /* solaris or LACKS_SCHED_H */
#if (defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0) || !USE_SPIN_LOCKS
#include <pthread.h>
#endif /* USE_RECURSIVE_LOCKS ... */
#elif defined(_MSC_VER)
#ifndef _M_AMD64
/* These are already defined on AMD64 builds */
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
LONG __cdecl _InterlockedCompareExchange(LONG volatile *Dest, LONG Exchange, LONG Comp);
LONG __cdecl _InterlockedExchange(LONG volatile *Target, LONG Value);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _M_AMD64 */
#pragma intrinsic (_InterlockedCompareExchange)
#pragma intrinsic (_InterlockedExchange)
#define interlockedcompareexchange _InterlockedCompareExchange
#define interlockedexchange _InterlockedExchange
#elif defined(WIN32) && defined(__GNUC__)
#define interlockedcompareexchange(a, b, c) __sync_val_compare_and_swap(a, c, b)
#define interlockedexchange __sync_lock_test_and_set
#endif /* Win32 */
#else /* USE_LOCKS */
#endif /* USE_LOCKS */
#ifndef LOCK_AT_FORK
#define LOCK_AT_FORK 0
#endif
/* Declarations for bit scanning on win32 */
#if defined(_MSC_VER) && _MSC_VER>=1300
#ifndef BitScanForward /* Try to avoid pulling in WinNT.h */
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
unsigned char _BitScanForward(unsigned long *index, unsigned long mask);
unsigned char _BitScanReverse(unsigned long *index, unsigned long mask);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#define BitScanForward _BitScanForward
#define BitScanReverse _BitScanReverse
#pragma intrinsic(_BitScanForward)
#pragma intrinsic(_BitScanReverse)
#endif /* BitScanForward */
#endif /* defined(_MSC_VER) && _MSC_VER>=1300 */
#ifndef WIN32
#ifndef malloc_getpagesize
# ifdef _SC_PAGESIZE /* some SVR4 systems omit an underscore */
# ifndef _SC_PAGE_SIZE
# define _SC_PAGE_SIZE _SC_PAGESIZE
# endif
# endif
# ifdef _SC_PAGE_SIZE
# define malloc_getpagesize sysconf(_SC_PAGE_SIZE)
# else
# if defined(BSD) || defined(DGUX) || defined(HAVE_GETPAGESIZE)
extern size_t getpagesize();
# define malloc_getpagesize getpagesize()
# else
# ifdef WIN32 /* use supplied emulation of getpagesize */
# define malloc_getpagesize getpagesize()
# else
# ifndef LACKS_SYS_PARAM_H
# include <sys/param.h>
# endif
# ifdef EXEC_PAGESIZE
# define malloc_getpagesize EXEC_PAGESIZE
# else
# ifdef NBPG
# ifndef CLSIZE
# define malloc_getpagesize NBPG
# else
# define malloc_getpagesize (NBPG * CLSIZE)
# endif
# else
# ifdef NBPC
# define malloc_getpagesize NBPC
# else
# ifdef PAGESIZE
# define malloc_getpagesize PAGESIZE
# else /* just guess */
# define malloc_getpagesize ((size_t)4096U)
# endif
# endif
# endif
# endif
# endif
# endif
# endif
#endif
#endif
/* ------------------- size_t and alignment properties -------------------- */
/* The byte and bit size of a size_t */
#define SIZE_T_SIZE (sizeof(size_t))
#define SIZE_T_BITSIZE (sizeof(size_t) << 3)
/* Some constants coerced to size_t */
/* Annoying but necessary to avoid errors on some platforms */
#define SIZE_T_ZERO ((size_t)0)
#define SIZE_T_ONE ((size_t)1)
#define SIZE_T_TWO ((size_t)2)
#define SIZE_T_FOUR ((size_t)4)
#define TWO_SIZE_T_SIZES (SIZE_T_SIZE<<1)
#define FOUR_SIZE_T_SIZES (SIZE_T_SIZE<<2)
#define SIX_SIZE_T_SIZES (FOUR_SIZE_T_SIZES+TWO_SIZE_T_SIZES)
#define HALF_MAX_SIZE_T (MAX_SIZE_T / 2U)
/* The bit mask value corresponding to MALLOC_ALIGNMENT */
#define CHUNK_ALIGN_MASK (MALLOC_ALIGNMENT - SIZE_T_ONE)
/* True if address a has acceptable alignment */
#define is_aligned(A) (((size_t)((A)) & (CHUNK_ALIGN_MASK)) == 0)
/* the number of bytes to offset an address to align it */
#define align_offset(A)\
((((size_t)(A) & CHUNK_ALIGN_MASK) == 0)? 0 :\
((MALLOC_ALIGNMENT - ((size_t)(A) & CHUNK_ALIGN_MASK)) & CHUNK_ALIGN_MASK))
/* -------------------------- MMAP preliminaries ------------------------- */
/*
If HAVE_MORECORE or HAVE_MMAP are false, we just define calls and
checks to fail so compiler optimizer can delete code rather than
using so many "#if"s.
*/
/* MORECORE and MMAP must return MFAIL on failure */
#define MFAIL ((void*)(MAX_SIZE_T))
#define CMFAIL ((char*)(MFAIL)) /* defined for convenience */
#if HAVE_MMAP
#ifndef WIN32
#define MUNMAP_DEFAULT(a, s) munmap((a), (s))
#define MMAP_PROT (PROT_READ|PROT_WRITE)
#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)
#define MAP_ANONYMOUS MAP_ANON
#endif /* MAP_ANON */
#ifdef MAP_ANONYMOUS
#define MMAP_FLAGS (MAP_PRIVATE|MAP_ANONYMOUS)
#define MMAP_DEFAULT(s) mmap(0, (s), MMAP_PROT, MMAP_FLAGS, -1, 0)
#else /* MAP_ANONYMOUS */
/*
Nearly all versions of mmap support MAP_ANONYMOUS, so the following
is unlikely to be needed, but is supplied just in case.
*/
#define MMAP_FLAGS (MAP_PRIVATE)
static int dev_zero_fd = -1; /* Cached file descriptor for /dev/zero. */
#define MMAP_DEFAULT(s) ((dev_zero_fd < 0) ? \
(dev_zero_fd = open("/dev/zero", O_RDWR), \
mmap(0, (s), MMAP_PROT, MMAP_FLAGS, dev_zero_fd, 0)) : \
mmap(0, (s), MMAP_PROT, MMAP_FLAGS, dev_zero_fd, 0))
#endif /* MAP_ANONYMOUS */
#define DIRECT_MMAP_DEFAULT(s) MMAP_DEFAULT(s)
#else /* WIN32 */
/* Win32 MMAP via VirtualAlloc */
static FORCEINLINE void* win32mmap(size_t size) {
void* ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE);
return (ptr != 0)? ptr: MFAIL;
}
/* For direct MMAP, use MEM_TOP_DOWN to minimize interference */
static FORCEINLINE void* win32direct_mmap(size_t size) {
void* ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT|MEM_TOP_DOWN,
PAGE_READWRITE);
return (ptr != 0)? ptr: MFAIL;
}
/* This function supports releasing coalesed segments */
static FORCEINLINE int win32munmap(void* ptr, size_t size) {
MEMORY_BASIC_INFORMATION minfo;
char* cptr = (char*)ptr;
while (size) {
if (VirtualQuery(cptr, &minfo, sizeof(minfo)) == 0)
return -1;
if (minfo.BaseAddress != cptr || minfo.AllocationBase != cptr ||
minfo.State != MEM_COMMIT || minfo.RegionSize > size)
return -1;
if (VirtualFree(cptr, 0, MEM_RELEASE) == 0)
return -1;
cptr += minfo.RegionSize;
size -= minfo.RegionSize;
}
return 0;
}
#define MMAP_DEFAULT(s) win32mmap(s)
#define MUNMAP_DEFAULT(a, s) win32munmap((a), (s))
#define DIRECT_MMAP_DEFAULT(s) win32direct_mmap(s)
#endif /* WIN32 */
#endif /* HAVE_MMAP */
#if HAVE_MREMAP
#ifndef WIN32
#define MREMAP_DEFAULT(addr, osz, nsz, mv) mremap((addr), (osz), (nsz), (mv))
#endif /* WIN32 */
#endif /* HAVE_MREMAP */
/**
* Define CALL_MORECORE
*/
#if HAVE_MORECORE
#ifdef MORECORE
#define CALL_MORECORE(S) MORECORE(S)
#else /* MORECORE */
#define CALL_MORECORE(S) MORECORE_DEFAULT(S)
#endif /* MORECORE */
#else /* HAVE_MORECORE */
#define CALL_MORECORE(S) MFAIL
#endif /* HAVE_MORECORE */
/**
* Define CALL_MMAP/CALL_MUNMAP/CALL_DIRECT_MMAP
*/
#if HAVE_MMAP
#define USE_MMAP_BIT (SIZE_T_ONE)
#ifdef MMAP
#define CALL_MMAP(s) MMAP(s)
#else /* MMAP */
#define CALL_MMAP(s) MMAP_DEFAULT(s)
#endif /* MMAP */
#ifdef MUNMAP
#define CALL_MUNMAP(a, s) MUNMAP((a), (s))
#else /* MUNMAP */
#define CALL_MUNMAP(a, s) MUNMAP_DEFAULT((a), (s))
#endif /* MUNMAP */
#ifdef DIRECT_MMAP
#define CALL_DIRECT_MMAP(s) DIRECT_MMAP(s)
#else /* DIRECT_MMAP */
#define CALL_DIRECT_MMAP(s) DIRECT_MMAP_DEFAULT(s)
#endif /* DIRECT_MMAP */
#else /* HAVE_MMAP */
#define USE_MMAP_BIT (SIZE_T_ZERO)
#define MMAP(s) MFAIL
#define MUNMAP(a, s) (-1)
#define DIRECT_MMAP(s) MFAIL
#define CALL_DIRECT_MMAP(s) DIRECT_MMAP(s)
#define CALL_MMAP(s) MMAP(s)
#define CALL_MUNMAP(a, s) MUNMAP((a), (s))
#endif /* HAVE_MMAP */
/**
* Define CALL_MREMAP
*/
#if HAVE_MMAP && HAVE_MREMAP
#ifdef MREMAP
#define CALL_MREMAP(addr, osz, nsz, mv) MREMAP((addr), (osz), (nsz), (mv))
#else /* MREMAP */
#define CALL_MREMAP(addr, osz, nsz, mv) MREMAP_DEFAULT((addr), (osz), (nsz), (mv))
#endif /* MREMAP */
#else /* HAVE_MMAP && HAVE_MREMAP */
#define CALL_MREMAP(addr, osz, nsz, mv) MFAIL
#endif /* HAVE_MMAP && HAVE_MREMAP */
/* mstate bit set if continguous morecore disabled or failed */
#define USE_NONCONTIGUOUS_BIT (4U)
/* segment bit set in create_mspace_with_base */
#define EXTERN_BIT (8U)
/* --------------------------- Lock preliminaries ------------------------ */
/*
When locks are defined, there is one global lock, plus
one per-mspace lock.
The global lock_ensures that mparams.magic and other unique
mparams values are initialized only once. It also protects
sequences of calls to MORECORE. In many cases sys_alloc requires
two calls, that should not be interleaved with calls by other
threads. This does not protect against direct calls to MORECORE
by other threads not using this lock, so there is still code to
cope the best we can on interference.
Per-mspace locks surround calls to malloc, free, etc.
By default, locks are simple non-reentrant mutexes.
Because lock-protected regions generally have bounded times, it is
OK to use the supplied simple spinlocks. Spinlocks are likely to
improve performance for lightly contended applications, but worsen
performance under heavy contention.
If USE_LOCKS is > 1, the definitions of lock routines here are
bypassed, in which case you will need to define the type MLOCK_T,
and at least INITIAL_LOCK, DESTROY_LOCK, ACQUIRE_LOCK, RELEASE_LOCK
and TRY_LOCK. You must also declare a
static MLOCK_T malloc_global_mutex = { initialization values };.
*/
#if !USE_LOCKS
#define USE_LOCK_BIT (0U)
#define INITIAL_LOCK(l) (0)
#define DESTROY_LOCK(l) (0)
#define ACQUIRE_MALLOC_GLOBAL_LOCK()
#define RELEASE_MALLOC_GLOBAL_LOCK()
#else
#if USE_LOCKS > 1
/* ----------------------- User-defined locks ------------------------ */
/* Define your own lock implementation here */
/* #define INITIAL_LOCK(lk) ... */
/* #define DESTROY_LOCK(lk) ... */
/* #define ACQUIRE_LOCK(lk) ... */
/* #define RELEASE_LOCK(lk) ... */
/* #define TRY_LOCK(lk) ... */
/* static MLOCK_T malloc_global_mutex = ... */
#elif USE_SPIN_LOCKS
/* First, define CAS_LOCK and CLEAR_LOCK on ints */
/* Note CAS_LOCK defined to return 0 on success */
#if defined(__GNUC__)&& (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1))
#define CAS_LOCK(sl) __sync_lock_test_and_set(sl, 1)
#define CLEAR_LOCK(sl) __sync_lock_release(sl)
#elif (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)))
/* Custom spin locks for older gcc on x86 */
static FORCEINLINE int x86_cas_lock(int *sl) {
int ret;
int val = 1;
int cmp = 0;
__asm__ __volatile__ ("lock; cmpxchgl %1, %2"
: "=a" (ret)
: "r" (val), "m" (*(sl)), "0"(cmp)
: "memory", "cc");
return ret;
}
static FORCEINLINE void x86_clear_lock(int* sl) {
assert(*sl != 0);
int prev = 0;
int ret;
__asm__ __volatile__ ("lock; xchgl %0, %1"
: "=r" (ret)
: "m" (*(sl)), "0"(prev)
: "memory");
}
#define CAS_LOCK(sl) x86_cas_lock(sl)
#define CLEAR_LOCK(sl) x86_clear_lock(sl)
#else /* Win32 MSC */
#define CAS_LOCK(sl) interlockedexchange(sl, (LONG)1)
#define CLEAR_LOCK(sl) interlockedexchange (sl, (LONG)0)
#endif /* ... gcc spins locks ... */
/* How to yield for a spin lock */
#define SPINS_PER_YIELD 63
#if defined(_MSC_VER)
#define SLEEP_EX_DURATION 50 /* delay for yield/sleep */
#define SPIN_LOCK_YIELD SleepEx(SLEEP_EX_DURATION, FALSE)
#elif defined (__SVR4) && defined (__sun) /* solaris */
#define SPIN_LOCK_YIELD thr_yield();
#elif !defined(LACKS_SCHED_H)
#define SPIN_LOCK_YIELD sched_yield();
#else
#define SPIN_LOCK_YIELD
#endif /* ... yield ... */
#if !defined(USE_RECURSIVE_LOCKS) || USE_RECURSIVE_LOCKS == 0
/* Plain spin locks use single word (embedded in malloc_states) */
static int spin_acquire_lock(int *sl) {
int spins = 0;
while (*(volatile int *)sl != 0 || CAS_LOCK(sl)) {
if ((++spins & SPINS_PER_YIELD) == 0) {
SPIN_LOCK_YIELD;
}
}
return 0;
}
#define MLOCK_T int
#define TRY_LOCK(sl) !CAS_LOCK(sl)
#define RELEASE_LOCK(sl) CLEAR_LOCK(sl)
#define ACQUIRE_LOCK(sl) (CAS_LOCK(sl)? spin_acquire_lock(sl) : 0)
#define INITIAL_LOCK(sl) (*sl = 0)
#define DESTROY_LOCK(sl) (0)
static MLOCK_T malloc_global_mutex = 0;
#else /* USE_RECURSIVE_LOCKS */
/* types for lock owners */
#ifdef WIN32
#define THREAD_ID_T DWORD
#define CURRENT_THREAD GetCurrentThreadId()
#define EQ_OWNER(X,Y) ((X) == (Y))
#else
/*
Note: the following assume that pthread_t is a type that can be
initialized to (casted) zero. If this is not the case, you will need to
somehow redefine these or not use spin locks.
*/
#define THREAD_ID_T pthread_t
#define CURRENT_THREAD pthread_self()
#define EQ_OWNER(X,Y) pthread_equal(X, Y)
#endif
struct malloc_recursive_lock {
int sl;
unsigned int c;
THREAD_ID_T threadid;
};
#define MLOCK_T struct malloc_recursive_lock
static MLOCK_T malloc_global_mutex = { 0, 0, (THREAD_ID_T)0};
static FORCEINLINE void recursive_release_lock(MLOCK_T *lk) {
assert(lk->sl != 0);
if (--lk->c == 0) {
CLEAR_LOCK(&lk->sl);
}
}
static FORCEINLINE int recursive_acquire_lock(MLOCK_T *lk) {
THREAD_ID_T mythreadid = CURRENT_THREAD;
int spins = 0;
for (;;) {
if (*((volatile int *)(&lk->sl)) == 0) {
if (!CAS_LOCK(&lk->sl)) {
lk->threadid = mythreadid;
lk->c = 1;
return 0;
}
}
else if (EQ_OWNER(lk->threadid, mythreadid)) {
++lk->c;
return 0;
}
if ((++spins & SPINS_PER_YIELD) == 0) {
SPIN_LOCK_YIELD;
}
}
}
static FORCEINLINE int recursive_try_lock(MLOCK_T *lk) {
THREAD_ID_T mythreadid = CURRENT_THREAD;
if (*((volatile int *)(&lk->sl)) == 0) {
if (!CAS_LOCK(&lk->sl)) {
lk->threadid = mythreadid;
lk->c = 1;
return 1;
}
}
else if (EQ_OWNER(lk->threadid, mythreadid)) {
++lk->c;
return 1;
}
return 0;
}
#define RELEASE_LOCK(lk) recursive_release_lock(lk)
#define TRY_LOCK(lk) recursive_try_lock(lk)
#define ACQUIRE_LOCK(lk) recursive_acquire_lock(lk)
#define INITIAL_LOCK(lk) ((lk)->threadid = (THREAD_ID_T)0, (lk)->sl = 0, (lk)->c = 0)
#define DESTROY_LOCK(lk) (0)
#endif /* USE_RECURSIVE_LOCKS */
#elif defined(WIN32) /* Win32 critical sections */
#define MLOCK_T CRITICAL_SECTION
#define ACQUIRE_LOCK(lk) (EnterCriticalSection(lk), 0)
#define RELEASE_LOCK(lk) LeaveCriticalSection(lk)
#define TRY_LOCK(lk) TryEnterCriticalSection(lk)
#define INITIAL_LOCK(lk) (!InitializeCriticalSectionAndSpinCount((lk), 0x80000000|4000))
#define DESTROY_LOCK(lk) (DeleteCriticalSection(lk), 0)
#define NEED_GLOBAL_LOCK_INIT
static MLOCK_T malloc_global_mutex;
static volatile LONG malloc_global_mutex_status;
/* Use spin loop to initialize global lock */
static void init_malloc_global_mutex() {
for (;;) {
long stat = malloc_global_mutex_status;
if (stat > 0)
return;
/* transition to < 0 while initializing, then to > 0) */
if (stat == 0 &&
interlockedcompareexchange(&malloc_global_mutex_status, (LONG)-1, (LONG)0) == 0) {
InitializeCriticalSection(&malloc_global_mutex);
interlockedexchange(&malloc_global_mutex_status, (LONG)1);
return;
}
SleepEx(0, FALSE);
}
}
#else /* pthreads-based locks */
#define MLOCK_T pthread_mutex_t
#define ACQUIRE_LOCK(lk) pthread_mutex_lock(lk)
#define RELEASE_LOCK(lk) pthread_mutex_unlock(lk)
#define TRY_LOCK(lk) (!pthread_mutex_trylock(lk))
#define INITIAL_LOCK(lk) pthread_init_lock(lk)
#define DESTROY_LOCK(lk) pthread_mutex_destroy(lk)
#if defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0 && defined(linux) && !defined(PTHREAD_MUTEX_RECURSIVE)
/* Cope with old-style linux recursive lock initialization by adding */
/* skipped internal declaration from pthread.h */
extern int pthread_mutexattr_setkind_np __P ((pthread_mutexattr_t *__attr,
int __kind));
#define PTHREAD_MUTEX_RECURSIVE PTHREAD_MUTEX_RECURSIVE_NP
#define pthread_mutexattr_settype(x,y) pthread_mutexattr_setkind_np(x,y)
#endif /* USE_RECURSIVE_LOCKS ... */
static MLOCK_T malloc_global_mutex = PTHREAD_MUTEX_INITIALIZER;
static int pthread_init_lock (MLOCK_T *lk) {
pthread_mutexattr_t attr;
if (pthread_mutexattr_init(&attr)) return 1;
#if defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0
if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE)) return 1;
#endif
if (pthread_mutex_init(lk, &attr)) return 1;
if (pthread_mutexattr_destroy(&attr)) return 1;
return 0;
}
#endif /* ... lock types ... */
/* Common code for all lock types */
#define USE_LOCK_BIT (2U)
#ifndef ACQUIRE_MALLOC_GLOBAL_LOCK
#define ACQUIRE_MALLOC_GLOBAL_LOCK() ACQUIRE_LOCK(&malloc_global_mutex);
#endif
#ifndef RELEASE_MALLOC_GLOBAL_LOCK
#define RELEASE_MALLOC_GLOBAL_LOCK() RELEASE_LOCK(&malloc_global_mutex);
#endif
#endif /* USE_LOCKS */
/* ----------------------- Chunk representations ------------------------ */
/*
(The following includes lightly edited explanations by Colin Plumb.)
The malloc_chunk declaration below is misleading (but accurate and
necessary). It declares a "view" into memory allowing access to
necessary fields at known offsets from a given base.
Chunks of memory are maintained using a `boundary tag' method as
originally described by Knuth. (See the paper by Paul Wilson
ftp://ftp.cs.utexas.edu/pub/garbage/allocsrv.ps for a survey of such
techniques.) Sizes of free chunks are stored both in the front of
each chunk and at the end. This makes consolidating fragmented
chunks into bigger chunks fast. The head fields also hold bits
representing whether chunks are free or in use.
Here are some pictures to make it clearer. They are "exploded" to
show that the state of a chunk can be thought of as extending from
the high 31 bits of the head field of its header through the
prev_foot and PINUSE_BIT bit of the following chunk header.
A chunk that's in use looks like:
chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Size of previous chunk (if P = 0) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |P|
| Size of this chunk 1| +-+
mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
+- -+
| |
+- -+
| :
+- size - sizeof(size_t) available payload bytes -+
: |
chunk-> +- -+
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |1|
| Size of next chunk (may or may not be in use) | +-+
mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
And if it's free, it looks like this:
chunk-> +- -+
| User payload (must be in use, or we would have merged!) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |P|
| Size of this chunk 0| +-+
mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Next pointer |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Prev pointer |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| :
+- size - sizeof(struct chunk) unused bytes -+
: |
chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Size of this chunk |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |0|
| Size of next chunk (must be in use, or we would have merged)| +-+
mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| :
+- User payload -+
: |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|0|
+-+
Note that since we always merge adjacent free chunks, the chunks
adjacent to a free chunk must be in use.
Given a pointer to a chunk (which can be derived trivially from the
payload pointer) we can, in O(1) time, find out whether the adjacent
chunks are free, and if so, unlink them from the lists that they
are on and merge them with the current chunk.
Chunks always begin on even word boundaries, so the mem portion
(which is returned to the user) is also on an even word boundary, and
thus at least double-word aligned.
The P (PINUSE_BIT) bit, stored in the unused low-order bit of the
chunk size (which is always a multiple of two words), is an in-use
bit for the *previous* chunk. If that bit is *clear*, then the
word before the current chunk size contains the previous chunk
size, and can be used to find the front of the previous chunk.
The very first chunk allocated always has this bit set, preventing
access to non-existent (or non-owned) memory. If pinuse is set for
any given chunk, then you CANNOT determine the size of the
previous chunk, and might even get a memory addressing fault when
trying to do so.
The C (CINUSE_BIT) bit, stored in the unused second-lowest bit of
the chunk size redundantly records whether the current chunk is
inuse (unless the chunk is mmapped). This redundancy enables usage
checks within free and realloc, and reduces indirection when freeing
and consolidating chunks.
Each freshly allocated chunk must have both cinuse and pinuse set.
That is, each allocated chunk borders either a previously allocated
and still in-use chunk, or the base of its memory arena. This is
ensured by making all allocations from the `lowest' part of any
found chunk. Further, no free chunk physically borders another one,
so each free chunk is known to be preceded and followed by either
inuse chunks or the ends of memory.
Note that the `foot' of the current chunk is actually represented
as the prev_foot of the NEXT chunk. This makes it easier to
deal with alignments etc but can be very confusing when trying
to extend or adapt this code.
The exceptions to all this are
1. The special chunk `top' is the top-most available chunk (i.e.,
the one bordering the end of available memory). It is treated
specially. Top is never included in any bin, is used only if
no other chunk is available, and is released back to the
system if it is very large (see M_TRIM_THRESHOLD). In effect,
the top chunk is treated as larger (and thus less well
fitting) than any other available chunk. The top chunk
doesn't update its trailing size field since there is no next
contiguous chunk that would have to index off it. However,
space is still allocated for it (TOP_FOOT_SIZE) to enable
separation or merging when space is extended.
3. Chunks allocated via mmap, have both cinuse and pinuse bits
cleared in their head fields. Because they are allocated
one-by-one, each must carry its own prev_foot field, which is
also used to hold the offset this chunk has within its mmapped
region, which is needed to preserve alignment. Each mmapped
chunk is trailed by the first two fields of a fake next-chunk
for sake of usage checks.
*/
struct malloc_chunk {
size_t prev_foot; /* Size of previous chunk (if free). */
size_t head; /* Size and inuse bits. */
struct malloc_chunk* fd; /* double links -- used only if free. */
struct malloc_chunk* bk;
};
typedef struct malloc_chunk mchunk;
typedef struct malloc_chunk* mchunkptr;
typedef struct malloc_chunk* sbinptr; /* The type of bins of chunks */
typedef unsigned int bindex_t; /* Described below */
typedef unsigned int binmap_t; /* Described below */
typedef unsigned int flag_t; /* The type of various bit flag sets */
/* ------------------- Chunks sizes and alignments ----------------------- */
#define MCHUNK_SIZE (sizeof(mchunk))
#if FOOTERS
#define CHUNK_OVERHEAD (TWO_SIZE_T_SIZES)
#else /* FOOTERS */
#define CHUNK_OVERHEAD (SIZE_T_SIZE)
#endif /* FOOTERS */
/* MMapped chunks need a second word of overhead ... */
#define MMAP_CHUNK_OVERHEAD (TWO_SIZE_T_SIZES)
/* ... and additional padding for fake next-chunk at foot */
#define MMAP_FOOT_PAD (FOUR_SIZE_T_SIZES)
/* The smallest size we can malloc is an aligned minimal chunk */
#define MIN_CHUNK_SIZE\
((MCHUNK_SIZE + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK)
/* conversion from malloc headers to user pointers, and back */
#define chunk2mem(p) ((void*)((char*)(p) + TWO_SIZE_T_SIZES))
#define mem2chunk(mem) ((mchunkptr)((char*)(mem) - TWO_SIZE_T_SIZES))
/* chunk associated with aligned address A */
#define align_as_chunk(A) (mchunkptr)((A) + align_offset(chunk2mem(A)))
/* Bounds on request (not chunk) sizes. */
#define MAX_REQUEST ((-MIN_CHUNK_SIZE) << 2)
#define MIN_REQUEST (MIN_CHUNK_SIZE - CHUNK_OVERHEAD - SIZE_T_ONE)
/* pad request bytes into a usable size */
#define pad_request(req) \
(((req) + CHUNK_OVERHEAD + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK)
/* pad request, checking for minimum (but not maximum) */
#define request2size(req) \
(((req) < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(req))
/* ------------------ Operations on head and foot fields ----------------- */
/*
The head field of a chunk is or'ed with PINUSE_BIT when previous
adjacent chunk in use, and or'ed with CINUSE_BIT if this chunk is in
use, unless mmapped, in which case both bits are cleared.
FLAG4_BIT is not used by this malloc, but might be useful in extensions.
*/
#define PINUSE_BIT (SIZE_T_ONE)
#define CINUSE_BIT (SIZE_T_TWO)
#define FLAG4_BIT (SIZE_T_FOUR)
#define INUSE_BITS (PINUSE_BIT|CINUSE_BIT)
#define FLAG_BITS (PINUSE_BIT|CINUSE_BIT|FLAG4_BIT)
/* Head value for fenceposts */
#define FENCEPOST_HEAD (INUSE_BITS|SIZE_T_SIZE)
/* extraction of fields from head words */
#define cinuse(p) ((p)->head & CINUSE_BIT)
#define pinuse(p) ((p)->head & PINUSE_BIT)
#define flag4inuse(p) ((p)->head & FLAG4_BIT)
#define is_inuse(p) (((p)->head & INUSE_BITS) != PINUSE_BIT)
#define is_mmapped(p) (((p)->head & INUSE_BITS) == 0)
#define chunksize(p) ((p)->head & ~(FLAG_BITS))
#define clear_pinuse(p) ((p)->head &= ~PINUSE_BIT)
#define set_flag4(p) ((p)->head |= FLAG4_BIT)
#define clear_flag4(p) ((p)->head &= ~FLAG4_BIT)
/* Treat space at ptr +/- offset as a chunk */
#define chunk_plus_offset(p, s) ((mchunkptr)(((char*)(p)) + (s)))
#define chunk_minus_offset(p, s) ((mchunkptr)(((char*)(p)) - (s)))
/* Ptr to next or previous physical malloc_chunk. */
#define next_chunk(p) ((mchunkptr)( ((char*)(p)) + ((p)->head & ~FLAG_BITS)))
#define prev_chunk(p) ((mchunkptr)( ((char*)(p)) - ((p)->prev_foot) ))
/* extract next chunk's pinuse bit */
#define next_pinuse(p) ((next_chunk(p)->head) & PINUSE_BIT)
/* Get/set size at footer */
#define get_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_foot)
#define set_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_foot = (s))
/* Set size, pinuse bit, and foot */
#define set_size_and_pinuse_of_free_chunk(p, s)\
((p)->head = (s|PINUSE_BIT), set_foot(p, s))
/* Set size, pinuse bit, foot, and clear next pinuse */
#define set_free_with_pinuse(p, s, n)\
(clear_pinuse(n), set_size_and_pinuse_of_free_chunk(p, s))
/* Get the internal overhead associated with chunk p */
#define overhead_for(p)\
(is_mmapped(p)? MMAP_CHUNK_OVERHEAD : CHUNK_OVERHEAD)
/* Return true if malloced space is not necessarily cleared */
#if MMAP_CLEARS
#define calloc_must_clear(p) (!is_mmapped(p))
#else /* MMAP_CLEARS */
#define calloc_must_clear(p) (1)
#endif /* MMAP_CLEARS */
/* ---------------------- Overlaid data structures ----------------------- */
/*
When chunks are not in use, they are treated as nodes of either
lists or trees.
"Small" chunks are stored in circular doubly-linked lists, and look
like this:
chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Size of previous chunk |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
`head:' | Size of chunk, in bytes |P|
mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Forward pointer to next chunk in list |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Back pointer to previous chunk in list |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Unused space (may be 0 bytes long) .
. .
. |
nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
`foot:' | Size of chunk, in bytes |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Larger chunks are kept in a form of bitwise digital trees (aka
tries) keyed on chunksizes. Because malloc_tree_chunks are only for
free chunks greater than 256 bytes, their size doesn't impose any
constraints on user chunk sizes. Each node looks like:
chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Size of previous chunk |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
`head:' | Size of chunk, in bytes |P|
mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Forward pointer to next chunk of same size |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Back pointer to previous chunk of same size |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Pointer to left child (child[0]) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Pointer to right child (child[1]) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Pointer to parent |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| bin index of this chunk |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Unused space .
. |
nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
`foot:' | Size of chunk, in bytes |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Each tree holding treenodes is a tree of unique chunk sizes. Chunks
of the same size are arranged in a circularly-linked list, with only
the oldest chunk (the next to be used, in our FIFO ordering)
actually in the tree. (Tree members are distinguished by a non-null
parent pointer.) If a chunk with the same size an an existing node
is inserted, it is linked off the existing node using pointers that
work in the same way as fd/bk pointers of small chunks.
Each tree contains a power of 2 sized range of chunk sizes (the
smallest is 0x100 <= x < 0x180), which is is divided in half at each
tree level, with the chunks in the smaller half of the range (0x100
<= x < 0x140 for the top nose) in the left subtree and the larger
half (0x140 <= x < 0x180) in the right subtree. This is, of course,
done by inspecting individual bits.
Using these rules, each node's left subtree contains all smaller
sizes than its right subtree. However, the node at the root of each
subtree has no particular ordering relationship to either. (The
dividing line between the subtree sizes is based on trie relation.)
If we remove the last chunk of a given size from the interior of the
tree, we need to replace it with a leaf node. The tree ordering
rules permit a node to be replaced by any leaf below it.
The smallest chunk in a tree (a common operation in a best-fit
allocator) can be found by walking a path to the leftmost leaf in
the tree. Unlike a usual binary tree, where we follow left child
pointers until we reach a null, here we follow the right child
pointer any time the left one is null, until we reach a leaf with
both child pointers null. The smallest chunk in the tree will be
somewhere along that path.
The worst case number of steps to add, find, or remove a node is
bounded by the number of bits differentiating chunks within
bins. Under current bin calculations, this ranges from 6 up to 21
(for 32 bit sizes) or up to 53 (for 64 bit sizes). The typical case
is of course much better.
*/
struct malloc_tree_chunk {
/* The first four fields must be compatible with malloc_chunk */
size_t prev_foot;
size_t head;
struct malloc_tree_chunk* fd;
struct malloc_tree_chunk* bk;
struct malloc_tree_chunk* child[2];
struct malloc_tree_chunk* parent;
bindex_t index;
};
typedef struct malloc_tree_chunk tchunk;
typedef struct malloc_tree_chunk* tchunkptr;
typedef struct malloc_tree_chunk* tbinptr; /* The type of bins of trees */
/* A little helper macro for trees */
#define leftmost_child(t) ((t)->child[0] != 0? (t)->child[0] : (t)->child[1])
/* ----------------------------- Segments -------------------------------- */
/*
Each malloc space may include non-contiguous segments, held in a
list headed by an embedded malloc_segment record representing the
top-most space. Segments also include flags holding properties of
the space. Large chunks that are directly allocated by mmap are not
included in this list. They are instead independently created and
destroyed without otherwise keeping track of them.
Segment management mainly comes into play for spaces allocated by
MMAP. Any call to MMAP might or might not return memory that is
adjacent to an existing segment. MORECORE normally contiguously
extends the current space, so this space is almost always adjacent,
which is simpler and faster to deal with. (This is why MORECORE is
used preferentially to MMAP when both are available -- see
sys_alloc.) When allocating using MMAP, we don't use any of the
hinting mechanisms (inconsistently) supported in various
implementations of unix mmap, or distinguish reserving from
committing memory. Instead, we just ask for space, and exploit
contiguity when we get it. It is probably possible to do
better than this on some systems, but no general scheme seems
to be significantly better.
Management entails a simpler variant of the consolidation scheme
used for chunks to reduce fragmentation -- new adjacent memory is
normally prepended or appended to an existing segment. However,
there are limitations compared to chunk consolidation that mostly
reflect the fact that segment processing is relatively infrequent
(occurring only when getting memory from system) and that we
don't expect to have huge numbers of segments:
* Segments are not indexed, so traversal requires linear scans. (It
would be possible to index these, but is not worth the extra
overhead and complexity for most programs on most platforms.)
* New segments are only appended to old ones when holding top-most
memory; if they cannot be prepended to others, they are held in
different segments.
Except for the top-most segment of an mstate, each segment record
is kept at the tail of its segment. Segments are added by pushing
segment records onto the list headed by &mstate.seg for the
containing mstate.
Segment flags control allocation/merge/deallocation policies:
* If EXTERN_BIT set, then we did not allocate this segment,
and so should not try to deallocate or merge with others.
(This currently holds only for the initial segment passed
into create_mspace_with_base.)
* If USE_MMAP_BIT set, the segment may be merged with
other surrounding mmapped segments and trimmed/de-allocated
using munmap.
* If neither bit is set, then the segment was obtained using
MORECORE so can be merged with surrounding MORECORE'd segments
and deallocated/trimmed using MORECORE with negative arguments.
*/
struct malloc_segment {
char* base; /* base address */
size_t size; /* allocated size */
struct malloc_segment* next; /* ptr to next segment */
flag_t sflags; /* mmap and extern flag */
};
#define is_mmapped_segment(S) ((S)->sflags & USE_MMAP_BIT)
#define is_extern_segment(S) ((S)->sflags & EXTERN_BIT)
typedef struct malloc_segment msegment;
typedef struct malloc_segment* msegmentptr;
/* ---------------------------- malloc_state ----------------------------- */
/*
A malloc_state holds all of the bookkeeping for a space.
The main fields are:
Top
The topmost chunk of the currently active segment. Its size is
cached in topsize. The actual size of topmost space is
topsize+TOP_FOOT_SIZE, which includes space reserved for adding
fenceposts and segment records if necessary when getting more
space from the system. The size at which to autotrim top is
cached from mparams in trim_check, except that it is disabled if
an autotrim fails.
Designated victim (dv)
This is the preferred chunk for servicing small requests that
don't have exact fits. It is normally the chunk split off most
recently to service another small request. Its size is cached in
dvsize. The link fields of this chunk are not maintained since it
is not kept in a bin.
SmallBins
An array of bin headers for free chunks. These bins hold chunks
with sizes less than MIN_LARGE_SIZE bytes. Each bin contains
chunks of all the same size, spaced 8 bytes apart. To simplify
use in double-linked lists, each bin header acts as a malloc_chunk
pointing to the real first node, if it exists (else pointing to
itself). This avoids special-casing for headers. But to avoid
waste, we allocate only the fd/bk pointers of bins, and then use
repositioning tricks to treat these as the fields of a chunk.
TreeBins
Treebins are pointers to the roots of trees holding a range of
sizes. There are 2 equally spaced treebins for each power of two
from TREE_SHIFT to TREE_SHIFT+16. The last bin holds anything
larger.
Bin maps
There is one bit map for small bins ("smallmap") and one for
treebins ("treemap). Each bin sets its bit when non-empty, and
clears the bit when empty. Bit operations are then used to avoid
bin-by-bin searching -- nearly all "search" is done without ever
looking at bins that won't be selected. The bit maps
conservatively use 32 bits per map word, even if on 64bit system.
For a good description of some of the bit-based techniques used
here, see Henry S. Warren Jr's book "Hacker's Delight" (and
supplement at http://hackersdelight.org/). Many of these are
intended to reduce the branchiness of paths through malloc etc, as
well as to reduce the number of memory locations read or written.
Segments
A list of segments headed by an embedded malloc_segment record
representing the initial space.
Address check support
The least_addr field is the least address ever obtained from
MORECORE or MMAP. Attempted frees and reallocs of any address less
than this are trapped (unless INSECURE is defined).
Magic tag
A cross-check field that should always hold same value as mparams.magic.
Max allowed footprint
The maximum allowed bytes to allocate from system (zero means no limit)
Flags
Bits recording whether to use MMAP, locks, or contiguous MORECORE
Statistics
Each space keeps track of current and maximum system memory
obtained via MORECORE or MMAP.
Trim support
Fields holding the amount of unused topmost memory that should trigger
trimming, and a counter to force periodic scanning to release unused
non-topmost segments.
Locking
If USE_LOCKS is defined, the "mutex" lock is acquired and released
around every public call using this mspace.
Extension support
A void* pointer and a size_t field that can be used to help implement
extensions to this malloc.
*/
/* Bin types, widths and sizes */
#define NSMALLBINS (32U)
#define NTREEBINS (32U)
#define SMALLBIN_SHIFT (3U)
#define SMALLBIN_WIDTH (SIZE_T_ONE << SMALLBIN_SHIFT)
#define TREEBIN_SHIFT (8U)
#define MIN_LARGE_SIZE (SIZE_T_ONE << TREEBIN_SHIFT)
#define MAX_SMALL_SIZE (MIN_LARGE_SIZE - SIZE_T_ONE)
#define MAX_SMALL_REQUEST (MAX_SMALL_SIZE - CHUNK_ALIGN_MASK - CHUNK_OVERHEAD)
struct malloc_state {
binmap_t smallmap;
binmap_t treemap;
size_t dvsize;
size_t topsize;
char* least_addr;
mchunkptr dv;
mchunkptr top;
size_t trim_check;
size_t release_checks;
size_t magic;
mchunkptr smallbins[(NSMALLBINS+1)*2];
tbinptr treebins[NTREEBINS];
size_t footprint;
size_t max_footprint;
size_t footprint_limit; /* zero means no limit */
flag_t mflags;
#if USE_LOCKS
MLOCK_T mutex; /* locate lock among fields that rarely change */
#endif /* USE_LOCKS */
msegment seg;
void* extp; /* Unused but available for extensions */
size_t exts;
};
typedef struct malloc_state* mstate;
/* ------------- Global malloc_state and malloc_params ------------------- */
/*
malloc_params holds global properties, including those that can be
dynamically set using mallopt. There is a single instance, mparams,
initialized in init_mparams. Note that the non-zeroness of "magic"
also serves as an initialization flag.
*/
struct malloc_params {
size_t magic;
size_t page_size;
size_t granularity;
size_t mmap_threshold;
size_t trim_threshold;
flag_t default_mflags;
};
static struct malloc_params mparams;
/* Ensure mparams initialized */
#define ensure_initialization() (void)(mparams.magic != 0 || init_mparams())
#if !ONLY_MSPACES
/* The global malloc_state used for all non-"mspace" calls */
static struct malloc_state _gm_;
#define gm (&_gm_)
#define is_global(M) ((M) == &_gm_)
#endif /* !ONLY_MSPACES */
#define is_initialized(M) ((M)->top != 0)
/* -------------------------- system alloc setup ------------------------- */
/* Operations on mflags */
#define use_lock(M) ((M)->mflags & USE_LOCK_BIT)
#define enable_lock(M) ((M)->mflags |= USE_LOCK_BIT)
#if USE_LOCKS
#define disable_lock(M) ((M)->mflags &= ~USE_LOCK_BIT)
#else
#define disable_lock(M)
#endif
#define use_mmap(M) ((M)->mflags & USE_MMAP_BIT)
#define enable_mmap(M) ((M)->mflags |= USE_MMAP_BIT)
#if HAVE_MMAP
#define disable_mmap(M) ((M)->mflags &= ~USE_MMAP_BIT)
#else
#define disable_mmap(M)
#endif
#define use_noncontiguous(M) ((M)->mflags & USE_NONCONTIGUOUS_BIT)
#define disable_contiguous(M) ((M)->mflags |= USE_NONCONTIGUOUS_BIT)
#define set_lock(M,L)\
((M)->mflags = (L)?\
((M)->mflags | USE_LOCK_BIT) :\
((M)->mflags & ~USE_LOCK_BIT))
/* page-align a size */
#define page_align(S)\
(((S) + (mparams.page_size - SIZE_T_ONE)) & ~(mparams.page_size - SIZE_T_ONE))
/* granularity-align a size */
#define granularity_align(S)\
(((S) + (mparams.granularity - SIZE_T_ONE))\
& ~(mparams.granularity - SIZE_T_ONE))
/* For mmap, use granularity alignment on windows, else page-align */
#ifdef WIN32
#define mmap_align(S) granularity_align(S)
#else
#define mmap_align(S) page_align(S)
#endif
/* For sys_alloc, enough padding to ensure can malloc request on success */
#define SYS_ALLOC_PADDING (TOP_FOOT_SIZE + MALLOC_ALIGNMENT)
#define is_page_aligned(S)\
(((size_t)(S) & (mparams.page_size - SIZE_T_ONE)) == 0)
#define is_granularity_aligned(S)\
(((size_t)(S) & (mparams.granularity - SIZE_T_ONE)) == 0)
/* True if segment S holds address A */
#define segment_holds(S, A)\
((char*)(A) >= S->base && (char*)(A) < S->base + S->size)
/* Return segment holding given address */
static msegmentptr segment_holding(mstate m, char* addr) {
msegmentptr sp = &m->seg;
for (;;) {
if (addr >= sp->base && addr < sp->base + sp->size)
return sp;
if ((sp = sp->next) == 0)
return 0;
}
}
/* Return true if segment contains a segment link */
static int has_segment_link(mstate m, msegmentptr ss) {
msegmentptr sp = &m->seg;
for (;;) {
if ((char*)sp >= ss->base && (char*)sp < ss->base + ss->size)
return 1;
if ((sp = sp->next) == 0)
return 0;
}
}
#ifndef MORECORE_CANNOT_TRIM
#define should_trim(M,s) ((s) > (M)->trim_check)
#else /* MORECORE_CANNOT_TRIM */
#define should_trim(M,s) (0)
#endif /* MORECORE_CANNOT_TRIM */
/*
TOP_FOOT_SIZE is padding at the end of a segment, including space
that may be needed to place segment records and fenceposts when new
noncontiguous segments are added.
*/
#define TOP_FOOT_SIZE\
(align_offset(chunk2mem(0))+pad_request(sizeof(struct malloc_segment))+MIN_CHUNK_SIZE)
/* ------------------------------- Hooks -------------------------------- */
/*
PREACTION should be defined to return 0 on success, and nonzero on
failure. If you are not using locking, you can redefine these to do
anything you like.
*/
#if USE_LOCKS
#define PREACTION(M) ((use_lock(M))? ACQUIRE_LOCK(&(M)->mutex) : 0)
#define POSTACTION(M) { if (use_lock(M)) RELEASE_LOCK(&(M)->mutex); }
#else /* USE_LOCKS */
#ifndef PREACTION
#define PREACTION(M) (0)
#endif /* PREACTION */
#ifndef POSTACTION
#define POSTACTION(M)
#endif /* POSTACTION */
#endif /* USE_LOCKS */
/*
CORRUPTION_ERROR_ACTION is triggered upon detected bad addresses.
USAGE_ERROR_ACTION is triggered on detected bad frees and
reallocs. The argument p is an address that might have triggered the
fault. It is ignored by the two predefined actions, but might be
useful in custom actions that try to help diagnose errors.
*/
#if PROCEED_ON_ERROR
/* A count of the number of corruption errors causing resets */
int malloc_corruption_error_count;
/* default corruption action */
static void reset_on_error(mstate m);
#define CORRUPTION_ERROR_ACTION(m) reset_on_error(m)
#define USAGE_ERROR_ACTION(m, p)
#else /* PROCEED_ON_ERROR */
#ifndef CORRUPTION_ERROR_ACTION
#define CORRUPTION_ERROR_ACTION(m) ABORT
#endif /* CORRUPTION_ERROR_ACTION */
#ifndef USAGE_ERROR_ACTION
#define USAGE_ERROR_ACTION(m,p) ABORT
#endif /* USAGE_ERROR_ACTION */
#endif /* PROCEED_ON_ERROR */
/* -------------------------- Debugging setup ---------------------------- */
#if ! DEBUG
#define check_free_chunk(M,P)
#define check_inuse_chunk(M,P)
#define check_malloced_chunk(M,P,N)
#define check_mmapped_chunk(M,P)
#define check_malloc_state(M)
#define check_top_chunk(M,P)
#else /* DEBUG */
#define check_free_chunk(M,P) do_check_free_chunk(M,P)
#define check_inuse_chunk(M,P) do_check_inuse_chunk(M,P)
#define check_top_chunk(M,P) do_check_top_chunk(M,P)
#define check_malloced_chunk(M,P,N) do_check_malloced_chunk(M,P,N)
#define check_mmapped_chunk(M,P) do_check_mmapped_chunk(M,P)
#define check_malloc_state(M) do_check_malloc_state(M)
static void do_check_any_chunk(mstate m, mchunkptr p);
static void do_check_top_chunk(mstate m, mchunkptr p);
static void do_check_mmapped_chunk(mstate m, mchunkptr p);
static void do_check_inuse_chunk(mstate m, mchunkptr p);
static void do_check_free_chunk(mstate m, mchunkptr p);
static void do_check_malloced_chunk(mstate m, void* mem, size_t s);
static void do_check_tree(mstate m, tchunkptr t);
static void do_check_treebin(mstate m, bindex_t i);
static void do_check_smallbin(mstate m, bindex_t i);
static void do_check_malloc_state(mstate m);
static int bin_find(mstate m, mchunkptr x);
static size_t traverse_and_check(mstate m);
#endif /* DEBUG */
/* ---------------------------- Indexing Bins ---------------------------- */
#define is_small(s) (((s) >> SMALLBIN_SHIFT) < NSMALLBINS)
#define small_index(s) (bindex_t)((s) >> SMALLBIN_SHIFT)
#define small_index2size(i) ((i) << SMALLBIN_SHIFT)
#define MIN_SMALL_INDEX (small_index(MIN_CHUNK_SIZE))
/* addressing by index. See above about smallbin repositioning */
#define smallbin_at(M, i) ((sbinptr)((char*)&((M)->smallbins[(i)<<1])))
#define treebin_at(M,i) (&((M)->treebins[i]))
/* assign tree index for size S to variable I. Use x86 asm if possible */
#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
#define compute_tree_index(S, I)\
{\
unsigned int X = S >> TREEBIN_SHIFT;\
if (X == 0)\
I = 0;\
else if (X > 0xFFFF)\
I = NTREEBINS-1;\
else {\
unsigned int K = (unsigned) sizeof(X)*__CHAR_BIT__ - 1 - (unsigned) __builtin_clz(X); \
I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1)));\
}\
}
#elif defined (__INTEL_COMPILER)
#define compute_tree_index(S, I)\
{\
size_t X = S >> TREEBIN_SHIFT;\
if (X == 0)\
I = 0;\
else if (X > 0xFFFF)\
I = NTREEBINS-1;\
else {\
unsigned int K = _bit_scan_reverse (X); \
I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1)));\
}\
}
#elif defined(_MSC_VER) && _MSC_VER>=1300
#define compute_tree_index(S, I)\
{\
size_t X = S >> TREEBIN_SHIFT;\
if (X == 0)\
I = 0;\
else if (X > 0xFFFF)\
I = NTREEBINS-1;\
else {\
unsigned int K;\
_BitScanReverse((DWORD *) &K, (DWORD) X);\
I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1)));\
}\
}
#else /* GNUC */
#define compute_tree_index(S, I)\
{\
size_t X = S >> TREEBIN_SHIFT;\
if (X == 0)\
I = 0;\
else if (X > 0xFFFF)\
I = NTREEBINS-1;\
else {\
unsigned int Y = (unsigned int)X;\
unsigned int N = ((Y - 0x100) >> 16) & 8;\
unsigned int K = (((Y <<= N) - 0x1000) >> 16) & 4;\
N += K;\
N += K = (((Y <<= K) - 0x4000) >> 16) & 2;\
K = 14 - N + ((Y <<= K) >> 15);\
I = (K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1));\
}\
}
#endif /* GNUC */
/* Bit representing maximum resolved size in a treebin at i */
#define bit_for_tree_index(i) \
(i == NTREEBINS-1)? (SIZE_T_BITSIZE-1) : (((i) >> 1) + TREEBIN_SHIFT - 2)
/* Shift placing maximum resolved bit in a treebin at i as sign bit */
#define leftshift_for_tree_index(i) \
((i == NTREEBINS-1)? 0 : \
((SIZE_T_BITSIZE-SIZE_T_ONE) - (((i) >> 1) + TREEBIN_SHIFT - 2)))
/* The size of the smallest chunk held in bin with index i */
#define minsize_for_tree_index(i) \
((SIZE_T_ONE << (((i) >> 1) + TREEBIN_SHIFT)) | \
(((size_t)((i) & SIZE_T_ONE)) << (((i) >> 1) + TREEBIN_SHIFT - 1)))
/* ------------------------ Operations on bin maps ----------------------- */
/* bit corresponding to given index */
#define idx2bit(i) ((binmap_t)(1) << (i))
/* Mark/Clear bits with given index */
#define mark_smallmap(M,i) ((M)->smallmap |= idx2bit(i))
#define clear_smallmap(M,i) ((M)->smallmap &= ~idx2bit(i))
#define smallmap_is_marked(M,i) ((M)->smallmap & idx2bit(i))
#define mark_treemap(M,i) ((M)->treemap |= idx2bit(i))
#define clear_treemap(M,i) ((M)->treemap &= ~idx2bit(i))
#define treemap_is_marked(M,i) ((M)->treemap & idx2bit(i))
/* isolate the least set bit of a bitmap */
#define least_bit(x) ((x) & -(x))
/* mask with all bits to left of least bit of x on */
#define left_bits(x) ((x<<1) | -(x<<1))
/* mask with all bits to left of or equal to least bit of x on */
#define same_or_left_bits(x) ((x) | -(x))
/* index corresponding to given bit. Use x86 asm if possible */
#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
#define compute_bit2idx(X, I)\
{\
unsigned int J;\
J = __builtin_ctz(X); \
I = (bindex_t)J;\
}
#elif defined (__INTEL_COMPILER)
#define compute_bit2idx(X, I)\
{\
unsigned int J;\
J = _bit_scan_forward (X); \
I = (bindex_t)J;\
}
#elif defined(_MSC_VER) && _MSC_VER>=1300
#define compute_bit2idx(X, I)\
{\
unsigned int J;\
_BitScanForward((DWORD *) &J, X);\
I = (bindex_t)J;\
}
#elif USE_BUILTIN_FFS
#define compute_bit2idx(X, I) I = ffs(X)-1
#else
#define compute_bit2idx(X, I)\
{\
unsigned int Y = X - 1;\
unsigned int K = Y >> (16-4) & 16;\
unsigned int N = K; Y >>= K;\
N += K = Y >> (8-3) & 8; Y >>= K;\
N += K = Y >> (4-2) & 4; Y >>= K;\
N += K = Y >> (2-1) & 2; Y >>= K;\
N += K = Y >> (1-0) & 1; Y >>= K;\
I = (bindex_t)(N + Y);\
}
#endif /* GNUC */
/* ----------------------- Runtime Check Support ------------------------- */
/*
For security, the main invariant is that malloc/free/etc never
writes to a static address other than malloc_state, unless static
malloc_state itself has been corrupted, which cannot occur via
malloc (because of these checks). In essence this means that we
believe all pointers, sizes, maps etc held in malloc_state, but
check all of those linked or offsetted from other embedded data
structures. These checks are interspersed with main code in a way
that tends to minimize their run-time cost.
When FOOTERS is defined, in addition to range checking, we also
verify footer fields of inuse chunks, which can be used guarantee
that the mstate controlling malloc/free is intact. This is a
streamlined version of the approach described by William Robertson
et al in "Run-time Detection of Heap-based Overflows" LISA'03
http://www.usenix.org/events/lisa03/tech/robertson.html The footer
of an inuse chunk holds the xor of its mstate and a random seed,
that is checked upon calls to free() and realloc(). This is
(probabalistically) unguessable from outside the program, but can be
computed by any code successfully malloc'ing any chunk, so does not
itself provide protection against code that has already broken
security through some other means. Unlike Robertson et al, we
always dynamically check addresses of all offset chunks (previous,
next, etc). This turns out to be cheaper than relying on hashes.
*/
#if !INSECURE
/* Check if address a is at least as high as any from MORECORE or MMAP */
#define ok_address(M, a) ((char*)(a) >= (M)->least_addr)
/* Check if address of next chunk n is higher than base chunk p */
#define ok_next(p, n) ((char*)(p) < (char*)(n))
/* Check if p has inuse status */
#define ok_inuse(p) is_inuse(p)
/* Check if p has its pinuse bit on */
#define ok_pinuse(p) pinuse(p)
#else /* !INSECURE */
#define ok_address(M, a) (1)
#define ok_next(b, n) (1)
#define ok_inuse(p) (1)
#define ok_pinuse(p) (1)
#endif /* !INSECURE */
#if (FOOTERS && !INSECURE)
/* Check if (alleged) mstate m has expected magic field */
#define ok_magic(M) ((M)->magic == mparams.magic)
#else /* (FOOTERS && !INSECURE) */
#define ok_magic(M) (1)
#endif /* (FOOTERS && !INSECURE) */
/* In gcc, use __builtin_expect to minimize impact of checks */
#if !INSECURE
#if defined(__GNUC__) && __GNUC__ >= 3
#define RTCHECK(e) __builtin_expect(e, 1)
#else /* GNUC */
#define RTCHECK(e) (e)
#endif /* GNUC */
#else /* !INSECURE */
#define RTCHECK(e) (1)
#endif /* !INSECURE */
/* macros to set up inuse chunks with or without footers */
#if !FOOTERS
#define mark_inuse_foot(M,p,s)
/* Macros for setting head/foot of non-mmapped chunks */
/* Set cinuse bit and pinuse bit of next chunk */
#define set_inuse(M,p,s)\
((p)->head = (((p)->head & PINUSE_BIT)|s|CINUSE_BIT),\
((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT)
/* Set cinuse and pinuse of this chunk and pinuse of next chunk */
#define set_inuse_and_pinuse(M,p,s)\
((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\
((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT)
/* Set size, cinuse and pinuse bit of this chunk */
#define set_size_and_pinuse_of_inuse_chunk(M, p, s)\
((p)->head = (s|PINUSE_BIT|CINUSE_BIT))
#else /* FOOTERS */
/* Set foot of inuse chunk to be xor of mstate and seed */
#define mark_inuse_foot(M,p,s)\
(((mchunkptr)((char*)(p) + (s)))->prev_foot = ((size_t)(M) ^ mparams.magic))
#define get_mstate_for(p)\
((mstate)(((mchunkptr)((char*)(p) +\
(chunksize(p))))->prev_foot ^ mparams.magic))
#define set_inuse(M,p,s)\
((p)->head = (((p)->head & PINUSE_BIT)|s|CINUSE_BIT),\
(((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT), \
mark_inuse_foot(M,p,s))
#define set_inuse_and_pinuse(M,p,s)\
((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\
(((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT),\
mark_inuse_foot(M,p,s))
#define set_size_and_pinuse_of_inuse_chunk(M, p, s)\
((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\
mark_inuse_foot(M, p, s))
#endif /* !FOOTERS */
/* ---------------------------- setting mparams -------------------------- */
#if LOCK_AT_FORK
static void pre_fork(void) { ACQUIRE_LOCK(&(gm)->mutex); }
static void post_fork_parent(void) { RELEASE_LOCK(&(gm)->mutex); }
static void post_fork_child(void) { INITIAL_LOCK(&(gm)->mutex); }
#endif /* LOCK_AT_FORK */
/* Initialize mparams */
static int init_mparams(void) {
#ifdef NEED_GLOBAL_LOCK_INIT
if (malloc_global_mutex_status <= 0)
init_malloc_global_mutex();
#endif
ACQUIRE_MALLOC_GLOBAL_LOCK();
if (mparams.magic == 0) {
size_t magic;
size_t psize;
size_t gsize;
#ifndef WIN32
psize = malloc_getpagesize;
gsize = ((DEFAULT_GRANULARITY != 0)? DEFAULT_GRANULARITY : psize);
#else /* WIN32 */
{
SYSTEM_INFO system_info;
GetSystemInfo(&system_info);
psize = system_info.dwPageSize;
gsize = ((DEFAULT_GRANULARITY != 0)?
DEFAULT_GRANULARITY : system_info.dwAllocationGranularity);
}
#endif /* WIN32 */
/* Sanity-check configuration:
size_t must be unsigned and as wide as pointer type.
ints must be at least 4 bytes.
alignment must be at least 8.
Alignment, min chunk size, and page size must all be powers of 2.
*/
if ((sizeof(size_t) != sizeof(char*)) ||
(MAX_SIZE_T < MIN_CHUNK_SIZE) ||
(sizeof(int) < 4) ||
(MALLOC_ALIGNMENT < (size_t)8U) ||
((MALLOC_ALIGNMENT & (MALLOC_ALIGNMENT-SIZE_T_ONE)) != 0) ||
((MCHUNK_SIZE & (MCHUNK_SIZE-SIZE_T_ONE)) != 0) ||
((gsize & (gsize-SIZE_T_ONE)) != 0) ||
((psize & (psize-SIZE_T_ONE)) != 0))
ABORT;
mparams.granularity = gsize;
mparams.page_size = psize;
mparams.mmap_threshold = DEFAULT_MMAP_THRESHOLD;
mparams.trim_threshold = DEFAULT_TRIM_THRESHOLD;
#if MORECORE_CONTIGUOUS
mparams.default_mflags = USE_LOCK_BIT|USE_MMAP_BIT;
#else /* MORECORE_CONTIGUOUS */
mparams.default_mflags = USE_LOCK_BIT|USE_MMAP_BIT|USE_NONCONTIGUOUS_BIT;
#endif /* MORECORE_CONTIGUOUS */
#if !ONLY_MSPACES
/* Set up lock for main malloc area */
gm->mflags = mparams.default_mflags;
(void)INITIAL_LOCK(&gm->mutex);
#endif
#if LOCK_AT_FORK
pthread_atfork(&pre_fork, &post_fork_parent, &post_fork_child);
#endif
{
#if USE_DEV_RANDOM
int fd;
unsigned char buf[sizeof(size_t)];
/* Try to use /dev/urandom, else fall back on using time */
if ((fd = open("/dev/urandom", O_RDONLY)) >= 0 &&
read(fd, buf, sizeof(buf)) == sizeof(buf)) {
magic = *((size_t *) buf);
close(fd);
}
else
#endif /* USE_DEV_RANDOM */
#ifdef WIN32
magic = (size_t)(GetTickCount() ^ (size_t)0x55555555U);
#elif defined(LACKS_TIME_H)
magic = (size_t)&magic ^ (size_t)0x55555555U;
#else
magic = (size_t)(time(0) ^ (size_t)0x55555555U);
#endif
magic |= (size_t)8U; /* ensure nonzero */
magic &= ~(size_t)7U; /* improve chances of fault for bad values */
/* Until memory modes commonly available, use volatile-write */
(*(volatile size_t *)(&(mparams.magic))) = magic;
}
}
RELEASE_MALLOC_GLOBAL_LOCK();
return 1;
}
/* support for mallopt */
static int change_mparam(int param_number, int value) {
size_t val;
ensure_initialization();
val = (value == -1)? MAX_SIZE_T : (size_t)value;
switch(param_number) {
case M_TRIM_THRESHOLD:
mparams.trim_threshold = val;
return 1;
case M_GRANULARITY:
if (val >= mparams.page_size && ((val & (val-1)) == 0)) {
mparams.granularity = val;
return 1;
}
else
return 0;
case M_MMAP_THRESHOLD:
mparams.mmap_threshold = val;
return 1;
default:
return 0;
}
}
#if DEBUG
/* ------------------------- Debugging Support --------------------------- */
/* Check properties of any chunk, whether free, inuse, mmapped etc */
static void do_check_any_chunk(mstate m, mchunkptr p) {
assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD));
assert(ok_address(m, p));
}
/* Check properties of top chunk */
static void do_check_top_chunk(mstate m, mchunkptr p) {
msegmentptr sp = segment_holding(m, (char*)p);
size_t sz = p->head & ~INUSE_BITS; /* third-lowest bit can be set! */
assert(sp != 0);
assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD));
assert(ok_address(m, p));
assert(sz == m->topsize);
assert(sz > 0);
assert(sz == ((sp->base + sp->size) - (char*)p) - TOP_FOOT_SIZE);
assert(pinuse(p));
assert(!pinuse(chunk_plus_offset(p, sz)));
}
/* Check properties of (inuse) mmapped chunks */
static void do_check_mmapped_chunk(mstate m, mchunkptr p) {
size_t sz = chunksize(p);
size_t len = (sz + (p->prev_foot) + MMAP_FOOT_PAD);
assert(is_mmapped(p));
assert(use_mmap(m));
assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD));
assert(ok_address(m, p));
assert(!is_small(sz));
assert((len & (mparams.page_size-SIZE_T_ONE)) == 0);
assert(chunk_plus_offset(p, sz)->head == FENCEPOST_HEAD);
assert(chunk_plus_offset(p, sz+SIZE_T_SIZE)->head == 0);
}
/* Check properties of inuse chunks */
static void do_check_inuse_chunk(mstate m, mchunkptr p) {
do_check_any_chunk(m, p);
assert(is_inuse(p));
assert(next_pinuse(p));
/* If not pinuse and not mmapped, previous chunk has OK offset */
assert(is_mmapped(p) || pinuse(p) || next_chunk(prev_chunk(p)) == p);
if (is_mmapped(p))
do_check_mmapped_chunk(m, p);
}
/* Check properties of free chunks */
static void do_check_free_chunk(mstate m, mchunkptr p) {
size_t sz = chunksize(p);
mchunkptr next = chunk_plus_offset(p, sz);
do_check_any_chunk(m, p);
assert(!is_inuse(p));
assert(!next_pinuse(p));
assert (!is_mmapped(p));
if (p != m->dv && p != m->top) {
if (sz >= MIN_CHUNK_SIZE) {
assert((sz & CHUNK_ALIGN_MASK) == 0);
assert(is_aligned(chunk2mem(p)));
assert(next->prev_foot == sz);
assert(pinuse(p));
assert (next == m->top || is_inuse(next));
assert(p->fd->bk == p);
assert(p->bk->fd == p);
}
else /* markers are always of size SIZE_T_SIZE */
assert(sz == SIZE_T_SIZE);
}
}
/* Check properties of malloced chunks at the point they are malloced */
static void do_check_malloced_chunk(mstate m, void* mem, size_t s) {
if (mem != 0) {
mchunkptr p = mem2chunk(mem);
size_t sz = p->head & ~INUSE_BITS;
do_check_inuse_chunk(m, p);
assert((sz & CHUNK_ALIGN_MASK) == 0);
assert(sz >= MIN_CHUNK_SIZE);
assert(sz >= s);
/* unless mmapped, size is less than MIN_CHUNK_SIZE more than request */
assert(is_mmapped(p) || sz < (s + MIN_CHUNK_SIZE));
}
}
/* Check a tree and its subtrees. */
static void do_check_tree(mstate m, tchunkptr t) {
tchunkptr head = 0;
tchunkptr u = t;
bindex_t tindex = t->index;
size_t tsize = chunksize(t);
bindex_t idx;
compute_tree_index(tsize, idx);
assert(tindex == idx);
assert(tsize >= MIN_LARGE_SIZE);
assert(tsize >= minsize_for_tree_index(idx));
assert((idx == NTREEBINS-1) || (tsize < minsize_for_tree_index((idx+1))));
do { /* traverse through chain of same-sized nodes */
do_check_any_chunk(m, ((mchunkptr)u));
assert(u->index == tindex);
assert(chunksize(u) == tsize);
assert(!is_inuse(u));
assert(!next_pinuse(u));
assert(u->fd->bk == u);
assert(u->bk->fd == u);
if (u->parent == 0) {
assert(u->child[0] == 0);
assert(u->child[1] == 0);
}
else {
assert(head == 0); /* only one node on chain has parent */
head = u;
assert(u->parent != u);
assert (u->parent->child[0] == u ||
u->parent->child[1] == u ||
*((tbinptr*)(u->parent)) == u);
if (u->child[0] != 0) {
assert(u->child[0]->parent == u);
assert(u->child[0] != u);
do_check_tree(m, u->child[0]);
}
if (u->child[1] != 0) {
assert(u->child[1]->parent == u);
assert(u->child[1] != u);
do_check_tree(m, u->child[1]);
}
if (u->child[0] != 0 && u->child[1] != 0) {
assert(chunksize(u->child[0]) < chunksize(u->child[1]));
}
}
u = u->fd;
} while (u != t);
assert(head != 0);
}
/* Check all the chunks in a treebin. */
static void do_check_treebin(mstate m, bindex_t i) {
tbinptr* tb = treebin_at(m, i);
tchunkptr t = *tb;
int empty = (m->treemap & (1U << i)) == 0;
if (t == 0)
assert(empty);
if (!empty)
do_check_tree(m, t);
}
/* Check all the chunks in a smallbin. */
static void do_check_smallbin(mstate m, bindex_t i) {
sbinptr b = smallbin_at(m, i);
mchunkptr p = b->bk;
unsigned int empty = (m->smallmap & (1U << i)) == 0;
if (p == b)
assert(empty);
if (!empty) {
for (; p != b; p = p->bk) {
size_t size = chunksize(p);
mchunkptr q;
/* each chunk claims to be free */
do_check_free_chunk(m, p);
/* chunk belongs in bin */
assert(small_index(size) == i);
assert(p->bk == b || chunksize(p->bk) == chunksize(p));
/* chunk is followed by an inuse chunk */
q = next_chunk(p);
if (q->head != FENCEPOST_HEAD)
do_check_inuse_chunk(m, q);
}
}
}
/* Find x in a bin. Used in other check functions. */
static int bin_find(mstate m, mchunkptr x) {
size_t size = chunksize(x);
if (is_small(size)) {
bindex_t sidx = small_index(size);
sbinptr b = smallbin_at(m, sidx);
if (smallmap_is_marked(m, sidx)) {
mchunkptr p = b;
do {
if (p == x)
return 1;
} while ((p = p->fd) != b);
}
}
else {
bindex_t tidx;
compute_tree_index(size, tidx);
if (treemap_is_marked(m, tidx)) {
tchunkptr t = *treebin_at(m, tidx);
size_t sizebits = size << leftshift_for_tree_index(tidx);
while (t != 0 && chunksize(t) != size) {
t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1];
sizebits <<= 1;
}
if (t != 0) {
tchunkptr u = t;
do {
if (u == (tchunkptr)x)
return 1;
} while ((u = u->fd) != t);
}
}
}
return 0;
}
/* Traverse each chunk and check it; return total */
static size_t traverse_and_check(mstate m) {
size_t sum = 0;
if (is_initialized(m)) {
msegmentptr s = &m->seg;
sum += m->topsize + TOP_FOOT_SIZE;
while (s != 0) {
mchunkptr q = align_as_chunk(s->base);
mchunkptr lastq = 0;
assert(pinuse(q));
while (segment_holds(s, q) &&
q != m->top && q->head != FENCEPOST_HEAD) {
sum += chunksize(q);
if (is_inuse(q)) {
assert(!bin_find(m, q));
do_check_inuse_chunk(m, q);
}
else {
assert(q == m->dv || bin_find(m, q));
assert(lastq == 0 || is_inuse(lastq)); /* Not 2 consecutive free */
do_check_free_chunk(m, q);
}
lastq = q;
q = next_chunk(q);
}
s = s->next;
}
}
return sum;
}
/* Check all properties of malloc_state. */
static void do_check_malloc_state(mstate m) {
bindex_t i;
size_t total;
/* check bins */
for (i = 0; i < NSMALLBINS; ++i)
do_check_smallbin(m, i);
for (i = 0; i < NTREEBINS; ++i)
do_check_treebin(m, i);
if (m->dvsize != 0) { /* check dv chunk */
do_check_any_chunk(m, m->dv);
assert(m->dvsize == chunksize(m->dv));
assert(m->dvsize >= MIN_CHUNK_SIZE);
assert(bin_find(m, m->dv) == 0);
}
if (m->top != 0) { /* check top chunk */
do_check_top_chunk(m, m->top);
/*assert(m->topsize == chunksize(m->top)); redundant */
assert(m->topsize > 0);
assert(bin_find(m, m->top) == 0);
}
total = traverse_and_check(m);
assert(total <= m->footprint);
assert(m->footprint <= m->max_footprint);
}
#endif /* DEBUG */
/* ----------------------------- statistics ------------------------------ */
#if !NO_MALLINFO
static struct mallinfo internal_mallinfo(mstate m) {
struct mallinfo nm = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
ensure_initialization();
if (!PREACTION(m)) {
check_malloc_state(m);
if (is_initialized(m)) {
size_t nfree = SIZE_T_ONE; /* top always free */
size_t mfree = m->topsize + TOP_FOOT_SIZE;
size_t sum = mfree;
msegmentptr s = &m->seg;
while (s != 0) {
mchunkptr q = align_as_chunk(s->base);
while (segment_holds(s, q) &&
q != m->top && q->head != FENCEPOST_HEAD) {
size_t sz = chunksize(q);
sum += sz;
if (!is_inuse(q)) {
mfree += sz;
++nfree;
}
q = next_chunk(q);
}
s = s->next;
}
nm.arena = sum;
nm.ordblks = nfree;
nm.hblkhd = m->footprint - sum;
nm.usmblks = m->max_footprint;
nm.uordblks = m->footprint - mfree;
nm.fordblks = mfree;
nm.keepcost = m->topsize;
}
POSTACTION(m);
}
return nm;
}
#endif /* !NO_MALLINFO */
#if !NO_MALLOC_STATS
static void internal_malloc_stats(mstate m) {
ensure_initialization();
if (!PREACTION(m)) {
size_t maxfp = 0;
size_t fp = 0;
size_t used = 0;
check_malloc_state(m);
if (is_initialized(m)) {
msegmentptr s = &m->seg;
maxfp = m->max_footprint;
fp = m->footprint;
used = fp - (m->topsize + TOP_FOOT_SIZE);
while (s != 0) {
mchunkptr q = align_as_chunk(s->base);
while (segment_holds(s, q) &&
q != m->top && q->head != FENCEPOST_HEAD) {
if (!is_inuse(q))
used -= chunksize(q);
q = next_chunk(q);
}
s = s->next;
}
}
POSTACTION(m); /* drop lock */
fprintf(stderr, "max system bytes = %10lu\n", (unsigned long)(maxfp));
fprintf(stderr, "system bytes = %10lu\n", (unsigned long)(fp));
fprintf(stderr, "in use bytes = %10lu\n", (unsigned long)(used));
}
}
#endif /* NO_MALLOC_STATS */
/* ----------------------- Operations on smallbins ----------------------- */
/*
Various forms of linking and unlinking are defined as macros. Even
the ones for trees, which are very long but have very short typical
paths. This is ugly but reduces reliance on inlining support of
compilers.
*/
/* Link a free chunk into a smallbin */
#define insert_small_chunk(M, P, S) {\
bindex_t I = small_index(S);\
mchunkptr B = smallbin_at(M, I);\
mchunkptr F = B;\
assert(S >= MIN_CHUNK_SIZE);\
if (!smallmap_is_marked(M, I))\
mark_smallmap(M, I);\
else if (RTCHECK(ok_address(M, B->fd)))\
F = B->fd;\
else {\
CORRUPTION_ERROR_ACTION(M);\
}\
B->fd = P;\
F->bk = P;\
P->fd = F;\
P->bk = B;\
}
/* Unlink a chunk from a smallbin */
#define unlink_small_chunk(M, P, S) {\
mchunkptr F = P->fd;\
mchunkptr B = P->bk;\
bindex_t I = small_index(S);\
assert(P != B);\
assert(P != F);\
assert(chunksize(P) == small_index2size(I));\
if (RTCHECK(F == smallbin_at(M,I) || (ok_address(M, F) && F->bk == P))) { \
if (B == F) {\
clear_smallmap(M, I);\
}\
else if (RTCHECK(B == smallbin_at(M,I) ||\
(ok_address(M, B) && B->fd == P))) {\
F->bk = B;\
B->fd = F;\
}\
else {\
CORRUPTION_ERROR_ACTION(M);\
}\
}\
else {\
CORRUPTION_ERROR_ACTION(M);\
}\
}
/* Unlink the first chunk from a smallbin */
#define unlink_first_small_chunk(M, B, P, I) {\
mchunkptr F = P->fd;\
assert(P != B);\
assert(P != F);\
assert(chunksize(P) == small_index2size(I));\
if (B == F) {\
clear_smallmap(M, I);\
}\
else if (RTCHECK(ok_address(M, F) && F->bk == P)) {\
F->bk = B;\
B->fd = F;\
}\
else {\
CORRUPTION_ERROR_ACTION(M);\
}\
}
/* Replace dv node, binning the old one */
/* Used only when dvsize known to be small */
#define replace_dv(M, P, S) {\
size_t DVS = M->dvsize;\
assert(is_small(DVS));\
if (DVS != 0) {\
mchunkptr DV = M->dv;\
insert_small_chunk(M, DV, DVS);\
}\
M->dvsize = S;\
M->dv = P;\
}
/* ------------------------- Operations on trees ------------------------- */
/* Insert chunk into tree */
#define insert_large_chunk(M, X, S) {\
tbinptr* H;\
bindex_t I;\
compute_tree_index(S, I);\
H = treebin_at(M, I);\
X->index = I;\
X->child[0] = X->child[1] = 0;\
if (!treemap_is_marked(M, I)) {\
mark_treemap(M, I);\
*H = X;\
X->parent = (tchunkptr)H;\
X->fd = X->bk = X;\
}\
else {\
tchunkptr T = *H;\
size_t K = S << leftshift_for_tree_index(I);\
for (;;) {\
if (chunksize(T) != S) {\
tchunkptr* C = &(T->child[(K >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]);\
K <<= 1;\
if (*C != 0)\
T = *C;\
else if (RTCHECK(ok_address(M, C))) {\
*C = X;\
X->parent = T;\
X->fd = X->bk = X;\
break;\
}\
else {\
CORRUPTION_ERROR_ACTION(M);\
break;\
}\
}\
else {\
tchunkptr F = T->fd;\
if (RTCHECK(ok_address(M, T) && ok_address(M, F))) {\
T->fd = F->bk = X;\
X->fd = F;\
X->bk = T;\
X->parent = 0;\
break;\
}\
else {\
CORRUPTION_ERROR_ACTION(M);\
break;\
}\
}\
}\
}\
}
/*
Unlink steps:
1. If x is a chained node, unlink it from its same-sized fd/bk links
and choose its bk node as its replacement.
2. If x was the last node of its size, but not a leaf node, it must
be replaced with a leaf node (not merely one with an open left or
right), to make sure that lefts and rights of descendents
correspond properly to bit masks. We use the rightmost descendent
of x. We could use any other leaf, but this is easy to locate and
tends to counteract removal of leftmosts elsewhere, and so keeps
paths shorter than minimally guaranteed. This doesn't loop much
because on average a node in a tree is near the bottom.
3. If x is the base of a chain (i.e., has parent links) relink
x's parent and children to x's replacement (or null if none).
*/
#define unlink_large_chunk(M, X) {\
tchunkptr XP = X->parent;\
tchunkptr R;\
if (X->bk != X) {\
tchunkptr F = X->fd;\
R = X->bk;\
if (RTCHECK(ok_address(M, F) && F->bk == X && R->fd == X)) {\
F->bk = R;\
R->fd = F;\
}\
else {\
CORRUPTION_ERROR_ACTION(M);\
}\
}\
else {\
tchunkptr* RP;\
if (((R = *(RP = &(X->child[1]))) != 0) ||\
((R = *(RP = &(X->child[0]))) != 0)) {\
tchunkptr* CP;\
while ((*(CP = &(R->child[1])) != 0) ||\
(*(CP = &(R->child[0])) != 0)) {\
R = *(RP = CP);\
}\
if (RTCHECK(ok_address(M, RP)))\
*RP = 0;\
else {\
CORRUPTION_ERROR_ACTION(M);\
}\
}\
}\
if (XP != 0) {\
tbinptr* H = treebin_at(M, X->index);\
if (X == *H) {\
if ((*H = R) == 0) \
clear_treemap(M, X->index);\
}\
else if (RTCHECK(ok_address(M, XP))) {\
if (XP->child[0] == X) \
XP->child[0] = R;\
else \
XP->child[1] = R;\
}\
else\
CORRUPTION_ERROR_ACTION(M);\
if (R != 0) {\
if (RTCHECK(ok_address(M, R))) {\
tchunkptr C0, C1;\
R->parent = XP;\
if ((C0 = X->child[0]) != 0) {\
if (RTCHECK(ok_address(M, C0))) {\
R->child[0] = C0;\
C0->parent = R;\
}\
else\
CORRUPTION_ERROR_ACTION(M);\
}\
if ((C1 = X->child[1]) != 0) {\
if (RTCHECK(ok_address(M, C1))) {\
R->child[1] = C1;\
C1->parent = R;\
}\
else\
CORRUPTION_ERROR_ACTION(M);\
}\
}\
else\
CORRUPTION_ERROR_ACTION(M);\
}\
}\
}
/* Relays to large vs small bin operations */
#define insert_chunk(M, P, S)\
if (is_small(S)) insert_small_chunk(M, P, S)\
else { tchunkptr TP = (tchunkptr)(P); insert_large_chunk(M, TP, S); }
#define unlink_chunk(M, P, S)\
if (is_small(S)) unlink_small_chunk(M, P, S)\
else { tchunkptr TP = (tchunkptr)(P); unlink_large_chunk(M, TP); }
/* Relays to internal calls to malloc/free from realloc, memalign etc */
#if ONLY_MSPACES
#define internal_malloc(m, b) mspace_malloc(m, b)
#define internal_free(m, mem) mspace_free(m,mem);
#else /* ONLY_MSPACES */
#if MSPACES
#define internal_malloc(m, b)\
((m == gm)? dlmalloc(b) : mspace_malloc(m, b))
#define internal_free(m, mem)\
if (m == gm) dlfree(mem); else mspace_free(m,mem);
#else /* MSPACES */
#define internal_malloc(m, b) dlmalloc(b)
#define internal_free(m, mem) dlfree(mem)
#endif /* MSPACES */
#endif /* ONLY_MSPACES */
/* ----------------------- Direct-mmapping chunks ----------------------- */
/*
Directly mmapped chunks are set up with an offset to the start of
the mmapped region stored in the prev_foot field of the chunk. This
allows reconstruction of the required argument to MUNMAP when freed,
and also allows adjustment of the returned chunk to meet alignment
requirements (especially in memalign).
*/
/* Malloc using mmap */
static void* mmap_alloc(mstate m, size_t nb) {
size_t mmsize = mmap_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK);
if (m->footprint_limit != 0) {
size_t fp = m->footprint + mmsize;
if (fp <= m->footprint || fp > m->footprint_limit)
return 0;
}
if (mmsize > nb) { /* Check for wrap around 0 */
char* mm = (char*)(CALL_DIRECT_MMAP(mmsize));
if (mm != CMFAIL) {
size_t offset = align_offset(chunk2mem(mm));
size_t psize = mmsize - offset - MMAP_FOOT_PAD;
mchunkptr p = (mchunkptr)(mm + offset);
p->prev_foot = offset;
p->head = psize;
mark_inuse_foot(m, p, psize);
chunk_plus_offset(p, psize)->head = FENCEPOST_HEAD;
chunk_plus_offset(p, psize+SIZE_T_SIZE)->head = 0;
if (m->least_addr == 0 || mm < m->least_addr)
m->least_addr = mm;
if ((m->footprint += mmsize) > m->max_footprint)
m->max_footprint = m->footprint;
assert(is_aligned(chunk2mem(p)));
check_mmapped_chunk(m, p);
return chunk2mem(p);
}
}
return 0;
}
/* Realloc using mmap */
static mchunkptr mmap_resize(mstate m, mchunkptr oldp, size_t nb, int flags) {
size_t oldsize = chunksize(oldp);
(void)flags; /* placate people compiling -Wunused */
if (is_small(nb)) /* Can't shrink mmap regions below small size */
return 0;
/* Keep old chunk if big enough but not too big */
if (oldsize >= nb + SIZE_T_SIZE &&
(oldsize - nb) <= (mparams.granularity << 1))
return oldp;
else {
size_t offset = oldp->prev_foot;
size_t oldmmsize = oldsize + offset + MMAP_FOOT_PAD;
size_t newmmsize = mmap_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK);
char* cp = (char*)CALL_MREMAP((char*)oldp - offset,
oldmmsize, newmmsize, flags);
if (cp != CMFAIL) {
mchunkptr newp = (mchunkptr)(cp + offset);
size_t psize = newmmsize - offset - MMAP_FOOT_PAD;
newp->head = psize;
mark_inuse_foot(m, newp, psize);
chunk_plus_offset(newp, psize)->head = FENCEPOST_HEAD;
chunk_plus_offset(newp, psize+SIZE_T_SIZE)->head = 0;
if (cp < m->least_addr)
m->least_addr = cp;
if ((m->footprint += newmmsize - oldmmsize) > m->max_footprint)
m->max_footprint = m->footprint;
check_mmapped_chunk(m, newp);
return newp;
}
}
return 0;
}
/* -------------------------- mspace management -------------------------- */
/* Initialize top chunk and its size */
static void init_top(mstate m, mchunkptr p, size_t psize) {
/* Ensure alignment */
size_t offset = align_offset(chunk2mem(p));
p = (mchunkptr)((char*)p + offset);
psize -= offset;
m->top = p;
m->topsize = psize;
p->head = psize | PINUSE_BIT;
/* set size of fake trailing chunk holding overhead space only once */
chunk_plus_offset(p, psize)->head = TOP_FOOT_SIZE;
m->trim_check = mparams.trim_threshold; /* reset on each update */
}
/* Initialize bins for a new mstate that is otherwise zeroed out */
static void init_bins(mstate m) {
/* Establish circular links for smallbins */
bindex_t i;
for (i = 0; i < NSMALLBINS; ++i) {
sbinptr bin = smallbin_at(m,i);
bin->fd = bin->bk = bin;
}
}
#if PROCEED_ON_ERROR
/* default corruption action */
static void reset_on_error(mstate m) {
int i;
++malloc_corruption_error_count;
/* Reinitialize fields to forget about all memory */
m->smallmap = m->treemap = 0;
m->dvsize = m->topsize = 0;
m->seg.base = 0;
m->seg.size = 0;
m->seg.next = 0;
m->top = m->dv = 0;
for (i = 0; i < NTREEBINS; ++i)
*treebin_at(m, i) = 0;
init_bins(m);
}
#endif /* PROCEED_ON_ERROR */
/* Allocate chunk and prepend remainder with chunk in successor base. */
static void* prepend_alloc(mstate m, char* newbase, char* oldbase,
size_t nb) {
mchunkptr p = align_as_chunk(newbase);
mchunkptr oldfirst = align_as_chunk(oldbase);
size_t psize = (char*)oldfirst - (char*)p;
mchunkptr q = chunk_plus_offset(p, nb);
size_t qsize = psize - nb;
set_size_and_pinuse_of_inuse_chunk(m, p, nb);
assert((char*)oldfirst > (char*)q);
assert(pinuse(oldfirst));
assert(qsize >= MIN_CHUNK_SIZE);
/* consolidate remainder with first chunk of old base */
if (oldfirst == m->top) {
size_t tsize = m->topsize += qsize;
m->top = q;
q->head = tsize | PINUSE_BIT;
check_top_chunk(m, q);
}
else if (oldfirst == m->dv) {
size_t dsize = m->dvsize += qsize;
m->dv = q;
set_size_and_pinuse_of_free_chunk(q, dsize);
}
else {
if (!is_inuse(oldfirst)) {
size_t nsize = chunksize(oldfirst);
unlink_chunk(m, oldfirst, nsize);
oldfirst = chunk_plus_offset(oldfirst, nsize);
qsize += nsize;
}
set_free_with_pinuse(q, qsize, oldfirst);
insert_chunk(m, q, qsize);
check_free_chunk(m, q);
}
check_malloced_chunk(m, chunk2mem(p), nb);
return chunk2mem(p);
}
/* Add a segment to hold a new noncontiguous region */
static void add_segment(mstate m, char* tbase, size_t tsize, flag_t mmapped) {
/* Determine locations and sizes of segment, fenceposts, old top */
char* old_top = (char*)m->top;
msegmentptr oldsp = segment_holding(m, old_top);
char* old_end = oldsp->base + oldsp->size;
size_t ssize = pad_request(sizeof(struct malloc_segment));
char* rawsp = old_end - (ssize + FOUR_SIZE_T_SIZES + CHUNK_ALIGN_MASK);
size_t offset = align_offset(chunk2mem(rawsp));
char* asp = rawsp + offset;
char* csp = (asp < (old_top + MIN_CHUNK_SIZE))? old_top : asp;
mchunkptr sp = (mchunkptr)csp;
msegmentptr ss = (msegmentptr)(chunk2mem(sp));
mchunkptr tnext = chunk_plus_offset(sp, ssize);
mchunkptr p = tnext;
int nfences = 0;
/* reset top to new space */
init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE);
/* Set up segment record */
assert(is_aligned(ss));
set_size_and_pinuse_of_inuse_chunk(m, sp, ssize);
*ss = m->seg; /* Push current record */
m->seg.base = tbase;
m->seg.size = tsize;
m->seg.sflags = mmapped;
m->seg.next = ss;
/* Insert trailing fenceposts */
for (;;) {
mchunkptr nextp = chunk_plus_offset(p, SIZE_T_SIZE);
p->head = FENCEPOST_HEAD;
++nfences;
if ((char*)(&(nextp->head)) < old_end)
p = nextp;
else
break;
}
assert(nfences >= 2);
/* Insert the rest of old top into a bin as an ordinary free chunk */
if (csp != old_top) {
mchunkptr q = (mchunkptr)old_top;
size_t psize = csp - old_top;
mchunkptr tn = chunk_plus_offset(q, psize);
set_free_with_pinuse(q, psize, tn);
insert_chunk(m, q, psize);
}
check_top_chunk(m, m->top);
}
/* -------------------------- System allocation -------------------------- */
/* Get memory from system using MORECORE or MMAP */
static void* sys_alloc(mstate m, size_t nb) {
char* tbase = CMFAIL;
size_t tsize = 0;
flag_t mmap_flag = 0;
size_t asize; /* allocation size */
ensure_initialization();
/* Directly map large chunks, but only if already initialized */
if (use_mmap(m) && nb >= mparams.mmap_threshold && m->topsize != 0) {
void* mem = mmap_alloc(m, nb);
if (mem != 0)
return mem;
}
asize = granularity_align(nb + SYS_ALLOC_PADDING);
if (asize <= nb)
return 0; /* wraparound */
if (m->footprint_limit != 0) {
size_t fp = m->footprint + asize;
if (fp <= m->footprint || fp > m->footprint_limit)
return 0;
}
/*
Try getting memory in any of three ways (in most-preferred to
least-preferred order):
1. A call to MORECORE that can normally contiguously extend memory.
(disabled if not MORECORE_CONTIGUOUS or not HAVE_MORECORE or
or main space is mmapped or a previous contiguous call failed)
2. A call to MMAP new space (disabled if not HAVE_MMAP).
Note that under the default settings, if MORECORE is unable to
fulfill a request, and HAVE_MMAP is true, then mmap is
used as a noncontiguous system allocator. This is a useful backup
strategy for systems with holes in address spaces -- in this case
sbrk cannot contiguously expand the heap, but mmap may be able to
find space.
3. A call to MORECORE that cannot usually contiguously extend memory.
(disabled if not HAVE_MORECORE)
In all cases, we need to request enough bytes from system to ensure
we can malloc nb bytes upon success, so pad with enough space for
top_foot, plus alignment-pad to make sure we don't lose bytes if
not on boundary, and round this up to a granularity unit.
*/
if (MORECORE_CONTIGUOUS && !use_noncontiguous(m)) {
char* br = CMFAIL;
size_t ssize = asize; /* sbrk call size */
msegmentptr ss = (m->top == 0)? 0 : segment_holding(m, (char*)m->top);
ACQUIRE_MALLOC_GLOBAL_LOCK();
if (ss == 0) { /* First time through or recovery */
char* base = (char*)CALL_MORECORE(0);
if (base != CMFAIL) {
size_t fp;
/* Adjust to end on a page boundary */
if (!is_page_aligned(base))
ssize += (page_align((size_t)base) - (size_t)base);
fp = m->footprint + ssize; /* recheck limits */
if (ssize > nb && ssize < HALF_MAX_SIZE_T &&
(m->footprint_limit == 0 ||
(fp > m->footprint && fp <= m->footprint_limit)) &&
(br = (char*)(CALL_MORECORE(ssize))) == base) {
tbase = base;
tsize = ssize;
}
}
}
else {
/* Subtract out existing available top space from MORECORE request. */
ssize = granularity_align(nb - m->topsize + SYS_ALLOC_PADDING);
/* Use mem here only if it did continuously extend old space */
if (ssize < HALF_MAX_SIZE_T &&
(br = (char*)(CALL_MORECORE(ssize))) == ss->base+ss->size) {
tbase = br;
tsize = ssize;
}
}
if (tbase == CMFAIL) { /* Cope with partial failure */
if (br != CMFAIL) { /* Try to use/extend the space we did get */
if (ssize < HALF_MAX_SIZE_T &&
ssize < nb + SYS_ALLOC_PADDING) {
size_t esize = granularity_align(nb + SYS_ALLOC_PADDING - ssize);
if (esize < HALF_MAX_SIZE_T) {
char* end = (char*)CALL_MORECORE(esize);
if (end != CMFAIL)
ssize += esize;
else { /* Can't use; try to release */
(void) CALL_MORECORE(-ssize);
br = CMFAIL;
}
}
}
}
if (br != CMFAIL) { /* Use the space we did get */
tbase = br;
tsize = ssize;
}
else
disable_contiguous(m); /* Don't try contiguous path in the future */
}
RELEASE_MALLOC_GLOBAL_LOCK();
}
if (HAVE_MMAP && tbase == CMFAIL) { /* Try MMAP */
char* mp = (char*)(CALL_MMAP(asize));
if (mp != CMFAIL) {
tbase = mp;
tsize = asize;
mmap_flag = USE_MMAP_BIT;
}
}
if (HAVE_MORECORE && tbase == CMFAIL) { /* Try noncontiguous MORECORE */
if (asize < HALF_MAX_SIZE_T) {
char* br = CMFAIL;
char* end = CMFAIL;
ACQUIRE_MALLOC_GLOBAL_LOCK();
br = (char*)(CALL_MORECORE(asize));
end = (char*)(CALL_MORECORE(0));
RELEASE_MALLOC_GLOBAL_LOCK();
if (br != CMFAIL && end != CMFAIL && br < end) {
size_t ssize = end - br;
if (ssize > nb + TOP_FOOT_SIZE) {
tbase = br;
tsize = ssize;
}
}
}
}
if (tbase != CMFAIL) {
if ((m->footprint += tsize) > m->max_footprint)
m->max_footprint = m->footprint;
if (!is_initialized(m)) { /* first-time initialization */
if (m->least_addr == 0 || tbase < m->least_addr)
m->least_addr = tbase;
m->seg.base = tbase;
m->seg.size = tsize;
m->seg.sflags = mmap_flag;
m->magic = mparams.magic;
m->release_checks = MAX_RELEASE_CHECK_RATE;
init_bins(m);
#if !ONLY_MSPACES
if (is_global(m))
init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE);
else
#endif
{
/* Offset top by embedded malloc_state */
mchunkptr mn = next_chunk(mem2chunk(m));
init_top(m, mn, (size_t)((tbase + tsize) - (char*)mn) -TOP_FOOT_SIZE);
}
}
else {
/* Try to merge with an existing segment */
msegmentptr sp = &m->seg;
/* Only consider most recent segment if traversal suppressed */
while (sp != 0 && tbase != sp->base + sp->size)
sp = (NO_SEGMENT_TRAVERSAL) ? 0 : sp->next;
if (sp != 0 &&
!is_extern_segment(sp) &&
(sp->sflags & USE_MMAP_BIT) == mmap_flag &&
segment_holds(sp, m->top)) { /* append */
sp->size += tsize;
init_top(m, m->top, m->topsize + tsize);
}
else {
if (tbase < m->least_addr)
m->least_addr = tbase;
sp = &m->seg;
while (sp != 0 && sp->base != tbase + tsize)
sp = (NO_SEGMENT_TRAVERSAL) ? 0 : sp->next;
if (sp != 0 &&
!is_extern_segment(sp) &&
(sp->sflags & USE_MMAP_BIT) == mmap_flag) {
char* oldbase = sp->base;
sp->base = tbase;
sp->size += tsize;
return prepend_alloc(m, tbase, oldbase, nb);
}
else
add_segment(m, tbase, tsize, mmap_flag);
}
}
if (nb < m->topsize) { /* Allocate from new or extended top space */
size_t rsize = m->topsize -= nb;
mchunkptr p = m->top;
mchunkptr r = m->top = chunk_plus_offset(p, nb);
r->head = rsize | PINUSE_BIT;
set_size_and_pinuse_of_inuse_chunk(m, p, nb);
check_top_chunk(m, m->top);
check_malloced_chunk(m, chunk2mem(p), nb);
return chunk2mem(p);
}
}
MALLOC_FAILURE_ACTION;
return 0;
}
/* ----------------------- system deallocation -------------------------- */
/* Unmap and unlink any mmapped segments that don't contain used chunks */
static size_t release_unused_segments(mstate m) {
size_t released = 0;
int nsegs = 0;
msegmentptr pred = &m->seg;
msegmentptr sp = pred->next;
while (sp != 0) {
char* base = sp->base;
size_t size = sp->size;
msegmentptr next = sp->next;
++nsegs;
if (is_mmapped_segment(sp) && !is_extern_segment(sp)) {
mchunkptr p = align_as_chunk(base);
size_t psize = chunksize(p);
/* Can unmap if first chunk holds entire segment and not pinned */
if (!is_inuse(p) && (char*)p + psize >= base + size - TOP_FOOT_SIZE) {
tchunkptr tp = (tchunkptr)p;
assert(segment_holds(sp, (char*)sp));
if (p == m->dv) {
m->dv = 0;
m->dvsize = 0;
}
else {
unlink_large_chunk(m, tp);
}
if (CALL_MUNMAP(base, size) == 0) {
released += size;
m->footprint -= size;
/* unlink obsoleted record */
sp = pred;
sp->next = next;
}
else { /* back out if cannot unmap */
insert_large_chunk(m, tp, psize);
}
}
}
if (NO_SEGMENT_TRAVERSAL) /* scan only first segment */
break;
pred = sp;
sp = next;
}
/* Reset check counter */
m->release_checks = (((size_t) nsegs > (size_t) MAX_RELEASE_CHECK_RATE)?
(size_t) nsegs : (size_t) MAX_RELEASE_CHECK_RATE);
return released;
}
static int sys_trim(mstate m, size_t pad) {
size_t released = 0;
ensure_initialization();
if (pad < MAX_REQUEST && is_initialized(m)) {
pad += TOP_FOOT_SIZE; /* ensure enough room for segment overhead */
if (m->topsize > pad) {
/* Shrink top space in granularity-size units, keeping at least one */
size_t unit = mparams.granularity;
size_t extra = ((m->topsize - pad + (unit - SIZE_T_ONE)) / unit -
SIZE_T_ONE) * unit;
msegmentptr sp = segment_holding(m, (char*)m->top);
if (!is_extern_segment(sp)) {
if (is_mmapped_segment(sp)) {
if (HAVE_MMAP &&
sp->size >= extra &&
!has_segment_link(m, sp)) { /* can't shrink if pinned */
size_t newsize = sp->size - extra;
(void)newsize; /* placate people compiling -Wunused-variable */
/* Prefer mremap, fall back to munmap */
if ((CALL_MREMAP(sp->base, sp->size, newsize, 0) != MFAIL) ||
(CALL_MUNMAP(sp->base + newsize, extra) == 0)) {
released = extra;
}
}
}
else if (HAVE_MORECORE) {
if (extra >= HALF_MAX_SIZE_T) /* Avoid wrapping negative */
extra = (HALF_MAX_SIZE_T) + SIZE_T_ONE - unit;
ACQUIRE_MALLOC_GLOBAL_LOCK();
{
/* Make sure end of memory is where we last set it. */
char* old_br = (char*)(CALL_MORECORE(0));
if (old_br == sp->base + sp->size) {
char* rel_br = (char*)(CALL_MORECORE(-extra));
char* new_br = (char*)(CALL_MORECORE(0));
if (rel_br != CMFAIL && new_br < old_br)
released = old_br - new_br;
}
}
RELEASE_MALLOC_GLOBAL_LOCK();
}
}
if (released != 0) {
sp->size -= released;
m->footprint -= released;
init_top(m, m->top, m->topsize - released);
check_top_chunk(m, m->top);
}
}
/* Unmap any unused mmapped segments */
if (HAVE_MMAP)
released += release_unused_segments(m);
/* On failure, disable autotrim to avoid repeated failed future calls */
if (released == 0 && m->topsize > m->trim_check)
m->trim_check = MAX_SIZE_T;
}
return (released != 0)? 1 : 0;
}
/* Consolidate and bin a chunk. Differs from exported versions
of free mainly in that the chunk need not be marked as inuse.
*/
static void dispose_chunk(mstate m, mchunkptr p, size_t psize) {
mchunkptr next = chunk_plus_offset(p, psize);
if (!pinuse(p)) {
mchunkptr prev;
size_t prevsize = p->prev_foot;
if (is_mmapped(p)) {
psize += prevsize + MMAP_FOOT_PAD;
if (CALL_MUNMAP((char*)p - prevsize, psize) == 0)
m->footprint -= psize;
return;
}
prev = chunk_minus_offset(p, prevsize);
psize += prevsize;
p = prev;
if (RTCHECK(ok_address(m, prev))) { /* consolidate backward */
if (p != m->dv) {
unlink_chunk(m, p, prevsize);
}
else if ((next->head & INUSE_BITS) == INUSE_BITS) {
m->dvsize = psize;
set_free_with_pinuse(p, psize, next);
return;
}
}
else {
CORRUPTION_ERROR_ACTION(m);
return;
}
}
if (RTCHECK(ok_address(m, next))) {
if (!cinuse(next)) { /* consolidate forward */
if (next == m->top) {
size_t tsize = m->topsize += psize;
m->top = p;
p->head = tsize | PINUSE_BIT;
if (p == m->dv) {
m->dv = 0;
m->dvsize = 0;
}
return;
}
else if (next == m->dv) {
size_t dsize = m->dvsize += psize;
m->dv = p;
set_size_and_pinuse_of_free_chunk(p, dsize);
return;
}
else {
size_t nsize = chunksize(next);
psize += nsize;
unlink_chunk(m, next, nsize);
set_size_and_pinuse_of_free_chunk(p, psize);
if (p == m->dv) {
m->dvsize = psize;
return;
}
}
}
else {
set_free_with_pinuse(p, psize, next);
}
insert_chunk(m, p, psize);
}
else {
CORRUPTION_ERROR_ACTION(m);
}
}
/* ---------------------------- malloc --------------------------- */
/* allocate a large request from the best fitting chunk in a treebin */
static void* tmalloc_large(mstate m, size_t nb) {
tchunkptr v = 0;
size_t rsize = -nb; /* Unsigned negation */
tchunkptr t;
bindex_t idx;
compute_tree_index(nb, idx);
if ((t = *treebin_at(m, idx)) != 0) {
/* Traverse tree for this bin looking for node with size == nb */
size_t sizebits = nb << leftshift_for_tree_index(idx);
tchunkptr rst = 0; /* The deepest untaken right subtree */
for (;;) {
tchunkptr rt;
size_t trem = chunksize(t) - nb;
if (trem < rsize) {
v = t;
if ((rsize = trem) == 0)
break;
}
rt = t->child[1];
t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1];
if (rt != 0 && rt != t)
rst = rt;
if (t == 0) {
t = rst; /* set t to least subtree holding sizes > nb */
break;
}
sizebits <<= 1;
}
}
if (t == 0 && v == 0) { /* set t to root of next non-empty treebin */
binmap_t leftbits = left_bits(idx2bit(idx)) & m->treemap;
if (leftbits != 0) {
bindex_t i;
binmap_t leastbit = least_bit(leftbits);
compute_bit2idx(leastbit, i);
t = *treebin_at(m, i);
}
}
while (t != 0) { /* find smallest of tree or subtree */
size_t trem = chunksize(t) - nb;
if (trem < rsize) {
rsize = trem;
v = t;
}
t = leftmost_child(t);
}
/* If dv is a better fit, return 0 so malloc will use it */
if (v != 0 && rsize < (size_t)(m->dvsize - nb)) {
if (RTCHECK(ok_address(m, v))) { /* split */
mchunkptr r = chunk_plus_offset(v, nb);
assert(chunksize(v) == rsize + nb);
if (RTCHECK(ok_next(v, r))) {
unlink_large_chunk(m, v);
if (rsize < MIN_CHUNK_SIZE)
set_inuse_and_pinuse(m, v, (rsize + nb));
else {
set_size_and_pinuse_of_inuse_chunk(m, v, nb);
set_size_and_pinuse_of_free_chunk(r, rsize);
insert_chunk(m, r, rsize);
}
return chunk2mem(v);
}
}
CORRUPTION_ERROR_ACTION(m);
}
return 0;
}
/* allocate a small request from the best fitting chunk in a treebin */
static void* tmalloc_small(mstate m, size_t nb) {
tchunkptr t, v;
size_t rsize;
bindex_t i;
binmap_t leastbit = least_bit(m->treemap);
compute_bit2idx(leastbit, i);
v = t = *treebin_at(m, i);
rsize = chunksize(t) - nb;
while ((t = leftmost_child(t)) != 0) {
size_t trem = chunksize(t) - nb;
if (trem < rsize) {
rsize = trem;
v = t;
}
}
if (RTCHECK(ok_address(m, v))) {
mchunkptr r = chunk_plus_offset(v, nb);
assert(chunksize(v) == rsize + nb);
if (RTCHECK(ok_next(v, r))) {
unlink_large_chunk(m, v);
if (rsize < MIN_CHUNK_SIZE)
set_inuse_and_pinuse(m, v, (rsize + nb));
else {
set_size_and_pinuse_of_inuse_chunk(m, v, nb);
set_size_and_pinuse_of_free_chunk(r, rsize);
replace_dv(m, r, rsize);
}
return chunk2mem(v);
}
}
CORRUPTION_ERROR_ACTION(m);
return 0;
}
#if !ONLY_MSPACES
void* dlmalloc(size_t bytes) {
/*
Basic algorithm:
If a small request (< 256 bytes minus per-chunk overhead):
1. If one exists, use a remainderless chunk in associated smallbin.
(Remainderless means that there are too few excess bytes to
represent as a chunk.)
2. If it is big enough, use the dv chunk, which is normally the
chunk adjacent to the one used for the most recent small request.
3. If one exists, split the smallest available chunk in a bin,
saving remainder in dv.
4. If it is big enough, use the top chunk.
5. If available, get memory from system and use it
Otherwise, for a large request:
1. Find the smallest available binned chunk that fits, and use it
if it is better fitting than dv chunk, splitting if necessary.
2. If better fitting than any binned chunk, use the dv chunk.
3. If it is big enough, use the top chunk.
4. If request size >= mmap threshold, try to directly mmap this chunk.
5. If available, get memory from system and use it
The ugly goto's here ensure that postaction occurs along all paths.
*/
#if USE_LOCKS
ensure_initialization(); /* initialize in sys_alloc if not using locks */
#endif
if (!PREACTION(gm)) {
void* mem;
size_t nb;
if (bytes <= MAX_SMALL_REQUEST) {
bindex_t idx;
binmap_t smallbits;
nb = (bytes < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(bytes);
idx = small_index(nb);
smallbits = gm->smallmap >> idx;
if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */
mchunkptr b, p;
idx += ~smallbits & 1; /* Uses next bin if idx empty */
b = smallbin_at(gm, idx);
p = b->fd;
assert(chunksize(p) == small_index2size(idx));
unlink_first_small_chunk(gm, b, p, idx);
set_inuse_and_pinuse(gm, p, small_index2size(idx));
mem = chunk2mem(p);
check_malloced_chunk(gm, mem, nb);
goto postaction;
}
else if (nb > gm->dvsize) {
if (smallbits != 0) { /* Use chunk in next nonempty smallbin */
mchunkptr b, p, r;
size_t rsize;
bindex_t i;
binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx));
binmap_t leastbit = least_bit(leftbits);
compute_bit2idx(leastbit, i);
b = smallbin_at(gm, i);
p = b->fd;
assert(chunksize(p) == small_index2size(i));
unlink_first_small_chunk(gm, b, p, i);
rsize = small_index2size(i) - nb;
/* Fit here cannot be remainderless if 4byte sizes */
if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE)
set_inuse_and_pinuse(gm, p, small_index2size(i));
else {
set_size_and_pinuse_of_inuse_chunk(gm, p, nb);
r = chunk_plus_offset(p, nb);
set_size_and_pinuse_of_free_chunk(r, rsize);
replace_dv(gm, r, rsize);
}
mem = chunk2mem(p);
check_malloced_chunk(gm, mem, nb);
goto postaction;
}
else if (gm->treemap != 0 && (mem = tmalloc_small(gm, nb)) != 0) {
check_malloced_chunk(gm, mem, nb);
goto postaction;
}
}
}
else if (bytes >= MAX_REQUEST)
nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */
else {
nb = pad_request(bytes);
if (gm->treemap != 0 && (mem = tmalloc_large(gm, nb)) != 0) {
check_malloced_chunk(gm, mem, nb);
goto postaction;
}
}
if (nb <= gm->dvsize) {
size_t rsize = gm->dvsize - nb;
mchunkptr p = gm->dv;
if (rsize >= MIN_CHUNK_SIZE) { /* split dv */
mchunkptr r = gm->dv = chunk_plus_offset(p, nb);
gm->dvsize = rsize;
set_size_and_pinuse_of_free_chunk(r, rsize);
set_size_and_pinuse_of_inuse_chunk(gm, p, nb);
}
else { /* exhaust dv */
size_t dvs = gm->dvsize;
gm->dvsize = 0;
gm->dv = 0;
set_inuse_and_pinuse(gm, p, dvs);
}
mem = chunk2mem(p);
check_malloced_chunk(gm, mem, nb);
goto postaction;
}
else if (nb < gm->topsize) { /* Split top */
size_t rsize = gm->topsize -= nb;
mchunkptr p = gm->top;
mchunkptr r = gm->top = chunk_plus_offset(p, nb);
r->head = rsize | PINUSE_BIT;
set_size_and_pinuse_of_inuse_chunk(gm, p, nb);
mem = chunk2mem(p);
check_top_chunk(gm, gm->top);
check_malloced_chunk(gm, mem, nb);
goto postaction;
}
mem = sys_alloc(gm, nb);
postaction:
POSTACTION(gm);
return mem;
}
return 0;
}
/* ---------------------------- free --------------------------- */
void dlfree(void* mem) {
/*
Consolidate freed chunks with preceeding or succeeding bordering
free chunks, if they exist, and then place in a bin. Intermixed
with special cases for top, dv, mmapped chunks, and usage errors.
*/
if (mem != 0) {
mchunkptr p = mem2chunk(mem);
#if FOOTERS
mstate fm = get_mstate_for(p);
if (!ok_magic(fm)) {
USAGE_ERROR_ACTION(fm, p);
return;
}
#else /* FOOTERS */
#define fm gm
#endif /* FOOTERS */
if (!PREACTION(fm)) {
check_inuse_chunk(fm, p);
if (RTCHECK(ok_address(fm, p) && ok_inuse(p))) {
size_t psize = chunksize(p);
mchunkptr next = chunk_plus_offset(p, psize);
if (!pinuse(p)) {
size_t prevsize = p->prev_foot;
if (is_mmapped(p)) {
psize += prevsize + MMAP_FOOT_PAD;
if (CALL_MUNMAP((char*)p - prevsize, psize) == 0)
fm->footprint -= psize;
goto postaction;
}
else {
mchunkptr prev = chunk_minus_offset(p, prevsize);
psize += prevsize;
p = prev;
if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */
if (p != fm->dv) {
unlink_chunk(fm, p, prevsize);
}
else if ((next->head & INUSE_BITS) == INUSE_BITS) {
fm->dvsize = psize;
set_free_with_pinuse(p, psize, next);
goto postaction;
}
}
else
goto erroraction;
}
}
if (RTCHECK(ok_next(p, next) && ok_pinuse(next))) {
if (!cinuse(next)) { /* consolidate forward */
if (next == fm->top) {
size_t tsize = fm->topsize += psize;
fm->top = p;
p->head = tsize | PINUSE_BIT;
if (p == fm->dv) {
fm->dv = 0;
fm->dvsize = 0;
}
if (should_trim(fm, tsize))
sys_trim(fm, 0);
goto postaction;
}
else if (next == fm->dv) {
size_t dsize = fm->dvsize += psize;
fm->dv = p;
set_size_and_pinuse_of_free_chunk(p, dsize);
goto postaction;
}
else {
size_t nsize = chunksize(next);
psize += nsize;
unlink_chunk(fm, next, nsize);
set_size_and_pinuse_of_free_chunk(p, psize);
if (p == fm->dv) {
fm->dvsize = psize;
goto postaction;
}
}
}
else
set_free_with_pinuse(p, psize, next);
if (is_small(psize)) {
insert_small_chunk(fm, p, psize);
check_free_chunk(fm, p);
}
else {
tchunkptr tp = (tchunkptr)p;
insert_large_chunk(fm, tp, psize);
check_free_chunk(fm, p);
if (--fm->release_checks == 0)
release_unused_segments(fm);
}
goto postaction;
}
}
erroraction:
USAGE_ERROR_ACTION(fm, p);
postaction:
POSTACTION(fm);
}
}
#if !FOOTERS
#undef fm
#endif /* FOOTERS */
}
void* dlcalloc(size_t n_elements, size_t elem_size) {
void* mem;
size_t req = 0;
if (n_elements != 0) {
req = n_elements * elem_size;
if (((n_elements | elem_size) & ~(size_t)0xffff) &&
(req / n_elements != elem_size))
req = MAX_SIZE_T; /* force downstream failure on overflow */
}
mem = dlmalloc(req);
if (mem != 0 && calloc_must_clear(mem2chunk(mem)))
memset(mem, 0, req);
return mem;
}
#endif /* !ONLY_MSPACES */
/* ------------ Internal support for realloc, memalign, etc -------------- */
/* Try to realloc; only in-place unless can_move true */
static mchunkptr try_realloc_chunk(mstate m, mchunkptr p, size_t nb,
int can_move) {
mchunkptr newp = 0;
size_t oldsize = chunksize(p);
mchunkptr next = chunk_plus_offset(p, oldsize);
if (RTCHECK(ok_address(m, p) && ok_inuse(p) &&
ok_next(p, next) && ok_pinuse(next))) {
if (is_mmapped(p)) {
newp = mmap_resize(m, p, nb, can_move);
}
else if (oldsize >= nb) { /* already big enough */
size_t rsize = oldsize - nb;
if (rsize >= MIN_CHUNK_SIZE) { /* split off remainder */
mchunkptr r = chunk_plus_offset(p, nb);
set_inuse(m, p, nb);
set_inuse(m, r, rsize);
dispose_chunk(m, r, rsize);
}
newp = p;
}
else if (next == m->top) { /* extend into top */
if (oldsize + m->topsize > nb) {
size_t newsize = oldsize + m->topsize;
size_t newtopsize = newsize - nb;
mchunkptr newtop = chunk_plus_offset(p, nb);
set_inuse(m, p, nb);
newtop->head = newtopsize |PINUSE_BIT;
m->top = newtop;
m->topsize = newtopsize;
newp = p;
}
}
else if (next == m->dv) { /* extend into dv */
size_t dvs = m->dvsize;
if (oldsize + dvs >= nb) {
size_t dsize = oldsize + dvs - nb;
if (dsize >= MIN_CHUNK_SIZE) {
mchunkptr r = chunk_plus_offset(p, nb);
mchunkptr n = chunk_plus_offset(r, dsize);
set_inuse(m, p, nb);
set_size_and_pinuse_of_free_chunk(r, dsize);
clear_pinuse(n);
m->dvsize = dsize;
m->dv = r;
}
else { /* exhaust dv */
size_t newsize = oldsize + dvs;
set_inuse(m, p, newsize);
m->dvsize = 0;
m->dv = 0;
}
newp = p;
}
}
else if (!cinuse(next)) { /* extend into next free chunk */
size_t nextsize = chunksize(next);
if (oldsize + nextsize >= nb) {
size_t rsize = oldsize + nextsize - nb;
unlink_chunk(m, next, nextsize);
if (rsize < MIN_CHUNK_SIZE) {
size_t newsize = oldsize + nextsize;
set_inuse(m, p, newsize);
}
else {
mchunkptr r = chunk_plus_offset(p, nb);
set_inuse(m, p, nb);
set_inuse(m, r, rsize);
dispose_chunk(m, r, rsize);
}
newp = p;
}
}
}
else {
USAGE_ERROR_ACTION(m, chunk2mem(p));
}
return newp;
}
static void* internal_memalign(mstate m, size_t alignment, size_t bytes) {
void* mem = 0;
if (alignment < MIN_CHUNK_SIZE) /* must be at least a minimum chunk size */
alignment = MIN_CHUNK_SIZE;
if ((alignment & (alignment-SIZE_T_ONE)) != 0) {/* Ensure a power of 2 */
size_t a = MALLOC_ALIGNMENT << 1;
while (a < alignment) a <<= 1;
alignment = a;
}
if (bytes >= MAX_REQUEST - alignment) {
if (m != 0) { /* Test isn't needed but avoids compiler warning */
MALLOC_FAILURE_ACTION;
}
}
else {
size_t nb = request2size(bytes);
size_t req = nb + alignment + MIN_CHUNK_SIZE - CHUNK_OVERHEAD;
mem = internal_malloc(m, req);
if (mem != 0) {
mchunkptr p = mem2chunk(mem);
if (PREACTION(m))
return 0;
if ((((size_t)(mem)) & (alignment - 1)) != 0) { /* misaligned */
/*
Find an aligned spot inside chunk. Since we need to give
back leading space in a chunk of at least MIN_CHUNK_SIZE, if
the first calculation places us at a spot with less than
MIN_CHUNK_SIZE leader, we can move to the next aligned spot.
We've allocated enough total room so that this is always
possible.
*/
char* br = (char*)mem2chunk((size_t)(((size_t)((char*)mem + alignment -
SIZE_T_ONE)) &
-alignment));
char* pos = ((size_t)(br - (char*)(p)) >= MIN_CHUNK_SIZE)?
br : br+alignment;
mchunkptr newp = (mchunkptr)pos;
size_t leadsize = pos - (char*)(p);
size_t newsize = chunksize(p) - leadsize;
if (is_mmapped(p)) { /* For mmapped chunks, just adjust offset */
newp->prev_foot = p->prev_foot + leadsize;
newp->head = newsize;
}
else { /* Otherwise, give back leader, use the rest */
set_inuse(m, newp, newsize);
set_inuse(m, p, leadsize);
dispose_chunk(m, p, leadsize);
}
p = newp;
}
/* Give back spare room at the end */
if (!is_mmapped(p)) {
size_t size = chunksize(p);
if (size > nb + MIN_CHUNK_SIZE) {
size_t remainder_size = size - nb;
mchunkptr remainder = chunk_plus_offset(p, nb);
set_inuse(m, p, nb);
set_inuse(m, remainder, remainder_size);
dispose_chunk(m, remainder, remainder_size);
}
}
mem = chunk2mem(p);
assert (chunksize(p) >= nb);
assert(((size_t)mem & (alignment - 1)) == 0);
check_inuse_chunk(m, p);
POSTACTION(m);
}
}
return mem;
}
/*
Common support for independent_X routines, handling
all of the combinations that can result.
The opts arg has:
bit 0 set if all elements are same size (using sizes[0])
bit 1 set if elements should be zeroed
*/
static void** ialloc(mstate m,
size_t n_elements,
size_t* sizes,
int opts,
void* chunks[]) {
size_t element_size; /* chunksize of each element, if all same */
size_t contents_size; /* total size of elements */
size_t array_size; /* request size of pointer array */
void* mem; /* malloced aggregate space */
mchunkptr p; /* corresponding chunk */
size_t remainder_size; /* remaining bytes while splitting */
void** marray; /* either "chunks" or malloced ptr array */
mchunkptr array_chunk; /* chunk for malloced ptr array */
flag_t was_enabled; /* to disable mmap */
size_t size;
size_t i;
ensure_initialization();
/* compute array length, if needed */
if (chunks != 0) {
if (n_elements == 0)
return chunks; /* nothing to do */
marray = chunks;
array_size = 0;
}
else {
/* if empty req, must still return chunk representing empty array */
if (n_elements == 0)
return (void**)internal_malloc(m, 0);
marray = 0;
array_size = request2size(n_elements * (sizeof(void*)));
}
/* compute total element size */
if (opts & 0x1) { /* all-same-size */
element_size = request2size(*sizes);
contents_size = n_elements * element_size;
}
else { /* add up all the sizes */
element_size = 0;
contents_size = 0;
for (i = 0; i != n_elements; ++i)
contents_size += request2size(sizes[i]);
}
size = contents_size + array_size;
/*
Allocate the aggregate chunk. First disable direct-mmapping so
malloc won't use it, since we would not be able to later
free/realloc space internal to a segregated mmap region.
*/
was_enabled = use_mmap(m);
disable_mmap(m);
mem = internal_malloc(m, size - CHUNK_OVERHEAD);
if (was_enabled)
enable_mmap(m);
if (mem == 0)
return 0;
if (PREACTION(m)) return 0;
p = mem2chunk(mem);
remainder_size = chunksize(p);
assert(!is_mmapped(p));
if (opts & 0x2) { /* optionally clear the elements */
memset((size_t*)mem, 0, remainder_size - SIZE_T_SIZE - array_size);
}
/* If not provided, allocate the pointer array as final part of chunk */
if (marray == 0) {
size_t array_chunk_size;
array_chunk = chunk_plus_offset(p, contents_size);
array_chunk_size = remainder_size - contents_size;
marray = (void**) (chunk2mem(array_chunk));
set_size_and_pinuse_of_inuse_chunk(m, array_chunk, array_chunk_size);
remainder_size = contents_size;
}
/* split out elements */
for (i = 0; ; ++i) {
marray[i] = chunk2mem(p);
if (i != n_elements-1) {
if (element_size != 0)
size = element_size;
else
size = request2size(sizes[i]);
remainder_size -= size;
set_size_and_pinuse_of_inuse_chunk(m, p, size);
p = chunk_plus_offset(p, size);
}
else { /* the final element absorbs any overallocation slop */
set_size_and_pinuse_of_inuse_chunk(m, p, remainder_size);
break;
}
}
#if DEBUG
if (marray != chunks) {
/* final element must have exactly exhausted chunk */
if (element_size != 0) {
assert(remainder_size == element_size);
}
else {
assert(remainder_size == request2size(sizes[i]));
}
check_inuse_chunk(m, mem2chunk(marray));
}
for (i = 0; i != n_elements; ++i)
check_inuse_chunk(m, mem2chunk(marray[i]));
#endif /* DEBUG */
POSTACTION(m);
return marray;
}
/* Try to free all pointers in the given array.
Note: this could be made faster, by delaying consolidation,
at the price of disabling some user integrity checks, We
still optimize some consolidations by combining adjacent
chunks before freeing, which will occur often if allocated
with ialloc or the array is sorted.
*/
static size_t internal_bulk_free(mstate m, void* array[], size_t nelem) {
size_t unfreed = 0;
if (!PREACTION(m)) {
void** a;
void** fence = &(array[nelem]);
for (a = array; a != fence; ++a) {
void* mem = *a;
if (mem != 0) {
mchunkptr p = mem2chunk(mem);
size_t psize = chunksize(p);
#if FOOTERS
if (get_mstate_for(p) != m) {
++unfreed;
continue;
}
#endif
check_inuse_chunk(m, p);
*a = 0;
if (RTCHECK(ok_address(m, p) && ok_inuse(p))) {
void ** b = a + 1; /* try to merge with next chunk */
mchunkptr next = next_chunk(p);
if (b != fence && *b == chunk2mem(next)) {
size_t newsize = chunksize(next) + psize;
set_inuse(m, p, newsize);
*b = chunk2mem(p);
}
else
dispose_chunk(m, p, psize);
}
else {
CORRUPTION_ERROR_ACTION(m);
break;
}
}
}
if (should_trim(m, m->topsize))
sys_trim(m, 0);
POSTACTION(m);
}
return unfreed;
}
/* Traversal */
#if MALLOC_INSPECT_ALL
static void internal_inspect_all(mstate m,
void(*handler)(void *start,
void *end,
size_t used_bytes,
void* callback_arg),
void* arg) {
if (is_initialized(m)) {
mchunkptr top = m->top;
msegmentptr s;
for (s = &m->seg; s != 0; s = s->next) {
mchunkptr q = align_as_chunk(s->base);
while (segment_holds(s, q) && q->head != FENCEPOST_HEAD) {
mchunkptr next = next_chunk(q);
size_t sz = chunksize(q);
size_t used;
void* start;
if (is_inuse(q)) {
used = sz - CHUNK_OVERHEAD; /* must not be mmapped */
start = chunk2mem(q);
}
else {
used = 0;
if (is_small(sz)) { /* offset by possible bookkeeping */
start = (void*)((char*)q + sizeof(struct malloc_chunk));
}
else {
start = (void*)((char*)q + sizeof(struct malloc_tree_chunk));
}
}
if (start < (void*)next) /* skip if all space is bookkeeping */
handler(start, next, used, arg);
if (q == top)
break;
q = next;
}
}
}
}
#endif /* MALLOC_INSPECT_ALL */
/* ------------------ Exported realloc, memalign, etc -------------------- */
#if !ONLY_MSPACES
void* dlrealloc(void* oldmem, size_t bytes) {
void* mem = 0;
if (oldmem == 0) {
mem = dlmalloc(bytes);
}
else if (bytes >= MAX_REQUEST) {
MALLOC_FAILURE_ACTION;
}
#ifdef REALLOC_ZERO_BYTES_FREES
else if (bytes == 0) {
dlfree(oldmem);
}
#endif /* REALLOC_ZERO_BYTES_FREES */
else {
size_t nb = request2size(bytes);
mchunkptr oldp = mem2chunk(oldmem);
#if ! FOOTERS
mstate m = gm;
#else /* FOOTERS */
mstate m = get_mstate_for(oldp);
if (!ok_magic(m)) {
USAGE_ERROR_ACTION(m, oldmem);
return 0;
}
#endif /* FOOTERS */
if (!PREACTION(m)) {
mchunkptr newp = try_realloc_chunk(m, oldp, nb, 1);
POSTACTION(m);
if (newp != 0) {
check_inuse_chunk(m, newp);
mem = chunk2mem(newp);
}
else {
mem = internal_malloc(m, bytes);
if (mem != 0) {
size_t oc = chunksize(oldp) - overhead_for(oldp);
memcpy(mem, oldmem, (oc < bytes)? oc : bytes);
internal_free(m, oldmem);
}
}
}
}
return mem;
}
void* dlrealloc_in_place(void* oldmem, size_t bytes) {
void* mem = 0;
if (oldmem != 0) {
if (bytes >= MAX_REQUEST) {
MALLOC_FAILURE_ACTION;
}
else {
size_t nb = request2size(bytes);
mchunkptr oldp = mem2chunk(oldmem);
#if ! FOOTERS
mstate m = gm;
#else /* FOOTERS */
mstate m = get_mstate_for(oldp);
if (!ok_magic(m)) {
USAGE_ERROR_ACTION(m, oldmem);
return 0;
}
#endif /* FOOTERS */
if (!PREACTION(m)) {
mchunkptr newp = try_realloc_chunk(m, oldp, nb, 0);
POSTACTION(m);
if (newp == oldp) {
check_inuse_chunk(m, newp);
mem = oldmem;
}
}
}
}
return mem;
}
void* dlmemalign(size_t alignment, size_t bytes) {
if (alignment <= MALLOC_ALIGNMENT) {
return dlmalloc(bytes);
}
return internal_memalign(gm, alignment, bytes);
}
int dlposix_memalign(void** pp, size_t alignment, size_t bytes) {
void* mem = 0;
if (alignment == MALLOC_ALIGNMENT)
mem = dlmalloc(bytes);
else {
size_t d = alignment / sizeof(void*);
size_t r = alignment % sizeof(void*);
if (r != 0 || d == 0 || (d & (d-SIZE_T_ONE)) != 0)
return EINVAL;
else if (bytes <= MAX_REQUEST - alignment) {
if (alignment < MIN_CHUNK_SIZE)
alignment = MIN_CHUNK_SIZE;
mem = internal_memalign(gm, alignment, bytes);
}
}
if (mem == 0)
return ENOMEM;
else {
*pp = mem;
return 0;
}
}
void* dlvalloc(size_t bytes) {
size_t pagesz;
ensure_initialization();
pagesz = mparams.page_size;
return dlmemalign(pagesz, bytes);
}
void* dlpvalloc(size_t bytes) {
size_t pagesz;
ensure_initialization();
pagesz = mparams.page_size;
return dlmemalign(pagesz, (bytes + pagesz - SIZE_T_ONE) & ~(pagesz - SIZE_T_ONE));
}
void** dlindependent_calloc(size_t n_elements, size_t elem_size,
void* chunks[]) {
size_t sz = elem_size; /* serves as 1-element array */
return ialloc(gm, n_elements, &sz, 3, chunks);
}
void** dlindependent_comalloc(size_t n_elements, size_t sizes[],
void* chunks[]) {
return ialloc(gm, n_elements, sizes, 0, chunks);
}
size_t dlbulk_free(void* array[], size_t nelem) {
return internal_bulk_free(gm, array, nelem);
}
#if MALLOC_INSPECT_ALL
void dlmalloc_inspect_all(void(*handler)(void *start,
void *end,
size_t used_bytes,
void* callback_arg),
void* arg) {
ensure_initialization();
if (!PREACTION(gm)) {
internal_inspect_all(gm, handler, arg);
POSTACTION(gm);
}
}
#endif /* MALLOC_INSPECT_ALL */
int dlmalloc_trim(size_t pad) {
int result = 0;
ensure_initialization();
if (!PREACTION(gm)) {
result = sys_trim(gm, pad);
POSTACTION(gm);
}
return result;
}
size_t dlmalloc_footprint(void) {
return gm->footprint;
}
size_t dlmalloc_max_footprint(void) {
return gm->max_footprint;
}
size_t dlmalloc_footprint_limit(void) {
size_t maf = gm->footprint_limit;
return maf == 0 ? MAX_SIZE_T : maf;
}
size_t dlmalloc_set_footprint_limit(size_t bytes) {
size_t result; /* invert sense of 0 */
if (bytes == 0)
result = granularity_align(1); /* Use minimal size */
if (bytes == MAX_SIZE_T)
result = 0; /* disable */
else
result = granularity_align(bytes);
return gm->footprint_limit = result;
}
#if !NO_MALLINFO
struct mallinfo dlmallinfo(void) {
return internal_mallinfo(gm);
}
#endif /* NO_MALLINFO */
#if !NO_MALLOC_STATS
void dlmalloc_stats() {
internal_malloc_stats(gm);
}
#endif /* NO_MALLOC_STATS */
int dlmallopt(int param_number, int value) {
return change_mparam(param_number, value);
}
size_t dlmalloc_usable_size(void* mem) {
if (mem != 0) {
mchunkptr p = mem2chunk(mem);
if (is_inuse(p))
return chunksize(p) - overhead_for(p);
}
return 0;
}
#endif /* !ONLY_MSPACES */
/* ----------------------------- user mspaces ---------------------------- */
#if MSPACES
static mstate init_user_mstate(char* tbase, size_t tsize) {
size_t msize = pad_request(sizeof(struct malloc_state));
mchunkptr mn;
mchunkptr msp = align_as_chunk(tbase);
mstate m = (mstate)(chunk2mem(msp));
memset(m, 0, msize);
(void)INITIAL_LOCK(&m->mutex);
msp->head = (msize|INUSE_BITS);
m->seg.base = m->least_addr = tbase;
m->seg.size = m->footprint = m->max_footprint = tsize;
m->magic = mparams.magic;
m->release_checks = MAX_RELEASE_CHECK_RATE;
m->mflags = mparams.default_mflags;
m->extp = 0;
m->exts = 0;
disable_contiguous(m);
init_bins(m);
mn = next_chunk(mem2chunk(m));
init_top(m, mn, (size_t)((tbase + tsize) - (char*)mn) - TOP_FOOT_SIZE);
check_top_chunk(m, m->top);
return m;
}
mspace create_mspace(size_t capacity, int locked) {
mstate m = 0;
size_t msize;
ensure_initialization();
msize = pad_request(sizeof(struct malloc_state));
if (capacity < (size_t) -(msize + TOP_FOOT_SIZE + mparams.page_size)) {
size_t rs = ((capacity == 0)? mparams.granularity :
(capacity + TOP_FOOT_SIZE + msize));
size_t tsize = granularity_align(rs);
char* tbase = (char*)(CALL_MMAP(tsize));
if (tbase != CMFAIL) {
m = init_user_mstate(tbase, tsize);
m->seg.sflags = USE_MMAP_BIT;
set_lock(m, locked);
}
}
return (mspace)m;
}
mspace create_mspace_with_base(void* base, size_t capacity, int locked) {
mstate m = 0;
size_t msize;
ensure_initialization();
msize = pad_request(sizeof(struct malloc_state));
if (capacity > msize + TOP_FOOT_SIZE &&
capacity < (size_t) -(msize + TOP_FOOT_SIZE + mparams.page_size)) {
m = init_user_mstate((char*)base, capacity);
m->seg.sflags = EXTERN_BIT;
set_lock(m, locked);
}
return (mspace)m;
}
int mspace_track_large_chunks(mspace msp, int enable) {
int ret = 0;
mstate ms = (mstate)msp;
if (!PREACTION(ms)) {
if (!use_mmap(ms)) {
ret = 1;
}
if (!enable) {
enable_mmap(ms);
} else {
disable_mmap(ms);
}
POSTACTION(ms);
}
return ret;
}
size_t destroy_mspace(mspace msp) {
size_t freed = 0;
mstate ms = (mstate)msp;
if (ok_magic(ms)) {
msegmentptr sp = &ms->seg;
(void)DESTROY_LOCK(&ms->mutex); /* destroy before unmapped */
while (sp != 0) {
char* base = sp->base;
size_t size = sp->size;
flag_t flag = sp->sflags;
(void)base; /* placate people compiling -Wunused-variable */
sp = sp->next;
if ((flag & USE_MMAP_BIT) && !(flag & EXTERN_BIT) &&
CALL_MUNMAP(base, size) == 0)
freed += size;
}
}
else {
USAGE_ERROR_ACTION(ms,ms);
}
return freed;
}
/*
mspace versions of routines are near-clones of the global
versions. This is not so nice but better than the alternatives.
*/
void* mspace_malloc(mspace msp, size_t bytes) {
mstate ms = (mstate)msp;
if (!ok_magic(ms)) {
USAGE_ERROR_ACTION(ms,ms);
return 0;
}
if (!PREACTION(ms)) {
void* mem;
size_t nb;
if (bytes <= MAX_SMALL_REQUEST) {
bindex_t idx;
binmap_t smallbits;
nb = (bytes < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(bytes);
idx = small_index(nb);
smallbits = ms->smallmap >> idx;
if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */
mchunkptr b, p;
idx += ~smallbits & 1; /* Uses next bin if idx empty */
b = smallbin_at(ms, idx);
p = b->fd;
assert(chunksize(p) == small_index2size(idx));
unlink_first_small_chunk(ms, b, p, idx);
set_inuse_and_pinuse(ms, p, small_index2size(idx));
mem = chunk2mem(p);
check_malloced_chunk(ms, mem, nb);
goto postaction;
}
else if (nb > ms->dvsize) {
if (smallbits != 0) { /* Use chunk in next nonempty smallbin */
mchunkptr b, p, r;
size_t rsize;
bindex_t i;
binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx));
binmap_t leastbit = least_bit(leftbits);
compute_bit2idx(leastbit, i);
b = smallbin_at(ms, i);
p = b->fd;
assert(chunksize(p) == small_index2size(i));
unlink_first_small_chunk(ms, b, p, i);
rsize = small_index2size(i) - nb;
/* Fit here cannot be remainderless if 4byte sizes */
if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE)
set_inuse_and_pinuse(ms, p, small_index2size(i));
else {
set_size_and_pinuse_of_inuse_chunk(ms, p, nb);
r = chunk_plus_offset(p, nb);
set_size_and_pinuse_of_free_chunk(r, rsize);
replace_dv(ms, r, rsize);
}
mem = chunk2mem(p);
check_malloced_chunk(ms, mem, nb);
goto postaction;
}
else if (ms->treemap != 0 && (mem = tmalloc_small(ms, nb)) != 0) {
check_malloced_chunk(ms, mem, nb);
goto postaction;
}
}
}
else if (bytes >= MAX_REQUEST)
nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */
else {
nb = pad_request(bytes);
if (ms->treemap != 0 && (mem = tmalloc_large(ms, nb)) != 0) {
check_malloced_chunk(ms, mem, nb);
goto postaction;
}
}
if (nb <= ms->dvsize) {
size_t rsize = ms->dvsize - nb;
mchunkptr p = ms->dv;
if (rsize >= MIN_CHUNK_SIZE) { /* split dv */
mchunkptr r = ms->dv = chunk_plus_offset(p, nb);
ms->dvsize = rsize;
set_size_and_pinuse_of_free_chunk(r, rsize);
set_size_and_pinuse_of_inuse_chunk(ms, p, nb);
}
else { /* exhaust dv */
size_t dvs = ms->dvsize;
ms->dvsize = 0;
ms->dv = 0;
set_inuse_and_pinuse(ms, p, dvs);
}
mem = chunk2mem(p);
check_malloced_chunk(ms, mem, nb);
goto postaction;
}
else if (nb < ms->topsize) { /* Split top */
size_t rsize = ms->topsize -= nb;
mchunkptr p = ms->top;
mchunkptr r = ms->top = chunk_plus_offset(p, nb);
r->head = rsize | PINUSE_BIT;
set_size_and_pinuse_of_inuse_chunk(ms, p, nb);
mem = chunk2mem(p);
check_top_chunk(ms, ms->top);
check_malloced_chunk(ms, mem, nb);
goto postaction;
}
mem = sys_alloc(ms, nb);
postaction:
POSTACTION(ms);
return mem;
}
return 0;
}
void mspace_free(mspace msp, void* mem) {
if (mem != 0) {
mchunkptr p = mem2chunk(mem);
#if FOOTERS
mstate fm = get_mstate_for(p);
(void)msp; /* placate people compiling -Wunused */
#else /* FOOTERS */
mstate fm = (mstate)msp;
#endif /* FOOTERS */
if (!ok_magic(fm)) {
USAGE_ERROR_ACTION(fm, p);
return;
}
if (!PREACTION(fm)) {
check_inuse_chunk(fm, p);
if (RTCHECK(ok_address(fm, p) && ok_inuse(p))) {
size_t psize = chunksize(p);
mchunkptr next = chunk_plus_offset(p, psize);
if (!pinuse(p)) {
size_t prevsize = p->prev_foot;
if (is_mmapped(p)) {
psize += prevsize + MMAP_FOOT_PAD;
if (CALL_MUNMAP((char*)p - prevsize, psize) == 0)
fm->footprint -= psize;
goto postaction;
}
else {
mchunkptr prev = chunk_minus_offset(p, prevsize);
psize += prevsize;
p = prev;
if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */
if (p != fm->dv) {
unlink_chunk(fm, p, prevsize);
}
else if ((next->head & INUSE_BITS) == INUSE_BITS) {
fm->dvsize = psize;
set_free_with_pinuse(p, psize, next);
goto postaction;
}
}
else
goto erroraction;
}
}
if (RTCHECK(ok_next(p, next) && ok_pinuse(next))) {
if (!cinuse(next)) { /* consolidate forward */
if (next == fm->top) {
size_t tsize = fm->topsize += psize;
fm->top = p;
p->head = tsize | PINUSE_BIT;
if (p == fm->dv) {
fm->dv = 0;
fm->dvsize = 0;
}
if (should_trim(fm, tsize))
sys_trim(fm, 0);
goto postaction;
}
else if (next == fm->dv) {
size_t dsize = fm->dvsize += psize;
fm->dv = p;
set_size_and_pinuse_of_free_chunk(p, dsize);
goto postaction;
}
else {
size_t nsize = chunksize(next);
psize += nsize;
unlink_chunk(fm, next, nsize);
set_size_and_pinuse_of_free_chunk(p, psize);
if (p == fm->dv) {
fm->dvsize = psize;
goto postaction;
}
}
}
else
set_free_with_pinuse(p, psize, next);
if (is_small(psize)) {
insert_small_chunk(fm, p, psize);
check_free_chunk(fm, p);
}
else {
tchunkptr tp = (tchunkptr)p;
insert_large_chunk(fm, tp, psize);
check_free_chunk(fm, p);
if (--fm->release_checks == 0)
release_unused_segments(fm);
}
goto postaction;
}
}
erroraction:
USAGE_ERROR_ACTION(fm, p);
postaction:
POSTACTION(fm);
}
}
}
void* mspace_calloc(mspace msp, size_t n_elements, size_t elem_size) {
void* mem;
size_t req = 0;
mstate ms = (mstate)msp;
if (!ok_magic(ms)) {
USAGE_ERROR_ACTION(ms,ms);
return 0;
}
if (n_elements != 0) {
req = n_elements * elem_size;
if (((n_elements | elem_size) & ~(size_t)0xffff) &&
(req / n_elements != elem_size))
req = MAX_SIZE_T; /* force downstream failure on overflow */
}
mem = internal_malloc(ms, req);
if (mem != 0 && calloc_must_clear(mem2chunk(mem)))
memset(mem, 0, req);
return mem;
}
void* mspace_realloc(mspace msp, void* oldmem, size_t bytes) {
void* mem = 0;
if (oldmem == 0) {
mem = mspace_malloc(msp, bytes);
}
else if (bytes >= MAX_REQUEST) {
MALLOC_FAILURE_ACTION;
}
#ifdef REALLOC_ZERO_BYTES_FREES
else if (bytes == 0) {
mspace_free(msp, oldmem);
}
#endif /* REALLOC_ZERO_BYTES_FREES */
else {
size_t nb = request2size(bytes);
mchunkptr oldp = mem2chunk(oldmem);
#if ! FOOTERS
mstate m = (mstate)msp;
#else /* FOOTERS */
mstate m = get_mstate_for(oldp);
if (!ok_magic(m)) {
USAGE_ERROR_ACTION(m, oldmem);
return 0;
}
#endif /* FOOTERS */
if (!PREACTION(m)) {
mchunkptr newp = try_realloc_chunk(m, oldp, nb, 1);
POSTACTION(m);
if (newp != 0) {
check_inuse_chunk(m, newp);
mem = chunk2mem(newp);
}
else {
mem = mspace_malloc(m, bytes);
if (mem != 0) {
size_t oc = chunksize(oldp) - overhead_for(oldp);
memcpy(mem, oldmem, (oc < bytes)? oc : bytes);
mspace_free(m, oldmem);
}
}
}
}
return mem;
}
void* mspace_realloc_in_place(mspace msp, void* oldmem, size_t bytes) {
void* mem = 0;
if (oldmem != 0) {
if (bytes >= MAX_REQUEST) {
MALLOC_FAILURE_ACTION;
}
else {
size_t nb = request2size(bytes);
mchunkptr oldp = mem2chunk(oldmem);
#if ! FOOTERS
mstate m = (mstate)msp;
#else /* FOOTERS */
mstate m = get_mstate_for(oldp);
(void)msp; /* placate people compiling -Wunused */
if (!ok_magic(m)) {
USAGE_ERROR_ACTION(m, oldmem);
return 0;
}
#endif /* FOOTERS */
if (!PREACTION(m)) {
mchunkptr newp = try_realloc_chunk(m, oldp, nb, 0);
POSTACTION(m);
if (newp == oldp) {
check_inuse_chunk(m, newp);
mem = oldmem;
}
}
}
}
return mem;
}
void* mspace_memalign(mspace msp, size_t alignment, size_t bytes) {
mstate ms = (mstate)msp;
if (!ok_magic(ms)) {
USAGE_ERROR_ACTION(ms,ms);
return 0;
}
if (alignment <= MALLOC_ALIGNMENT)
return mspace_malloc(msp, bytes);
return internal_memalign(ms, alignment, bytes);
}
void** mspace_independent_calloc(mspace msp, size_t n_elements,
size_t elem_size, void* chunks[]) {
size_t sz = elem_size; /* serves as 1-element array */
mstate ms = (mstate)msp;
if (!ok_magic(ms)) {
USAGE_ERROR_ACTION(ms,ms);
return 0;
}
return ialloc(ms, n_elements, &sz, 3, chunks);
}
void** mspace_independent_comalloc(mspace msp, size_t n_elements,
size_t sizes[], void* chunks[]) {
mstate ms = (mstate)msp;
if (!ok_magic(ms)) {
USAGE_ERROR_ACTION(ms,ms);
return 0;
}
return ialloc(ms, n_elements, sizes, 0, chunks);
}
size_t mspace_bulk_free(mspace msp, void* array[], size_t nelem) {
return internal_bulk_free((mstate)msp, array, nelem);
}
#if MALLOC_INSPECT_ALL
void mspace_inspect_all(mspace msp,
void(*handler)(void *start,
void *end,
size_t used_bytes,
void* callback_arg),
void* arg) {
mstate ms = (mstate)msp;
if (ok_magic(ms)) {
if (!PREACTION(ms)) {
internal_inspect_all(ms, handler, arg);
POSTACTION(ms);
}
}
else {
USAGE_ERROR_ACTION(ms,ms);
}
}
#endif /* MALLOC_INSPECT_ALL */
int mspace_trim(mspace msp, size_t pad) {
int result = 0;
mstate ms = (mstate)msp;
if (ok_magic(ms)) {
if (!PREACTION(ms)) {
result = sys_trim(ms, pad);
POSTACTION(ms);
}
}
else {
USAGE_ERROR_ACTION(ms,ms);
}
return result;
}
#if !NO_MALLOC_STATS
void mspace_malloc_stats(mspace msp) {
mstate ms = (mstate)msp;
if (ok_magic(ms)) {
internal_malloc_stats(ms);
}
else {
USAGE_ERROR_ACTION(ms,ms);
}
}
#endif /* NO_MALLOC_STATS */
size_t mspace_footprint(mspace msp) {
size_t result = 0;
mstate ms = (mstate)msp;
if (ok_magic(ms)) {
result = ms->footprint;
}
else {
USAGE_ERROR_ACTION(ms,ms);
}
return result;
}
size_t mspace_max_footprint(mspace msp) {
size_t result = 0;
mstate ms = (mstate)msp;
if (ok_magic(ms)) {
result = ms->max_footprint;
}
else {
USAGE_ERROR_ACTION(ms,ms);
}
return result;
}
size_t mspace_footprint_limit(mspace msp) {
size_t result = 0;
mstate ms = (mstate)msp;
if (ok_magic(ms)) {
size_t maf = ms->footprint_limit;
result = (maf == 0) ? MAX_SIZE_T : maf;
}
else {
USAGE_ERROR_ACTION(ms,ms);
}
return result;
}
size_t mspace_set_footprint_limit(mspace msp, size_t bytes) {
size_t result = 0;
mstate ms = (mstate)msp;
if (ok_magic(ms)) {
if (bytes == 0)
result = granularity_align(1); /* Use minimal size */
if (bytes == MAX_SIZE_T)
result = 0; /* disable */
else
result = granularity_align(bytes);
ms->footprint_limit = result;
}
else {
USAGE_ERROR_ACTION(ms,ms);
}
return result;
}
#if !NO_MALLINFO
struct mallinfo mspace_mallinfo(mspace msp) {
mstate ms = (mstate)msp;
if (!ok_magic(ms)) {
USAGE_ERROR_ACTION(ms,ms);
}
return internal_mallinfo(ms);
}
#endif /* NO_MALLINFO */
size_t mspace_usable_size(const void* mem) {
if (mem != 0) {
mchunkptr p = mem2chunk(mem);
if (is_inuse(p))
return chunksize(p) - overhead_for(p);
}
return 0;
}
int mspace_mallopt(int param_number, int value) {
return change_mparam(param_number, value);
}
#endif /* MSPACES */
/* -------------------- Alternative MORECORE functions ------------------- */
/*
Guidelines for creating a custom version of MORECORE:
* For best performance, MORECORE should allocate in multiples of pagesize.
* MORECORE may allocate more memory than requested. (Or even less,
but this will usually result in a malloc failure.)
* MORECORE must not allocate memory when given argument zero, but
instead return one past the end address of memory from previous
nonzero call.
* For best performance, consecutive calls to MORECORE with positive
arguments should return increasing addresses, indicating that
space has been contiguously extended.
* Even though consecutive calls to MORECORE need not return contiguous
addresses, it must be OK for malloc'ed chunks to span multiple
regions in those cases where they do happen to be contiguous.
* MORECORE need not handle negative arguments -- it may instead
just return MFAIL when given negative arguments.
Negative arguments are always multiples of pagesize. MORECORE
must not misinterpret negative args as large positive unsigned
args. You can suppress all such calls from even occurring by defining
MORECORE_CANNOT_TRIM,
As an example alternative MORECORE, here is a custom allocator
kindly contributed for pre-OSX macOS. It uses virtually but not
necessarily physically contiguous non-paged memory (locked in,
present and won't get swapped out). You can use it by uncommenting
this section, adding some #includes, and setting up the appropriate
defines above:
#define MORECORE osMoreCore
There is also a shutdown routine that should somehow be called for
cleanup upon program exit.
#define MAX_POOL_ENTRIES 100
#define MINIMUM_MORECORE_SIZE (64 * 1024U)
static int next_os_pool;
void *our_os_pools[MAX_POOL_ENTRIES];
void *osMoreCore(int size)
{
void *ptr = 0;
static void *sbrk_top = 0;
if (size > 0)
{
if (size < MINIMUM_MORECORE_SIZE)
size = MINIMUM_MORECORE_SIZE;
if (CurrentExecutionLevel() == kTaskLevel)
ptr = PoolAllocateResident(size + RM_PAGE_SIZE, 0);
if (ptr == 0)
{
return (void *) MFAIL;
}
// save ptrs so they can be freed during cleanup
our_os_pools[next_os_pool] = ptr;
next_os_pool++;
ptr = (void *) ((((size_t) ptr) + RM_PAGE_MASK) & ~RM_PAGE_MASK);
sbrk_top = (char *) ptr + size;
return ptr;
}
else if (size < 0)
{
// we don't currently support shrink behavior
return (void *) MFAIL;
}
else
{
return sbrk_top;
}
}
// cleanup any allocated memory pools
// called as last thing before shutting down driver
void osCleanupMem(void)
{
void **ptr;
for (ptr = our_os_pools; ptr < &our_os_pools[MAX_POOL_ENTRIES]; ptr++)
if (*ptr)
{
PoolDeallocate(*ptr);
*ptr = 0;
}
}
*/
/* -----------------------------------------------------------------------
History:
v2.8.6 Wed Aug 29 06:57:58 2012 Doug Lea
* fix bad comparison in dlposix_memalign
* don't reuse adjusted asize in sys_alloc
* add LOCK_AT_FORK -- thanks to Kirill Artamonov for the suggestion
* reduce compiler warnings -- thanks to all who reported/suggested these
v2.8.5 Sun May 22 10:26:02 2011 Doug Lea (dl at gee)
* Always perform unlink checks unless INSECURE
* Add posix_memalign.
* Improve realloc to expand in more cases; expose realloc_in_place.
Thanks to Peter Buhr for the suggestion.
* Add footprint_limit, inspect_all, bulk_free. Thanks
to Barry Hayes and others for the suggestions.
* Internal refactorings to avoid calls while holding locks
* Use non-reentrant locks by default. Thanks to Roland McGrath
for the suggestion.
* Small fixes to mspace_destroy, reset_on_error.
* Various configuration extensions/changes. Thanks
to all who contributed these.
V2.8.4a Thu Apr 28 14:39:43 2011 (dl at gee.cs.oswego.edu)
* Update Creative Commons URL
V2.8.4 Wed May 27 09:56:23 2009 Doug Lea (dl at gee)
* Use zeros instead of prev foot for is_mmapped
* Add mspace_track_large_chunks; thanks to Jean Brouwers
* Fix set_inuse in internal_realloc; thanks to Jean Brouwers
* Fix insufficient sys_alloc padding when using 16byte alignment
* Fix bad error check in mspace_footprint
* Adaptations for ptmalloc; thanks to Wolfram Gloger.
* Reentrant spin locks; thanks to Earl Chew and others
* Win32 improvements; thanks to Niall Douglas and Earl Chew
* Add NO_SEGMENT_TRAVERSAL and MAX_RELEASE_CHECK_RATE options
* Extension hook in malloc_state
* Various small adjustments to reduce warnings on some compilers
* Various configuration extensions/changes for more platforms. Thanks
to all who contributed these.
V2.8.3 Thu Sep 22 11:16:32 2005 Doug Lea (dl at gee)
* Add max_footprint functions
* Ensure all appropriate literals are size_t
* Fix conditional compilation problem for some #define settings
* Avoid concatenating segments with the one provided
in create_mspace_with_base
* Rename some variables to avoid compiler shadowing warnings
* Use explicit lock initialization.
* Better handling of sbrk interference.
* Simplify and fix segment insertion, trimming and mspace_destroy
* Reinstate REALLOC_ZERO_BYTES_FREES option from 2.7.x
* Thanks especially to Dennis Flanagan for help on these.
V2.8.2 Sun Jun 12 16:01:10 2005 Doug Lea (dl at gee)
* Fix memalign brace error.
V2.8.1 Wed Jun 8 16:11:46 2005 Doug Lea (dl at gee)
* Fix improper #endif nesting in C++
* Add explicit casts needed for C++
V2.8.0 Mon May 30 14:09:02 2005 Doug Lea (dl at gee)
* Use trees for large bins
* Support mspaces
* Use segments to unify sbrk-based and mmap-based system allocation,
removing need for emulation on most platforms without sbrk.
* Default safety checks
* Optional footer checks. Thanks to William Robertson for the idea.
* Internal code refactoring
* Incorporate suggestions and platform-specific changes.
Thanks to Dennis Flanagan, Colin Plumb, Niall Douglas,
Aaron Bachmann, Emery Berger, and others.
* Speed up non-fastbin processing enough to remove fastbins.
* Remove useless cfree() to avoid conflicts with other apps.
* Remove internal memcpy, memset. Compilers handle builtins better.
* Remove some options that no one ever used and rename others.
V2.7.2 Sat Aug 17 09:07:30 2002 Doug Lea (dl at gee)
* Fix malloc_state bitmap array misdeclaration
V2.7.1 Thu Jul 25 10:58:03 2002 Doug Lea (dl at gee)
* Allow tuning of FIRST_SORTED_BIN_SIZE
* Use PTR_UINT as type for all ptr->int casts. Thanks to John Belmonte.
* Better detection and support for non-contiguousness of MORECORE.
Thanks to Andreas Mueller, Conal Walsh, and Wolfram Gloger
* Bypass most of malloc if no frees. Thanks To Emery Berger.
* Fix freeing of old top non-contiguous chunk im sysmalloc.
* Raised default trim and map thresholds to 256K.
* Fix mmap-related #defines. Thanks to Lubos Lunak.
* Fix copy macros; added LACKS_FCNTL_H. Thanks to Neal Walfield.
* Branch-free bin calculation
* Default trim and mmap thresholds now 256K.
V2.7.0 Sun Mar 11 14:14:06 2001 Doug Lea (dl at gee)
* Introduce independent_comalloc and independent_calloc.
Thanks to Michael Pachos for motivation and help.
* Make optional .h file available
* Allow > 2GB requests on 32bit systems.
* new WIN32 sbrk, mmap, munmap, lock code from <[email protected]>.
Thanks also to Andreas Mueller <a.mueller at paradatec.de>,
and Anonymous.
* Allow override of MALLOC_ALIGNMENT (Thanks to Ruud Waij for
helping test this.)
* memalign: check alignment arg
* realloc: don't try to shift chunks backwards, since this
leads to more fragmentation in some programs and doesn't
seem to help in any others.
* Collect all cases in malloc requiring system memory into sysmalloc
* Use mmap as backup to sbrk
* Place all internal state in malloc_state
* Introduce fastbins (although similar to 2.5.1)
* Many minor tunings and cosmetic improvements
* Introduce USE_PUBLIC_MALLOC_WRAPPERS, USE_MALLOC_LOCK
* Introduce MALLOC_FAILURE_ACTION, MORECORE_CONTIGUOUS
Thanks to Tony E. Bennett <[email protected]> and others.
* Include errno.h to support default failure action.
V2.6.6 Sun Dec 5 07:42:19 1999 Doug Lea (dl at gee)
* return null for negative arguments
* Added Several WIN32 cleanups from Martin C. Fong <mcfong at yahoo.com>
* Add 'LACKS_SYS_PARAM_H' for those systems without 'sys/param.h'
(e.g. WIN32 platforms)
* Cleanup header file inclusion for WIN32 platforms
* Cleanup code to avoid Microsoft Visual C++ compiler complaints
* Add 'USE_DL_PREFIX' to quickly allow co-existence with existing
memory allocation routines
* Set 'malloc_getpagesize' for WIN32 platforms (needs more work)
* Use 'assert' rather than 'ASSERT' in WIN32 code to conform to
usage of 'assert' in non-WIN32 code
* Improve WIN32 'sbrk()' emulation's 'findRegion()' routine to
avoid infinite loop
* Always call 'fREe()' rather than 'free()'
V2.6.5 Wed Jun 17 15:57:31 1998 Doug Lea (dl at gee)
* Fixed ordering problem with boundary-stamping
V2.6.3 Sun May 19 08:17:58 1996 Doug Lea (dl at gee)
* Added pvalloc, as recommended by H.J. Liu
* Added 64bit pointer support mainly from Wolfram Gloger
* Added anonymously donated WIN32 sbrk emulation
* Malloc, calloc, getpagesize: add optimizations from Raymond Nijssen
* malloc_extend_top: fix mask error that caused wastage after
foreign sbrks
* Add linux mremap support code from HJ Liu
V2.6.2 Tue Dec 5 06:52:55 1995 Doug Lea (dl at gee)
* Integrated most documentation with the code.
* Add support for mmap, with help from
Wolfram Gloger ([email protected]).
* Use last_remainder in more cases.
* Pack bins using idea from [email protected]
* Use ordered bins instead of best-fit threshhold
* Eliminate block-local decls to simplify tracing and debugging.
* Support another case of realloc via move into top
* Fix error occuring when initial sbrk_base not word-aligned.
* Rely on page size for units instead of SBRK_UNIT to
avoid surprises about sbrk alignment conventions.
* Add mallinfo, mallopt. Thanks to Raymond Nijssen
([email protected]) for the suggestion.
* Add `pad' argument to malloc_trim and top_pad mallopt parameter.
* More precautions for cases where other routines call sbrk,
courtesy of Wolfram Gloger ([email protected]).
* Added macros etc., allowing use in linux libc from
H.J. Lu ([email protected])
* Inverted this history list
V2.6.1 Sat Dec 2 14:10:57 1995 Doug Lea (dl at gee)
* Re-tuned and fixed to behave more nicely with V2.6.0 changes.
* Removed all preallocation code since under current scheme
the work required to undo bad preallocations exceeds
the work saved in good cases for most test programs.
* No longer use return list or unconsolidated bins since
no scheme using them consistently outperforms those that don't
given above changes.
* Use best fit for very large chunks to prevent some worst-cases.
* Added some support for debugging
V2.6.0 Sat Nov 4 07:05:23 1995 Doug Lea (dl at gee)
* Removed footers when chunks are in use. Thanks to
Paul Wilson ([email protected]) for the suggestion.
V2.5.4 Wed Nov 1 07:54:51 1995 Doug Lea (dl at gee)
* Added malloc_trim, with help from Wolfram Gloger
([email protected]).
V2.5.3 Tue Apr 26 10:16:01 1994 Doug Lea (dl at g)
V2.5.2 Tue Apr 5 16:20:40 1994 Doug Lea (dl at g)
* realloc: try to expand in both directions
* malloc: swap order of clean-bin strategy;
* realloc: only conditionally expand backwards
* Try not to scavenge used bins
* Use bin counts as a guide to preallocation
* Occasionally bin return list chunks in first scan
* Add a few optimizations from [email protected]
V2.5.1 Sat Aug 14 15:40:43 1993 Doug Lea (dl at g)
* faster bin computation & slightly different binning
* merged all consolidations to one part of malloc proper
(eliminating old malloc_find_space & malloc_clean_bin)
* Scan 2 returns chunks (not just 1)
* Propagate failure in realloc if malloc returns 0
* Add stuff to allow compilation on non-ANSI compilers
from [email protected]
V2.5 Sat Aug 7 07:41:59 1993 Doug Lea (dl at g.oswego.edu)
* removed potential for odd address access in prev_chunk
* removed dependency on getpagesize.h
* misc cosmetics and a bit more internal documentation
* anticosmetics: mangled names in macros to evade debugger strangeness
* tested on sparc, hp-700, dec-mips, rs6000
with gcc & native cc (hp, dec only) allowing
Detlefs & Zorn comparison study (in SIGPLAN Notices.)
Trial version Fri Aug 28 13:14:29 1992 Doug Lea (dl at g.oswego.edu)
* Based loosely on libg++-1.2X malloc. (It retains some of the overall
structure of old version, but most details differ.)
*/
|
the_stack_data/218894362.c | #include<stdio.h>
int main(){
FILE *input1_file, *input2_file, *input3_file, *output_file;
input1_file = fopen("math.txt", "r");
input2_file = fopen("Bengali.txt", "r");
input3_file = fopen("English.txt","r");
output_file = fopen("Avarage.txt", "w");
int i,j,a,b,c;
float Avarage;
for(i=1;i<=10;i++){
fscanf(input1_file,"%d %d",&j ,&a);
fscanf(input2_file,"%d %d",&j ,&b);
fscanf(input3_file,"%d %d",&j ,&c);
Avarage = (float)(a+b+c)/3;
fprintf(output_file,"%d %f\n", i,Avarage);
}
fclose(input1_file);
fclose(input2_file);
fclose(input3_file);
fclose(output_file);
}
|
the_stack_data/179831033.c | #include <stdio.h>
int main (){
int a=10;
int b=5;
int c= a + b;
b=20;
a=10;
printf("O valor de a,b,c %d %d %d\n",a,b,c);
}
|
the_stack_data/75176.c | #include<stdio.h>
#include<stdlib.h>
// by debbah Mehdi Sofaine (MehdiSlik)
// note : in binarys search the vector must be sorted
// binary search of an element
int binary_search(int* vect ,int N,int x)
{
// debut :is the begin of vector vect
// fin : is the end of vector vect
// x :is the element we went to search
int debut =0 ; int fin= N-1,mil;
while( fin>=debut) {
mil=(int)((debut+fin)/2);
if (x==vect[mil]){
printf(" the element exist his index is :%d ",mil);
return mil;}
else if (x>vect[mil])debut=mil+1;
else fin=mil-1;
}
// if fin< debut
printf("the element doesnt exist ");
return -1 ;
}
int main(){
int n,i ;int * t,x;
printf("entre the size of the array :\n");
scanf("%d",&n);
//array allocation
t= (int*)(malloc(n* sizeof(int))) ;
//array initialization
for( i=0;i<n;i++){
*(t+i)=i+5;
fflush(stdin);
}
printf("\n show array: \n");
// array show
for( i=0;i<n;i++) {
printf("%d \t",t[i]);
}
printf("\n entre the element you went to search :");
fflush(stdin);
scanf("%d",&x);
int indexe=binary_search(t,n,x);
//printf("the indexe :%d",indexe);
}
|
the_stack_data/52630.c | #include <stdio.h>
int main(void)
{
int i;
printf("\nBitte geben Sie eine ganze Zahl ein: ");
scanf("%i", &i); /* Wartet auf die Eingabe */
printf("\nSie haben die Zahl %i eingegeben.", i);
return 0;
}
|
the_stack_data/43887119.c | #include <stdio.h>
#include <stdlib.h>
int main()
{
char nome[32];
fgets(nome, 32, stdin);
int i;
for(i = 0; i < 31; i++){
if(nome[i] == '\n'){
nome[i] = '\0';
break;
}
}
i--;
for(; i >= 0; i--){
printf("%c", nome[i]);
}
printf("\n");
return 0;
}
|
the_stack_data/150141958.c | #include<stdio.h>
int main(void)
{
int list[5], temp[5], i, j;
printf("Enter 5 numbers: ");
for(i = 0; i < 5; i++)
{
scanf("%d", &list[i]);
}
for(i = 0, j = 4; i < 5; i++, j--)
{
temp[i] = list[j];
}
for(i = 0; i < 5; i++)
{
printf("%d ", temp[i]);
}
printf("\n");
return 0;
}
|
the_stack_data/220455211.c | #include "stdio.h"
int main()
{
int a;
char c;
printf("Hello World\n");
exit(0);
}
|
the_stack_data/161080072.c | // Add two numbers
// Jordan Lewis
// March 2017
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv)
{
int x, y, sum;
char *error_msg = "Not a number; giving up\n";
char *thx = "Thanks for doing the right thing\n";
// get two numbers
printf("Gimme the first number: ");
if (scanf("%d", &x) == 0) {
printf(error_msg);
return 1;
} else {
printf(thx);
}
printf("Second number: ");
if (scanf("%d", &y) == 0) {
printf(error_msg);
return 1;
} else {
printf(thx);
}
// add numbers together
sum = x + y;
// print sum
printf("Sum = %d\n", sum);
return 0;
}
|
the_stack_data/95430.c | /*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Chris Torek.
*
* 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.
*
* $FreeBSD: src/lib/libc/stdio/asprintf.c,v 1.15 2009/03/02 04:11:42 das Exp $
* $DragonFly: src/lib/libc/stdio/asprintf.c,v 1.8 2006/03/02 18:05:30 joerg Exp $
*/
#include <stdarg.h>
#include <stdio.h>
int
asprintf(char ** __restrict s, const char * __restrict fmt, ...)
{
int ret;
va_list ap;
va_start(ap, fmt);
ret = vasprintf(s, fmt, ap);
va_end(ap);
return (ret);
}
|
the_stack_data/433216.c | #include <stdio.h>
int main()
{
int key = 10;
int a[key], b[key];
int temp = 0;
int j = 0; //偏移量
for (int i = 0; i < key; i++)
{
scanf("%d", &a[i]);
getchar();
}
scanf("%d", &j);
//进行排序
//逐一遍历每个元素
for (int k = 0; k < j; k++)
{
temp = a[key - 1];
for (int i = key - 1; i >= 0; i--)
{
if (i >= 1)
{
a[i] = a[i - 1];
}
else
{
a[i] = temp;
}
}
}
//输出数组
for (int i = 0; i < key; i++)
{
printf("%d", a[i]);
}
return 0;
}
|
the_stack_data/68888134.c | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: zkubli <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/09/18 13:10:23 by zkubli #+# #+# */
/* Updated: 2019/09/20 13:34:12 by zkubli ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strrchr(const char *s, int c)
{
int index;
index = 0;
while (s[index])
index++;
while (index >= 0)
{
if (s[index] == c)
return ((char *)(s + index));
index--;
}
return (0);
}
|
the_stack_data/97828.c | //퀵소트 사용
#include <stdio.h>
#include <stdlib.h>
int compare(const void* a, const void* b)
{
return *(int*)a - *(int*)b;
}
int main(void)
{
int n, list[1000001];
scanf("%d", &n);
for (int i = 0; i < n; i++)
scanf("%d", &list[i]);
qsort(list, n, sizeof(int), compare);
for (int i = 0; i < n; i++)
printf("%d\n", list[i]);
return 0;
}
|
the_stack_data/7949497.c |
#include <stdio.h>
#include <stdlib.h>
void scilab_rt_graduate_i0d0i0d0_d0d0d0(int scalarin0,
double scalarin1,
int scalarin2,
double scalarin3,
double* scalarout0,
double* scalarout1,
double* scalarout2)
{
printf("%d", scalarin0);
printf("%f", scalarin1);
printf("%d", scalarin2);
printf("%f", scalarin3);
*scalarout0 = rand();
*scalarout1 = rand();
*scalarout2 = rand();
}
|
the_stack_data/298132.c | #include <netinet/in.h>
#include <byteswap.h>
uint32_t ntohl(uint32_t n)
{
union { int i; char c; } u = { 1 };
return u.c ? bswap_32(n) : n;
}
|
the_stack_data/23574460.c | // Copyright 2008 Crip5 Dominique Pastre
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
void main(argc,argv)
int argc;
char *argv[];
{ char cmd[256]; // pour construire la commande (chaine de caracteres)
// le nombre d'arguments comprend le nom de l'executable
strcpy(cmd,"/usr/bin/swipl -f muscadet-fr -g true ");
if (argc >= 2 ) {
strcat(cmd," <<! 2> /dev/null \n tptp(["); // tptp([
int i;
strcat(cmd,"'"); //
strcat(cmd,argv[1]); // 'probleme ou chemin'
strcat(cmd,"'"); //
for (i=2;i<argc;i++) {
strcat(cmd, ","); // ,
strcat(cmd, argv[i]); // autres arguments
}
strcat(cmd, "]). \n halt. \n ! . "); // ]).
// alt.
// ! .
printf("\ncommande generee : \n%s\n",cmd);
}
else strcpy(cmd, "more tptp-commandes");
system(cmd); // pour executer la commande
return;
}
|
the_stack_data/371401.c | #include <stdio.h>
int *Enqueue(int arr[],int max);//This Function will Enter Elements in Queue.
int *Dequeue(int arr[]);//This Function will Delete Elements From Front of Queue.
void *Display(int arr[]);//This Function will Show the Elements of Queue.
//front and rear will hold the first and last element's position in the array.
int front=-1,rear=-1;//initially they are -1 because array elements start from 0
int main()
{
int max,choice;//max will be the array size.
printf("\nEnter the number of Elements You want to Enter inside Array\n");
scanf("%d",&max);
int arr[max];
while(1)
{
printf("\n1> Enqueue\n");
printf("\n2> Dequeue\n");
printf("\n3> Display\n");
printf("\n4> Exit\n");
printf("\n\nEnter Your choice\n");
scanf("%d",&choice);
switch(choice)
{
case 1:
Enqueue(&arr[0],max);
break;
case 2:
Dequeue(&arr[0]);
break;
case 3:
Display(&arr[0]);
break;
case 4:
return 0;
default:
printf("\nEnter Correct Choice\n");
}
}
return 0;
}
int *Enqueue(int arr[],int max)
{
int ITEM;//ITEM will be the element inserted in Queue.
if(rear==max-1)//This condition will check whether the queue is full or not.
{
printf("\nQueue is Full\n");
return arr;
}
else
{
if(rear==-1 && front==-1)//initially both are incremented to hold the first element's position number in array.
front=0;
rear=rear+1;//rear will hold the last element's position number in array.
printf("\nEnter The Integer You Want To Enter Inside Queue\n");
scanf("%d",&ITEM);
arr[rear]=ITEM;
}
return arr;
}
int *Dequeue(int arr[])
{
if(front==-1)//This will check whether the queue is empty or not.
{
printf("\nQueue is Empty\n");
return arr;
}
else
{
int ITEM;//ITEM will be assigned the first element of the array.
ITEM=arr[front];
if(front==rear)//when Queue contains only one Element
{
rear=-1;
front=-1;
}
else//When Queue contains more than one Element.
front=front+1;
printf("\nItem Inside Queue is Successfully Deleted\n");
}
return arr;
}
void *Display(int arr[])
{
int i;
if(front==-1)//when front is set -1 it implies Queue is Empty.
{
printf("\nQueue is Empty\n");
return arr;
}
for(i=front;i<=rear;i++)//prints the elements in Queue from front to rear position.
{
printf("%d\t",arr[i]);
}
printf("\n");
return arr;
} |
the_stack_data/116115.c | #include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main()
{
int monsters;
scanf("%d", &monsters);
int paths;
scanf("%d", &paths);
int power;
scanf("%d", &power);
int end;
scanf("%d", &end);
int Map[monsters][monsters];//adjacecy matrix
memset(Map,0,sizeof(Map));
int monster[monsters];
for(int x=0; x<monsters; x++)
{
scanf("%d", monster+x);
}
for(int x=0; x<paths; x++)
{
int from, to;
scanf("%d %d", &from, &to);
Map[from][to]=1;
}
// printf("pass\n");
int loses=0, wins=0;
int stack[paths];
memset(stack,-1,sizeof(stack));
int sidx=0;
stack[0]=0;
while(sidx>=0 && power<end)//stack
{
int curmon=stack[sidx];
--sidx;
if(power>monster[curmon])
{
power+=monster[curmon];
for(int x=monsters-1; x>=0; x--)
{
if(Map[curmon][x])
{
++sidx;
stack[sidx]=x;
}
}
++wins;
continue;
}
++loses;
}
printf("%d %d %d\n", loses, wins, power);
return 0;
}
|
the_stack_data/131653.c | /*
* sgen-protocol.c: Binary protocol of internal activity, to aid
* debugging.
*
* Copyright 2001-2003 Ximian, Inc
* Copyright 2003-2010 Novell, Inc.
* Copyright (C) 2012 Xamarin Inc
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License 2.0 as published by the Free Software Foundation;
*
* 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 2.0 along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifdef HAVE_SGEN_GC
#include "config.h"
#include "sgen-conf.h"
#include "sgen-gc.h"
#include "sgen-protocol.h"
#include "sgen-memory-governor.h"
#include "sgen-thread-pool.h"
#include "sgen-client.h"
#include "mono/utils/mono-membar.h"
#include <errno.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#include <fcntl.h>
#endif
/* FIXME Implement binary protocol IO on systems that don't have unistd */
#ifdef HAVE_UNISTD_H
/* If valid, dump binary protocol to this file */
static int binary_protocol_file = -1;
/* We set this to -1 to indicate an exclusive lock */
static volatile int binary_protocol_use_count = 0;
#define BINARY_PROTOCOL_BUFFER_SIZE (65536 - 2 * 8)
typedef struct _BinaryProtocolBuffer BinaryProtocolBuffer;
struct _BinaryProtocolBuffer {
BinaryProtocolBuffer * volatile next;
volatile int index;
unsigned char buffer [BINARY_PROTOCOL_BUFFER_SIZE];
};
static BinaryProtocolBuffer * volatile binary_protocol_buffers = NULL;
static char* filename_or_prefix = NULL;
static int current_file_index = 0;
static long long current_file_size = 0;
static long long file_size_limit;
static char*
filename_for_index (int index)
{
char *filename;
SGEN_ASSERT (0, file_size_limit > 0, "Indexed binary protocol filename must only be used with file size limit");
filename = sgen_alloc_internal_dynamic (strlen (filename_or_prefix) + 32, INTERNAL_MEM_BINARY_PROTOCOL, TRUE);
sprintf (filename, "%s.%d", filename_or_prefix, index);
return filename;
}
static void
free_filename (char *filename)
{
SGEN_ASSERT (0, file_size_limit > 0, "Indexed binary protocol filename must only be used with file size limit");
sgen_free_internal_dynamic (filename, strlen (filename_or_prefix) + 32, INTERNAL_MEM_BINARY_PROTOCOL);
}
static void
binary_protocol_open_file (void)
{
char *filename;
if (file_size_limit > 0)
filename = filename_for_index (current_file_index);
else
filename = filename_or_prefix;
do {
binary_protocol_file = open (filename, O_CREAT|O_WRONLY|O_TRUNC, 0644);
if (binary_protocol_file == -1 && errno != EINTR)
break; /* Failed */
} while (binary_protocol_file == -1);
if (file_size_limit > 0)
free_filename (filename);
}
#endif
void
binary_protocol_init (const char *filename, long long limit)
{
#ifdef HAVE_UNISTD_H
filename_or_prefix = sgen_alloc_internal_dynamic (strlen (filename) + 1, INTERNAL_MEM_BINARY_PROTOCOL, TRUE);
strcpy (filename_or_prefix, filename);
file_size_limit = limit;
binary_protocol_open_file ();
#endif
}
gboolean
binary_protocol_is_enabled (void)
{
#ifdef HAVE_UNISTD_H
return binary_protocol_file != -1;
#else
return FALSE;
#endif
}
#ifdef HAVE_UNISTD_H
static void
close_binary_protocol_file (void)
{
while (close (binary_protocol_file) == -1 && errno == EINTR)
;
binary_protocol_file = -1;
}
static gboolean
try_lock_exclusive (void)
{
do {
if (binary_protocol_use_count)
return FALSE;
} while (InterlockedCompareExchange (&binary_protocol_use_count, -1, 0) != 0);
mono_memory_barrier ();
return TRUE;
}
static void
unlock_exclusive (void)
{
mono_memory_barrier ();
SGEN_ASSERT (0, binary_protocol_use_count == -1, "Exclusively locked count must be -1");
if (InterlockedCompareExchange (&binary_protocol_use_count, 0, -1) != -1)
SGEN_ASSERT (0, FALSE, "Somebody messed with the exclusive lock");
}
static void
lock_recursive (void)
{
int old_count;
do {
retry:
old_count = binary_protocol_use_count;
if (old_count < 0) {
/* Exclusively locked - retry */
/* FIXME: short back-off */
goto retry;
}
} while (InterlockedCompareExchange (&binary_protocol_use_count, old_count + 1, old_count) != old_count);
mono_memory_barrier ();
}
static void
unlock_recursive (void)
{
int old_count;
mono_memory_barrier ();
do {
old_count = binary_protocol_use_count;
SGEN_ASSERT (0, old_count > 0, "Locked use count must be at least 1");
} while (InterlockedCompareExchange (&binary_protocol_use_count, old_count - 1, old_count) != old_count);
}
static void
binary_protocol_flush_buffer (BinaryProtocolBuffer *buffer)
{
ssize_t ret;
size_t to_write = buffer->index;
size_t written = 0;
g_assert (buffer->index > 0);
while (written < to_write) {
ret = write (binary_protocol_file, buffer->buffer + written, to_write - written);
if (ret >= 0)
written += ret;
else if (errno == EINTR)
continue;
else
close_binary_protocol_file ();
}
current_file_size += buffer->index;
sgen_free_os_memory (buffer, sizeof (BinaryProtocolBuffer), SGEN_ALLOC_INTERNAL);
}
static void
binary_protocol_check_file_overflow (void)
{
if (file_size_limit <= 0 || current_file_size < file_size_limit)
return;
close_binary_protocol_file ();
if (current_file_index > 0) {
char *filename = filename_for_index (current_file_index - 1);
unlink (filename);
free_filename (filename);
}
++current_file_index;
current_file_size = 0;
binary_protocol_open_file ();
}
#endif
/*
* Flushing buffers takes an exclusive lock, so it must only be done when the world is
* stopped, otherwise we might end up with a deadlock because a stopped thread owns the
* lock.
*
* The protocol entries that do flush have `FLUSH()` in their definition.
*/
void
binary_protocol_flush_buffers (gboolean force)
{
#ifdef HAVE_UNISTD_H
int num_buffers = 0, i;
BinaryProtocolBuffer *buf;
BinaryProtocolBuffer **bufs;
if (binary_protocol_file == -1)
return;
if (!force && !try_lock_exclusive ())
return;
for (buf = binary_protocol_buffers; buf != NULL; buf = buf->next)
++num_buffers;
bufs = sgen_alloc_internal_dynamic (num_buffers * sizeof (BinaryProtocolBuffer*), INTERNAL_MEM_BINARY_PROTOCOL, TRUE);
for (buf = binary_protocol_buffers, i = 0; buf != NULL; buf = buf->next, i++)
bufs [i] = buf;
SGEN_ASSERT (0, i == num_buffers, "Binary protocol buffer count error");
binary_protocol_buffers = NULL;
for (i = num_buffers - 1; i >= 0; --i) {
binary_protocol_flush_buffer (bufs [i]);
binary_protocol_check_file_overflow ();
}
sgen_free_internal_dynamic (buf, num_buffers * sizeof (BinaryProtocolBuffer*), INTERNAL_MEM_BINARY_PROTOCOL);
if (!force)
unlock_exclusive ();
#endif
}
#ifdef HAVE_UNISTD_H
static BinaryProtocolBuffer*
binary_protocol_get_buffer (int length)
{
BinaryProtocolBuffer *buffer, *new_buffer;
retry:
buffer = binary_protocol_buffers;
if (buffer && buffer->index + length <= BINARY_PROTOCOL_BUFFER_SIZE)
return buffer;
new_buffer = sgen_alloc_os_memory (sizeof (BinaryProtocolBuffer), SGEN_ALLOC_INTERNAL | SGEN_ALLOC_ACTIVATE, "debugging memory");
new_buffer->next = buffer;
new_buffer->index = 0;
if (InterlockedCompareExchangePointer ((void**)&binary_protocol_buffers, new_buffer, buffer) != buffer) {
sgen_free_os_memory (new_buffer, sizeof (BinaryProtocolBuffer), SGEN_ALLOC_INTERNAL);
goto retry;
}
return new_buffer;
}
#endif
static void
protocol_entry (unsigned char type, gpointer data, int size)
{
#ifdef HAVE_UNISTD_H
int index;
BinaryProtocolBuffer *buffer;
if (binary_protocol_file == -1)
return;
if (sgen_thread_pool_is_thread_pool_thread (mono_native_thread_id_get ()))
type |= 0x80;
lock_recursive ();
retry:
buffer = binary_protocol_get_buffer (size + 1);
retry_same_buffer:
index = buffer->index;
if (index + 1 + size > BINARY_PROTOCOL_BUFFER_SIZE)
goto retry;
if (InterlockedCompareExchange (&buffer->index, index + 1 + size, index) != index)
goto retry_same_buffer;
/* FIXME: if we're interrupted at this point, we have a buffer
entry that contains random data. */
buffer->buffer [index++] = type;
memcpy (buffer->buffer + index, data, size);
index += size;
g_assert (index <= BINARY_PROTOCOL_BUFFER_SIZE);
unlock_recursive ();
#endif
}
#define TYPE_INT int
#define TYPE_LONGLONG long long
#define TYPE_SIZE size_t
#define TYPE_POINTER gpointer
#define TYPE_BOOL gboolean
#define BEGIN_PROTOCOL_ENTRY0(method) \
void method (void) { \
int __type = PROTOCOL_ID(method); \
gpointer __data = NULL; \
int __size = 0; \
CLIENT_PROTOCOL_NAME (method) ();
#define BEGIN_PROTOCOL_ENTRY1(method,t1,f1) \
void method (t1 f1) { \
PROTOCOL_STRUCT(method) __entry = { f1 }; \
int __type = PROTOCOL_ID(method); \
gpointer __data = &__entry; \
int __size = sizeof (PROTOCOL_STRUCT(method)); \
CLIENT_PROTOCOL_NAME (method) (f1);
#define BEGIN_PROTOCOL_ENTRY2(method,t1,f1,t2,f2) \
void method (t1 f1, t2 f2) { \
PROTOCOL_STRUCT(method) __entry = { f1, f2 }; \
int __type = PROTOCOL_ID(method); \
gpointer __data = &__entry; \
int __size = sizeof (PROTOCOL_STRUCT(method)); \
CLIENT_PROTOCOL_NAME (method) (f1, f2);
#define BEGIN_PROTOCOL_ENTRY3(method,t1,f1,t2,f2,t3,f3) \
void method (t1 f1, t2 f2, t3 f3) { \
PROTOCOL_STRUCT(method) __entry = { f1, f2, f3 }; \
int __type = PROTOCOL_ID(method); \
gpointer __data = &__entry; \
int __size = sizeof (PROTOCOL_STRUCT(method)); \
CLIENT_PROTOCOL_NAME (method) (f1, f2, f3);
#define BEGIN_PROTOCOL_ENTRY4(method,t1,f1,t2,f2,t3,f3,t4,f4) \
void method (t1 f1, t2 f2, t3 f3, t4 f4) { \
PROTOCOL_STRUCT(method) __entry = { f1, f2, f3, f4 }; \
int __type = PROTOCOL_ID(method); \
gpointer __data = &__entry; \
int __size = sizeof (PROTOCOL_STRUCT(method)); \
CLIENT_PROTOCOL_NAME (method) (f1, f2, f3, f4);
#define BEGIN_PROTOCOL_ENTRY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) \
void method (t1 f1, t2 f2, t3 f3, t4 f4, t5 f5) { \
PROTOCOL_STRUCT(method) __entry = { f1, f2, f3, f4, f5 }; \
int __type = PROTOCOL_ID(method); \
gpointer __data = &__entry; \
int __size = sizeof (PROTOCOL_STRUCT(method)); \
CLIENT_PROTOCOL_NAME (method) (f1, f2, f3, f4, f5);
#define BEGIN_PROTOCOL_ENTRY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) \
void method (t1 f1, t2 f2, t3 f3, t4 f4, t5 f5, t6 f6) { \
PROTOCOL_STRUCT(method) __entry = { f1, f2, f3, f4, f5, f6 }; \
int __type = PROTOCOL_ID(method); \
gpointer __data = &__entry; \
int __size = sizeof (PROTOCOL_STRUCT(method)); \
CLIENT_PROTOCOL_NAME (method) (f1, f2, f3, f4, f5, f6);
#define FLUSH() \
binary_protocol_flush_buffers (FALSE);
#define DEFAULT_PRINT()
#define CUSTOM_PRINT(_)
#define IS_ALWAYS_MATCH(_)
#define MATCH_INDEX(_)
#define IS_VTABLE_MATCH(_)
#define END_PROTOCOL_ENTRY \
protocol_entry (__type, __data, __size); \
}
#ifdef SGEN_HEAVY_BINARY_PROTOCOL
#define BEGIN_PROTOCOL_ENTRY_HEAVY0(method) \
BEGIN_PROTOCOL_ENTRY0 (method)
#define BEGIN_PROTOCOL_ENTRY_HEAVY1(method,t1,f1) \
BEGIN_PROTOCOL_ENTRY1 (method,t1,f1)
#define BEGIN_PROTOCOL_ENTRY_HEAVY2(method,t1,f1,t2,f2) \
BEGIN_PROTOCOL_ENTRY2 (method,t1,f1,t2,f2)
#define BEGIN_PROTOCOL_ENTRY_HEAVY3(method,t1,f1,t2,f2,t3,f3) \
BEGIN_PROTOCOL_ENTRY3 (method,t1,f1,t2,f2,t3,f3)
#define BEGIN_PROTOCOL_ENTRY_HEAVY4(method,t1,f1,t2,f2,t3,f3,t4,f4) \
BEGIN_PROTOCOL_ENTRY4 (method,t1,f1,t2,f2,t3,f3,t4,f4)
#define BEGIN_PROTOCOL_ENTRY_HEAVY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) \
BEGIN_PROTOCOL_ENTRY5 (method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5)
#define BEGIN_PROTOCOL_ENTRY_HEAVY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) \
BEGIN_PROTOCOL_ENTRY6 (method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6)
#define END_PROTOCOL_ENTRY_HEAVY \
END_PROTOCOL_ENTRY
#else
#define BEGIN_PROTOCOL_ENTRY_HEAVY0(method)
#define BEGIN_PROTOCOL_ENTRY_HEAVY1(method,t1,f1)
#define BEGIN_PROTOCOL_ENTRY_HEAVY2(method,t1,f1,t2,f2)
#define BEGIN_PROTOCOL_ENTRY_HEAVY3(method,t1,f1,t2,f2,t3,f3)
#define BEGIN_PROTOCOL_ENTRY_HEAVY4(method,t1,f1,t2,f2,t3,f3,t4,f4)
#define BEGIN_PROTOCOL_ENTRY_HEAVY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5)
#define BEGIN_PROTOCOL_ENTRY_HEAVY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6)
#define END_PROTOCOL_ENTRY_HEAVY
#endif
#include "sgen-protocol-def.h"
#undef TYPE_INT
#undef TYPE_LONGLONG
#undef TYPE_SIZE
#undef TYPE_POINTER
#undef TYPE_BOOL
#endif /* HAVE_SGEN_GC */
|
the_stack_data/150143540.c | void printf(char *format);
void assert_fail(void);
int a, b;
int *p1, *p2;
int f() {
int v = *p1 + *p2 - a;
if (v == 1) {
p1 = p2;
return v;
} else {
return 0;
}
}
int main() {
p1 = &a;
p2 = &b;
b = 1;
a = 5;
a--;
a = f();
*p1 = 1000;
if (*p2 != 1000) {
printf("ERROR\n");
assert_fail();
goto ERROR;
}
return 0;
ERROR:
return 1;
}
|
the_stack_data/550439.c | /**
* @brief Test tool for libc printf formatters.
*
* @copyright
* This file is part of ToaruOS and is released under the terms
* of the NCSA / University of Illinois License - see LICENSE.md
* Copyright (C) 2020-2021 K. Lange
*/
#include <stdio.h>
int main(int argc, char * argv[]) {
printf("%.3d\n", 42);
printf("%.10d\n", 12345);
printf("%.1d\n", 0);
printf("%.0d\n", 0);
printf("%.0d\n", 1);
printf("%.0d\n", 123);
return 0;
}
|
the_stack_data/212643547.c | #include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <inttypes.h>
int x=1, y=2;
int main() {
uintptr_t ux = (uintptr_t)&x;
uintptr_t uy = (uintptr_t)&y;
uintptr_t offset = uy - ux;
printf("Addresses: &x=%"PRIuPTR" &y=%"PRIuPTR\
" offset=%"PRIuPTR" \n",(unsigned long)ux,(unsigned long)uy,(unsigned long)offset);
int *p = (int *)(ux + offset);
int *q = &y;
if (memcmp(&p, &q, sizeof(p)) == 0) {
*p = 11; // is this free of UB?
printf("x=%d y=%d *p=%d *q=%d\n",x,y,*p,*q);
}
}
|
the_stack_data/481700.c | #include <stdio.h>
#include <string.h>
#include <math.h>
#define WIDTH 100009
#define BASE 10000000
#define FORMAT "%07d"
int P[] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59,
61, 67, 71, 73, 79, 83, 89, 97 };
int T[100], C[100], D;
double A;
int E[WIDTH], Etop;
double L[sizeof(P) / sizeof(int)];
void dfs(int p, int n, double a);
int main(void)
{
int n, i, j, k;
#ifdef DEBUG
freopen("in", "r", stdin);
#endif
scanf("%d", &n);
for (i = 0; i < sizeof(P) / sizeof(int); ++i)
L[i] = log(P[i]);
A = 100000000000000;
dfs(0, n, 1);
E[0] = 1;
Etop = 1;
for (i = 0; i < D; ++i) {
--T[i];
for (j = 0; j < T[i]; ++j) {
for (k = 0; k < Etop; ++k)
E[k] *= P[i];
for (k = 0; k < Etop; ++k)
if (E[k] >= BASE) {
E[k + 1] += E[k] / BASE;
E[k] %= BASE;
}
while (E[Etop]) {
E[Etop + 1] += E[Etop] / BASE;
E[Etop++] %= BASE;
}
}
}
if (Etop == 0) {
putchar('0');
} else {
printf("%d", E[Etop - 1]);
for (i = Etop - 2; i >= 0; --i)
printf(FORMAT, E[i]);
}
putchar('\n');
return 0;
}
void dfs(int p, int n, double a)
{
int i;
if (p >= 16 || a > A)
return;
if (n == 1) {
if (a < A) {
A = a;
D = p;
memcpy(T, C, sizeof(C));
}
return;
}
for (i = 1; i * i <= n; ++i)
if (n % i == 0) {
if (i != 1) {
C[p] = i;
dfs(p + 1, n / i, a + (i - 1) * L[p]);
}
if (i * i != n) {
C[p] = n / i;
dfs(p + 1, i, a + (n / i - 1) * L[p]);
}
C[p] = 0;
}
}
|
the_stack_data/88964.c | #include <locale.h>
#include <time.h>
size_t strftime_l(char *restrict s, size_t n, const char *restrict f, const struct tm *restrict tm, locale_t l)
{
return strftime(s, n, f, tm);
}
|
the_stack_data/61075922.c | // Copyright (c) 2018 Alessandro Vinciguerra
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[]) {
if (argc != 2) {
return 1;
}
int freq = 0;
int reached[1000000];
int fcount = 1;
FILE* input = fopen(argv[1], "r");
char line[10];
while (1) {
while (fgets(line, sizeof(line), input)) {
freq += (int)strtol(line, (char**)NULL, 0);
reached[fcount++] = freq;
for (int i = 0; i < fcount - 1; i++) {
if (freq == reached[i]) {
printf("Duplicate frequency (index %d): %d\n", fcount, freq);
fclose(input);
return 0;
}
}
}
rewind(input);
}
}
|
the_stack_data/27126.c | /* { dg-do compile } */
/* { dg-require-effective-target fpic } */
/* { dg-options "-fPIC" } */
typedef int int64_t __attribute__ ((__mode__ ( __DI__ ))) ;
unsigned *
bar (int64_t which)
{
switch (which & 15 ) {
case 0 :
break;
case 1 :
case 5 :
case 2 : ;
}
return 0;
}
|
the_stack_data/1177388.c | /*
Web Server
*/
#include <unistd.h> // fuer read, write etc.
#include <stdlib.h> // fuer exit
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <time.h>
#include <sys/stat.h>
#define MAX_SOCK 10
#define URI_SIZE 255
#define CHUNK_SIZE 255
#define MAX_PATHLENGTH 255
#define DATE_SIZE 32
#define DATE_FORMAT "%a, %e %b %G %T GTM+1"
// Vorwaertsdeklarationen intern
void scan_request(int sockfd, char* rootDir);
void send_error(int sockfd, const char* version, const int code, const char* text);
void generate_timeString(time_t timer, char* output);
void generate_okHeader(const char* filepath, char* output);
void send_post_calculation(int sockfd, int num1, int num2);
void send_html(int sockfd, const char* path, const char* version);
void err_abort(char *str);
int main(int argc, char *argv[]) {
if(argc < 3){
err_abort("Missing Arguments! Syntax: httpserv [rootDir] [port]");
}
// Argumente prüden
char* rootDir = argv[1];
int port = atoi(argv[2]);
if(port <= 1024){
err_abort("Port reserved!");
}
printf("starting server on port: %d, rootDir: %s\n", port, rootDir);
// Deskriptoren, Adresslaenge, Prozess-ID
int sockfd, newsockfd, alen, pid;
int reuse = 1;
// Socket Adressen
struct sockaddr_in cli_addr, srv_addr;
// TCP-Socket erzeugen
if((sockfd=socket(AF_INET, SOCK_STREAM, 0)) < 0) {
err_abort("Kann Stream-Socket nicht oeffnen!");
}void send_file(int sockfd, const char* path, const char* version);
if(setsockopt(sockfd,SOL_SOCKET,SO_REUSEADDR,&reuse,sizeof(reuse))<0){
err_abort("Kann Socketoption nicht setzen!");
}
// Binden der lokalen Adresse damit Clients uns erreichen
memset((void *)&srv_addr, '\0', sizeof(srv_addr));
srv_addr.sin_family = AF_INET;
srv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
srv_addr.sin_port = htons(port);
if( bind(sockfd, (struct sockaddr *)&srv_addr,
sizeof(srv_addr)) < 0 ) {
err_abort("Kann lokale Adresse nicht binden, laeuft fremder Server?");
}
// Warteschlange fuer TCP-Socket einrichten
listen(sockfd,5);
printf("Web Server: bereit ...\n");
for(;;){
alen = sizeof(cli_addr);
// Verbindung aufbauen
newsockfd = accept(sockfd,(struct sockaddr *)&cli_addr,&alen);
if(newsockfd < 0){
err_abort("Fehler beim Verbindungsaufbau!");
}
// fuer jede Verbindung einen Kindprozess erzeugen
if((pid = fork()) < 0){
err_abort("Fehler beim Erzeugen eines Kindprozesses!");
}else if(pid == 0){
close(sockfd);
scan_request(newsockfd, rootDir);
//close(newsockfd);
exit(0);
}
close(newsockfd);
}
}
/*
scan_request: Lesen von Daten vom Socket und an den Client zuruecksenden
*/
void scan_request(int sockfd, char* rootDir){
int n;
int headerSize = 1;
char requestBuffer[URI_SIZE+1];
char* request = (char*)malloc(sizeof(char)*URI_SIZE);
for(;;){
n = read(sockfd,requestBuffer,URI_SIZE);
requestBuffer[n] = '\0';
sprintf( request, "%s%s", request, requestBuffer);
//printf("reqBuffer part %d\n%s\n\n", headerSize, requestBuffer);
if(n==0){
err_abort("Header empty\n");
}else if(n < 0){
err_abort("Fehler beim Lesen des Sockets!");
}else if(n < URI_SIZE /*|| strstr(request,"\r\n\r\n")*/){
printf("Request komplett (%d chunks)!\n", headerSize);
break;
}
headerSize++;
request = realloc(request, headerSize * sizeof(char)*URI_SIZE);
}
//printf("received request:\n%s\n", request);
char* header = request;
char* body = strstr(request, "\r\n\r\n");
header[body - header] = '\0';
body = &body[4];
printf("header:\n%s\n", header);
printf("body:\n%s\n", body);
char* command = strtok(header, " ");
printf("command: %s\n", command);
if( strcmp(command,"GET") == 0 ){
char path[MAX_PATHLENGTH];
sprintf(path, "%s%s", rootDir, strtok(NULL, " "));
char* version;
version = strtok(NULL, "\n");
printf("path: %s\nversion: %s\n", path, version);
free(request);
send_html(sockfd, path, version);
} else if ( strcmp(command,"POST") == 0 ){
strtok(body, "=");
int num1 = atoi(strtok(NULL, "&"));
strtok(NULL, "=");
int num2 = atoi(strtok(NULL, "&"));
free(request);
send_post_calculation(sockfd, num1, num2);
} else {
free(request);
err_abort("Header invalid!\n");
}
}
void send_error(int sockfd, const char* version, const int code, const char* text){
char response[URI_SIZE];
sprintf(response, "HTTP/1.1 %d %s\r\n\r\n%s\r\n\r\n", code, text, text);
int n = strlen(response);
printf("sending: %s\n", response);
if(write(sockfd, response, n) != n){
err_abort("Fehler beim Schreiben des Sockets!");
}
}
void generate_timeString(time_t timer, char* output){
struct tm* tm_info = localtime(&timer);
strftime(output, DATE_SIZE, DATE_FORMAT, tm_info);
}
void generate_okHeader(const char* filepath, char* output){
time_t timer;
time(&timer);
char now[DATE_SIZE];
generate_timeString(timer, now);
char modified[DATE_SIZE];
if(filepath != NULL){
struct stat attr;
stat(filepath, &attr);
generate_timeString(attr.st_mtime, modified);
}
else {
memcpy(modified, now, sizeof(modified));
}
if(strstr(filepath, ".png"))
{
sprintf(
output,
"HTTP/1.1 200 OK\nDate: %s\nLast-Modified: %s\nContent-Language: de\nContent-Type: image/png; charset=utf-8\r\n\r\n",
now,
modified
);
}
else
{
sprintf(
output,
"HTTP/1.1 200 OK\nDate: %s\nLast-Modified: %s\nContent-Language: de\nContent-Type: text/html; charset=utf-8\r\n\r\n",
now,
modified
);
}
}
void send_post_calculation(int sockfd, int num1, int num2){
char response[CHUNK_SIZE+1];
memset(response, '\0', CHUNK_SIZE+1);
generate_okHeader( NULL, response );
sprintf(
response,
"%s<HTML><BODY><center><h1> Ergebnis: %d</h1></center></BODY></HTML>",
response,
num1 * num2
);
if(write(sockfd, response, strlen(response)) != strlen(response)){
err_abort("Fehler beim Schreiben des Sockets!");
}
}
void send_html(int sockfd, const char* path, const char* version){
FILE* file = fopen( path, "r" );
if( file == NULL ){
send_error(sockfd, version, 404, "Not Found");
return;
}
char response[CHUNK_SIZE+1];
memset(response, '\0', CHUNK_SIZE+1);
generate_okHeader( path, response );
int n;
for(int i = 0;;i++){
//if first response sub headerbytes
int resLength = (int)strlen(response);
if( resLength > 0 ){
printf("\nsprintf\n");
//char chunk[CHUNK_SIZE-resLength+1];
//n = fread(chunk, 1, CHUNK_SIZE-resLength, file);
//chunk[n] = '\0';
//response[resLength] = *chunk;
//sprintf(response, "%s%s", response, chunk);
//n += resLength;
n=resLength;
}
else{
printf("\nSPRINTF\n");
n = fread(response, 1, CHUNK_SIZE, file);
}
printf("response (i: %d l: %d):\n%s\n\n", i, n,response);
if(write(sockfd, response, n) != n){
err_abort("Fehler beim Schreiben des Sockets!");
}
//break if chunk is not filled on cap
if( n < CHUNK_SIZE && resLength == 0){
printf("HTML-Transfer vollendet!\n");
break;
}
//clear response for next chunk
memset(response, '\0', CHUNK_SIZE+1);
}
fclose( file );
}
/*
Ausgabe von Fehlermeldungen
*/
void err_abort(char *str){
fprintf(stderr," TCP Echo-Server: %s\n",str);
fflush(stdout);
fflush(stderr);
exit(1);
}
|
the_stack_data/248580659.c | /*
*
* A tool to extract the vDSO shared object from the current process (this executable).
* Author: Levente Kurusa <[email protected]>
* License: MIT License
*
* Compile:
* $ gcc extract-vdso.c -o extract-vdsoA
*
* Usage:
* $ ./extract-vdso > vdso-sample.so
*
* Read the symbols:
* $ readelf -s vdso-sample.so
*/
#include <sys/auxv.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <string.h>
int
main(int argc, char **argvp)
{
void *vdso, *ptr;
int rc, page_size;
vdso = (void *) getauxval(AT_SYSINFO_EHDR);
if (!vdso) {
fprintf(stderr, "[ ERROR ] vDSO region not found\n");
return 1;
}
page_size = getauxval(AT_PAGESZ);
if (!page_size) {
page_size = 0x1000;
fprintf(stderr, "[ WARN ] AT_PAGESZ was not passed, assuming page size of 4K\n");
}
fprintf(stderr, "[ INFO ] vDSO region at %p\n", vdso);
for (ptr = vdso;; ptr += page_size) {
rc = write(1, ptr, page_size);
if (rc == page_size)
continue;
else if (errno == EFAULT) {
fprintf(stderr, "[ INFO ] Done, good-bye\n");
return 0;
} else {
fprintf(stderr, "[ ERROR ] Unexpected error: %s\n", strerror(errno));
return errno;
}
}
fprintf(stderr, "[ WARN ] Wrote the entire contents of the RAM to memory\n");
return 2;
}
|
the_stack_data/178266303.c | /* Copyright 2012-2020 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stdio.h>
int
bar (int n)
{
printf ("bar %d\n", n);
return 0;
}
|
the_stack_data/31387054.c | struct S
{
int i;
int j; // extra member
} some_var;
struct S *function()
{
return &some_var;
}
|
the_stack_data/606752.c | #define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAXLINE 100
void filecopy(FILE *ifp, FILE *ofp);
char *u_fgets(char *s, int n, FILE *iop);
int u_fputs(char *s, FILE *iop);
int u_getline(char *line, int max);
int main(int argc, char *argv[])
{
FILE *fp;
char *prog = argv[0];
if (argc == 1) {
filecopy(stdin, stdout);
}
else {
while (--argc > 0) {
if ((fp = fopen(*++argv, "r")) == NULL) {
fprintf(stderr, "%s: can't open %s\n", prog, *argv);
exit(1);
}
else {
filecopy(fp, stdout);
fclose(fp);
}
}
}
if (ferror(stdout)) {
fprintf(stderr, "%s: error writing stdout\n", prog);
}
getchar();
exit(0);
}
void filecopy(FILE *ifp, FILE *ofp)
{
char *p;
char buf[MAXLINE];
while ((p = u_fgets(buf, MAXLINE, ifp)) != NULL) {
u_fputs(buf, stdout);
}
}
char *u_fgets(char *s, int n, FILE *iop)
{
register int c;
register char *cs;
cs = s;
while (--n > 0 && (c = getc(iop)) != EOF) {
if ((*cs++ = c) == '\n') {
break;
}
}
*cs = '\0';
return (c == EOF && cs == s) ? NULL : s;
}
int u_fputs(char *s, FILE *iop)
{
int c;
while (c = *s++) {
putc(c, iop);
}
return ferror(iop) ? EOF : 1;
}
int u_getline(char *line, int max)
{
if (u_fgets(line, max, stdin) == NULL) {
return 0;
}
else {
return strlen(line);
}
} |
the_stack_data/109059.c | // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck %s
struct Bar {
float f1;
float f2;
unsigned u;
};
struct Bar foo(__builtin_va_list ap) {
return __builtin_va_arg(ap, struct Bar);
// CHECK: [[FPOP:%.*]] = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* {{.*}}, i32 0, i32 1
// CHECK: [[FPO:%.*]] = load i32, i32* [[FPOP]]
// CHECK: [[FPVEC:%.*]] = getelementptr i8, i8* {{.*}}, i32 [[FPO]]
// CHECK: bitcast i8* [[FPVEC]] to <2 x float>*
}
|
the_stack_data/184517323.c | #include<stdio.h>
int main()
{
int number;
printf("Enter number:");
scanf("%d",&number);
int i,rem,sum=0;
for(i=1;i<=number/2;i++)
{
rem=number%i;
if(rem==0)
{
sum=sum+i;
}
}
if(sum==number)
{
printf("%d is a perfect number",number);
}
else
{
printf("%d is not a perfect number",number);
}
return 0;
}
|
the_stack_data/742770.c |
#include <stdio.h>
void scilab_rt_plot3d_d2d2i2i0d0s0d2i2_(int in00, int in01, double matrixin0[in00][in01],
int in10, int in11, double matrixin1[in10][in11],
int in20, int in21, int matrixin2[in20][in21],
int scalarin0,
double scalarin1,
char* scalarin2,
int in30, int in31, double matrixin3[in30][in31],
int in40, int in41, int matrixin4[in40][in41])
{
int i;
int j;
double val0 = 0;
double val1 = 0;
int val2 = 0;
double val3 = 0;
int val4 = 0;
for (i = 0; i < in00; ++i) {
for (j = 0; j < in01; ++j) {
val0 += matrixin0[i][j];
}
}
printf("%f", val0);
for (i = 0; i < in10; ++i) {
for (j = 0; j < in11; ++j) {
val1 += matrixin1[i][j];
}
}
printf("%f", val1);
for (i = 0; i < in20; ++i) {
for (j = 0; j < in21; ++j) {
val2 += matrixin2[i][j];
}
}
printf("%d", val2);
printf("%d", scalarin0);
printf("%f", scalarin1);
printf("%s", scalarin2);
for (i = 0; i < in30; ++i) {
for (j = 0; j < in31; ++j) {
val3 += matrixin3[i][j];
}
}
printf("%f", val3);
for (i = 0; i < in40; ++i) {
for (j = 0; j < in41; ++j) {
val4 += matrixin4[i][j];
}
}
printf("%d", val4);
}
|
the_stack_data/876794.c | // RUN: %clang_cc1 -stack-protector 2 -Rpass-missed=inline -O2 -verify %s -emit-llvm-only
void side_effect(void);
void foo(void) {
side_effect();
}
// expected-remark@+3 {{foo will not be inlined into bar: stack protected callee but caller requested no stack protector}}
__attribute__((no_stack_protector))
void bar(void) {
foo();
}
// expected-remark@+2 {{bar will not be inlined into baz: stack protected caller but callee requested no stack protector}}
void baz(void) {
bar();
}
void ssp_callee(void);
// No issue; matching stack protections.
void ssp_caller(void) {
ssp_callee();
}
__attribute__((no_stack_protector))
void nossp_callee(void);
// No issue; matching stack protections.
__attribute__((no_stack_protector))
void nossp_caller(void) {
nossp_callee();
}
|
the_stack_data/26700390.c | #include <stdio.h>
#include <time.h>
#include <stdlib.h>
int main_array(void) {
srand(time(NULL));
printf("\n\n === 아빠는 대머리 게임 === \n\n");
int answer; // 사용자 입력값
int treatment = rand() % 4; // 발모제 선택 (0-3)
int cntShowBottle = 0; // 이번 게임에 보여줄 병 갯수
int prevCntShowBottle = 0; // 앞 게임에 보여준 병 갯수
// 서로 보여주는 병 갯수를 다르게 하여 정답률 향상 (처음에 2개 -> 다음엔 3개..)
// 3번의 기회 (3번의 발모제 투여 시도)
for (int i = 1; i <= 3; i++) {
int bottle[4] = {0, 0, 0, 0}; // 4개의 병
do {
cntShowBottle = rand() % 2 + 2; // 보여줄 병 갯수 (0-1, +2 -> 2, 3)
} while(cntShowBottle == prevCntShowBottle);
prevCntShowBottle = cntShowBottle;
int isincluded = 0; // 보여줄 병 중에 발모제가 포함되어있는지 여부
printf(" > %d 번째 시도 : ", i);
// 보여줄 병 종류를 선택
for (int j = 0; j < cntShowBottle; j++) {
int randBottle = rand() % 4; // 0-3
// 아직 선택되지 않은 병이면, 선택 처리
if (bottle[randBottle] == 0) {
bottle[randBottle] = 1;
if (randBottle == treatment) {
isincluded = 1;
}
}
// 이미 선택된 병이면, 중복이므로 다시 선택
else {
j--;
}
}
// 사용자에게 문제 표시
for (int k = 0; k < 4; k++) {
if (bottle[k] == 1) {
printf("%d", k + 1);
}
printf("물약을 머리에 바릅니다\n\n");
if (isincluded == 1) {
printf(" >> 성공, 머리가 났어요\n");
} else {
printf(" >> 실패, 머리가 나지 않았어요 \n");
}
printf("\n ... 계속하려면 아무키나 누르세요");
getchar();
}
printf("\n\n발모제는 몇번 일까요?");
scanf("%d", &answer);
if (answer == treatment + 1) {
printf("\n >> 정답입니다\n");
} else {
printf("\n >> 땡 틀렸어요. 정답은 %d 입니다\n", treatment + 1);
}
}
return 0;
} |
the_stack_data/67325462.c | /*
Copyright (c) 2017, Lawrence Livermore National Security, LLC.
Produced at the Lawrence Livermore National Laboratory
Written by Chunhua Liao, Pei-Hung Lin, Joshua Asplund,
Markus Schordan, and Ian Karlin
(email: [email protected], [email protected], [email protected],
[email protected], [email protected])
LLNL-CODE-732144
All rights reserved.
This file is part of DataRaceBench. For details, see
https://github.com/LLNL/dataracebench. Please also see the LICENSE file
for our additional BSD notice.
Redistribution and use in source and binary forms, with
or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the disclaimer below.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the disclaimer (as noted below)
in the documentation and/or other materials provided with the
distribution.
* Neither the name of the LLNS/LLNL nor the names of its contributors
may be used to endorse or promote products derived from this
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL
SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
Example use of fprintf
*/
#include <stdio.h>
int main(int argc, char* argv[])
{
int i;
int ret;
FILE* pfile;
int len=1000;
int A[1000];
for (i=0; i<len; i++)
A[i]=i;
pfile = fopen("mytempfile.txt","a+");
if (pfile ==NULL)
{
fprintf(stderr,"Error in fopen()\n");
}
#pragma omp parallel for
for (i=0; i<len; ++i)
{
fprintf(pfile, "%d\n", A[i] );
}
fclose(pfile);
ret = remove("mytempfile.txt");
if (ret != 0)
{
fprintf(stderr, "Error: unable to delete mytempfile.txt\n");
}
return 0;
}
|
the_stack_data/444853.c | #include <stdio.h>
#include <unistd.h>
//gcc -fno-pie -no-pie -Wno-implicit-function-declaration -fno-stack-protector -m32 babybufov.c -o babybufov
void target(){
char* executable="/bin/bash";
char* argv[]={executable,NULL};
puts("Jackpot!");
execve(executable,argv,NULL);
}
int vuln(){
char buf[16];
gets(buf);
return 0;
}
int main(){
setbuf(stdin,NULL);
setbuf(stdout,NULL);
puts("Gimme some data!");
fflush(stdout);
vuln();
puts("Failed... :(");
}
|
the_stack_data/26701018.c | #include<stdlib.h>
#include<math.h>
#include<stdio.h>
typedef struct
{
int hour, minute, second;
} digitime;
double
timeToDegrees (digitime time)
{
return (360 * time.hour / 24.0 + 360 * time.minute / (24 * 60.0) +
360 * time.second / (24 * 3600.0));
}
digitime
timeFromDegrees (double angle)
{
digitime d;
double totalSeconds = 24 * 60 * 60 * angle / 360;
d.second = (int) totalSeconds % 60;
d.minute = ((int) totalSeconds % 3600 - d.second) / 60;
d.hour = (int) totalSeconds / 3600;
return d;
}
double
meanAngle (double *angles, int size)
{
double y_part = 0, x_part = 0;
int i;
for (i = 0; i < size; i++)
{
x_part += cos (angles[i] * M_PI / 180);
y_part += sin (angles[i] * M_PI / 180);
}
return atan2 (y_part / size, x_part / size) * 180 / M_PI;
}
int
main ()
{
digitime *set, meanTime;
int inputs, i;
double *angleSet, angleMean;
printf ("Enter number of inputs : ");
scanf ("%d", &inputs);
set = malloc (inputs * sizeof (digitime));
angleSet = malloc (inputs * sizeof (double));
printf ("\n\nEnter the data separated by a space between each unit : ");
for (i = 0; i < inputs; i++)
{
scanf ("%d:%d:%d", &set[i].hour, &set[i].minute, &set[i].second);
angleSet[i] = timeToDegrees (set[i]);
}
meanTime = timeFromDegrees (360 + meanAngle (angleSet, inputs));
printf ("\n\nThe mean time is : %d:%d:%d", meanTime.hour, meanTime.minute,
meanTime.second);
return 0;
}
|
the_stack_data/145386.c | #include<stdio.h>
int f(int x){
int i;
for(i=2;i<=x-1;i++)
{
if(x%i==0){break;}
}
if(i==x)
return x;
else
return 0;
}
int main()
{
int a;
scanf("%d",&a);
int b;
for(b=1;f(a+b)!=a+b;b++){}
printf("%d",a+b);
} |
the_stack_data/156392771.c | // RUN: %clang_cc1 -emit-llvm %s -o /dev/null
/* Testcase for a problem where GCC allocated xqic to a register,
* and did not have a VAR_DECL that explained the stack slot to LLVM.
* Now the LLVM code synthesizes a stack slot if one is presented that
* has not been previously recognized. This is where alloca's named
* 'local' come from now.
*/
typedef struct {
short x;
} foostruct;
int foo(foostruct ic);
void test() {
foostruct xqic;
foo(xqic);
}
|
the_stack_data/161080139.c | #include <stdio.h>
#include <time.h>
#include <stdlib.h>
#define AJUSTE(a) ( ((a) * 3) - 3 )
#define ALUNOS 60
void preencheArray(int referencia, int array[]);
int main(void){
int cor;
int palheta[24] = {-1};
int matricula = 1;
srand(time(NULL));
while(matricula <= ALUNOS){
cor = (rand() % 8) + 1;
preencheArray(cor, palheta);
printf("MATRÍCULA %i\n", matricula);
printf("cor %i ... R = %i / G = %i / B = %i \n\n", cor, palheta[AJUSTE(cor)], palheta[AJUSTE(cor)+1], palheta[AJUSTE(cor)+2]);
matricula++;
}
return 0;
}
void preencheArray(int referencia, int array[]){
int valor[24] = {255,255,255, 0,0,255, 255,0,0, 0,255,0, 255,255,0, 255,0,255, 0,255,255, 0,0,0};
int min = AJUSTE(referencia);
for(int i = min; i < (referencia * 3); i++){
array[i] = valor[i];
}
return;
}
|
the_stack_data/132888.c | #include<stdio.h>
int power(int,int);
int main()
{
int x, n;
scanf("%d %d",&x,&n);
printf("%d",power(x,n));
return 0;
}
int power(int x, int n)
{
int result;
if(n==0)
return 1;
if(n%2==0)
{
//result=power(x,n/2)*power(x,n/2);
result=power(power(x,n/2),2);
}
else
{
result=x*power(x,n-1);
}
return result;
}
|
the_stack_data/150141813.c |
#include <stdio.h>
void scilab_rt_clf_i0_(int scalarin0)
{
printf("%d", scalarin0);
}
|
the_stack_data/43887052.c | // Prints a countdown
#include <stdio.h>
void print_count(int n)
{
printf("T minus %d and counting\n", n);
}
main()
{
for (int i = 10; i > 0 ; --i)
{
print_count(i);
}
} |
the_stack_data/218894229.c | /** msg.c */
/**
* 消息队列就是一些消息的列表。用户可以从消息队列中添加消息和读取消息等。
* 消息队列的实现包括创建或打开消息队列、添加消息、读取消息和控制消息队列这 4 种操作:
* 其中创建或打开消息队列使用的函数是 msgget(),这里创建的消息队列的数量会受到系统消息队列数量的限制;
* 添加消息使用的函数是 msgsnd()函数,它把消息添加到已打开的消息队列末尾;
* 读取消息使用的函数是msgrcv(),它把消息从消息队列中取走,与 FIFO 不同的是,这里可以指定取走某一条消息;
* 最后控制消息队列使用的函数是 msgctl(),它可以完成多项功能。
*
* 函数原型 int msgget(key_t key, int msgflg)
* 函数传入值
* key:消息队列的键值,多个进程可以通过它访问同一个消息队列,其中有个特殊值 IPC_PRIVATE。它用于创建当前进程的私有消息队列
* msgflg:权限标志位
* 函数返回值
* 成功:消息队列 ID
* 出错: - 1
*
* 函数原型 int msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg)
* 函数传入值
* msqid:消息队列的队列 ID
* msgp:指向消息结构的指针。该消息结构 msgbuf 通常为:
* struct msgbuf
* {
* long mtype; 消息类型,该结构必须从这个域开始
* char mtext[1]; 消息正文
* }
* msgsz:消息正文的字节数(不包括消息类型指针变量)
* msgflg
* IPC_NOWAIT 若消息无法立即发送(比如:当前消息队列已满),函数会立即返回
* 0: msgsnd 调阻塞直到发送成功为止
* 函数返回值
* 成功: 0
* 出错: -1
*
* 函数原型 int msgrcv(int msgid, void *msgp, size_t msgsz, long int msgtyp, int msgflg)
* 函数传入值
* msgid:消息队列的队列 ID
* msgp:消息缓冲区, 同于 msgsnd()函数的 msgp
* msgsz:消息正文的字节数(不包括消息类型指针变量)
* msgtyp:
* 0:接收消息队列中第一个消息
* 大于 0:接收消息队列中第一个类型为 msgtyp 的消息
* 小于 0:接收消息队列中第一个类型值不小于 msgtyp 绝对值且类型值又最小的消息
* msgflg:
* MSG_NOERROR:若返回的消息比 msgsz 字节多,则消息就会截短到 msgsz 字节,且不通知消息发送进程
* IPC_NOWAIT 若在消息队列中并没有相应类型的消息可以接收,则函数立即返回
* 0: msgsnd()调用阻塞直到接收一条相应类型的消息为止
* 函数返回值
* 成功: 0
* 出错: -1
*
* 函数原型 int msgctl (int msgqid, int cmd, struct msqid_ds *buf )
* 函数传入值
* msqid:消息队列的队列 ID
* cmd:
* IPC_STAT:读取消息队列的数据结构 msqid_ds,并将其存储在buf 指定的地址中
* IPC_SET:设置消息队列的数据结构 msqid_ds 中的 ipc_perm 域(IPC 操作权限描述结构)值。这个值取自 buf 参数
* IPC_RMID:从系统内核中删除消息队列
* buf:描述消息队列的 msgqid_ds 结构类型变量
* 函数返回值
* 成功: 0
* 出错: -1
*
*/
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#define BUFFER_SIZE 512
struct message
{
long msg_type;
char msg_text[BUFFER_SIZE];
};
int main()
{
int qid;
struct message msg;
/*创建消息队列*/
if ((qid = msgget((key_t)1234, IPC_CREAT|0666)) == -1)
{
perror("msgget");
exit(1);
}
printf("Open queue %d\n",qid);
while(1)
{
printf("Enter some message to the queue:");
if ((fgets(msg.msg_text, BUFFER_SIZE, stdin)) == NULL)
{
puts("no message");
exit(1);
}
msg.msg_type = getpid();
/*添加消息到消息队列*/
if ((msgsnd(qid, &msg, strlen(msg.msg_text), 0)) < 0)
{
perror("message posted");
exit(1);
}
if (strncmp(msg.msg_text, "quit", 4) == 0)
{
break;
}
}
exit(0);
}
|
the_stack_data/179831178.c | #include <stdio.h>
#include <math.h>
#include <float.h>
/* Write out a header file containing some precomputed machine-specific
constants used by the routines to save on runtime computation. */
int main (int argc, char *argv[]) {
printf("#ifndef MACHCONST_H\n"
"#define MACHCONST_H\n"
"\n"
"#define SQRT_FLT_MIN %.*e\n"
"#define SQRT_DBL_MIN %.*le\n"
"\n"
"#define SQRT_FLT_EPSILON %.*e\n"
"#define SQRT_DBL_EPSILON %.*le\n"
"\n"
"#endif /* MACHCONST_H */\n",
FLT_DIG+4, /* on the safe side! */
sqrtf(FLT_MIN),
DBL_DIG+4,
sqrt(DBL_MIN),
FLT_DIG+4,
sqrtf(FLT_EPSILON),
DBL_DIG+4,
sqrt(DBL_EPSILON));
return(0);
}
|
the_stack_data/275931.c | #include <stdio.h>
#include <stdlib.h>
/*Displays the array, passed to this method*/
void display(int arr[], int n)
{
int i;
for (i = 0; i < n; i++)
{
printf("%d ", arr[i]);
}
printf("\n");
}
/*Swap function to swap two values*/
void swap(int *first, int *second)
{
int temp = *first;
*first = *second;
*second = temp;
}
/*Partition method which selects a pivot
and places each element which is less than the pivot value to its left
and the elements greater than the pivot value to its right
arr[] --- array to be partitioned
lower --- lower index
upper --- upper index
*/
int partition(int arr[], int lower, int upper)
{
int i = (lower - 1);
int pivot = arr[upper]; // Selects last element as the pivot value
int j;
for (j = lower; j < upper; j++)
{
if (arr[j] <= pivot)
{ // if current element is smaller than the pivot
i++; // increment the index of smaller element
swap(&arr[i], &arr[j]);
}
}
swap(&arr[i + 1], &arr[upper]); // places the last element i.e, the pivot to its correct position
return (i + 1);
}
/*This is where the sorting of the array takes place
arr[] --- Array to be sorted
lower --- Starting index
upper --- Ending index
*/
void quickSort(int arr[], int lower, int upper)
{
if (upper > lower)
{
// partitioning index is returned by the partition method , partition element is at its correct poition
int partitionIndex = partition(arr, lower, upper);
// Sorting elements before and after the partition index
quickSort(arr, lower, partitionIndex - 1);
quickSort(arr, partitionIndex + 1, upper);
}
}
int main()
{
int n;
printf("Enter size of array:\n");
scanf("%d", &n); // E.g. 8
printf("Enter the elements of the array\n");
int i;
int *arr = (int *)malloc(sizeof(int) * n);
for (i = 0; i < n; i++)
{
scanf("%d", &arr[i]);
}
printf("Original array: ");
display(arr, n); // Original array : 10 11 9 8 4 7 3 8
quickSort(arr, 0, n - 1);
printf("Sorted array: ");
display(arr, n); // Sorted array : 3 4 7 8 8 9 10 11
getchar();
return 0;
}
|
the_stack_data/43888044.c | #include <stddef.h>
char *strsep(char **stringp, const char *delim)
{
char *s;
const char *spanp;
int c, sc;
char *tok;
if ((s = *stringp) == NULL)
return (NULL);
for (tok = s;;) {
c = *s++;
spanp = delim;
do {
if ((sc = *spanp++) == c) {
if (c == 0)
s = NULL;
else
s[-1] = 0;
*stringp = s;
return (tok);
}
} while (sc != 0);
}
} |
the_stack_data/68887069.c | // RUN: %clang_cc1 -triple x86_64-apple-darwin -verify -fsyntax-only %s -Wdouble-promotion
float ReturnFloatFromDouble(double d) {
return d;
}
float ReturnFloatFromLongDouble(long double ld) {
return ld;
}
double ReturnDoubleFromLongDouble(long double ld) {
return ld;
}
double ReturnDoubleFromFloat(float f) {
return f; //expected-warning{{implicit conversion increases floating-point precision: 'float' to 'double'}}
}
long double ReturnLongDoubleFromFloat(float f) {
return f; //expected-warning{{implicit conversion increases floating-point precision: 'float' to 'long double'}}
}
long double ReturnLongDoubleFromDouble(double d) {
return d; //expected-warning{{implicit conversion increases floating-point precision: 'double' to 'long double'}}
}
void Assignment(float f, double d, long double ld) {
d = f; //expected-warning{{implicit conversion increases floating-point precision: 'float' to 'double'}}
ld = f; //expected-warning{{implicit conversion increases floating-point precision: 'float' to 'long double'}}
ld = d; //expected-warning{{implicit conversion increases floating-point precision: 'double' to 'long double'}}
f = d;
f = ld;
d = ld;
}
extern void DoubleParameter(double);
extern void LongDoubleParameter(long double);
void ArgumentPassing(float f, double d) {
DoubleParameter(f); // expected-warning{{implicit conversion increases floating-point precision: 'float' to 'double'}}
LongDoubleParameter(f); // expected-warning{{implicit conversion increases floating-point precision: 'float' to 'long double'}}
LongDoubleParameter(d); // expected-warning{{implicit conversion increases floating-point precision: 'double' to 'long double'}}
}
void BinaryOperator(float f, double d, long double ld) {
f = f * d; // expected-warning{{implicit conversion increases floating-point precision: 'float' to 'double'}}
f = d * f; // expected-warning{{implicit conversion increases floating-point precision: 'float' to 'double'}}
f = f * ld; // expected-warning{{implicit conversion increases floating-point precision: 'float' to 'long double'}}
f = ld * f; // expected-warning{{implicit conversion increases floating-point precision: 'float' to 'long double'}}
d = d * ld; // expected-warning{{implicit conversion increases floating-point precision: 'double' to 'long double'}}
d = ld * d; // expected-warning{{implicit conversion increases floating-point precision: 'double' to 'long double'}}
}
void MultiplicationAssignment(float f, double d, long double ld) {
d *= f; // expected-warning{{implicit conversion increases floating-point precision: 'float' to 'double'}}
ld *= f; // expected-warning{{implicit conversion increases floating-point precision: 'float' to 'long double'}}
ld *= d; // expected-warning{{implicit conversion increases floating-point precision: 'double' to 'long double'}}
// FIXME: These cases should produce warnings as above.
f *= d;
f *= ld;
d *= ld;
}
// FIXME: As with a binary operator, the operands to the conditional operator are
// converted to a common type and should produce a warning.
void ConditionalOperator(float f, double d, long double ld, int i) {
f = i ? f : d;
f = i ? d : f;
f = i ? f : ld;
f = i ? ld : f;
d = i ? d : ld;
d = i ? ld : d;
}
|
the_stack_data/154154.c | #include <stdio.h>
int main() {
int a[5];
int i;
for (i = 0; i < 5; i++) {
printf("a[%d] = ", i);
scanf("%d", &a[i]);
}
printf("\nPrint array a[n]\n\n");
for (i = 4; i >= 0; --i) {
printf("a[%d] = %d\n", i, a[i]);
}
printf("\n");
getch();
} |
the_stack_data/65167.c | /* -*- mode: C; c-basic-offset: 3; -*- */
/*--------------------------------------------------------------------*/
/*--- Wrappers for generic Unix system calls ---*/
/*--- syswrap-generic.c ---*/
/*--------------------------------------------------------------------*/
/*
This file is part of Valgrind, a dynamic binary instrumentation
framework.
Copyright (C) 2000-2015 Julian Seward
[email protected]
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307, USA.
The GNU General Public License is contained in the file COPYING.
*/
#if defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_solaris)
#include "pub_core_basics.h"
#include "pub_core_vki.h"
#include "pub_core_vkiscnums.h"
#include "pub_core_threadstate.h"
#include "pub_core_debuginfo.h" // VG_(di_notify_*)
#include "pub_core_aspacemgr.h"
#include "pub_core_transtab.h" // VG_(discard_translations)
#include "pub_core_xarray.h"
#include "pub_core_clientstate.h" // VG_(brk_base), VG_(brk_limit)
#include "pub_core_debuglog.h"
#include "pub_core_errormgr.h"
#include "pub_core_gdbserver.h" // VG_(gdbserver)
#include "pub_core_libcbase.h"
#include "pub_core_libcassert.h"
#include "pub_core_libcfile.h"
#include "pub_core_libcprint.h"
#include "pub_core_libcproc.h"
#include "pub_core_libcsignal.h"
#include "pub_core_machine.h" // VG_(get_SP)
#include "pub_core_mallocfree.h"
#include "pub_core_options.h"
#include "pub_core_scheduler.h"
#include "pub_core_signals.h"
#include "pub_core_stacktrace.h" // For VG_(get_and_pp_StackTrace)()
#include "pub_core_syscall.h"
#include "pub_core_syswrap.h"
#include "pub_core_tooliface.h"
#include "pub_core_ume.h"
#include "pub_core_stacks.h"
#include "priv_types_n_macros.h"
#include "priv_syswrap-generic.h"
#include "config.h"
void ML_(guess_and_register_stack) (Addr sp, ThreadState* tst)
{
Bool debug = False;
NSegment const* seg;
/* We don't really know where the client stack is, because its
allocated by the client. The best we can do is look at the
memory mappings and try to derive some useful information. We
assume that sp starts near its highest possible value, and can
only go down to the start of the mmaped segment. */
seg = VG_(am_find_nsegment)(sp);
if (seg &&
VG_(am_is_valid_for_client)(sp, 1, VKI_PROT_READ | VKI_PROT_WRITE)) {
tst->client_stack_highest_byte = (Addr)VG_PGROUNDUP(sp)-1;
tst->client_stack_szB = tst->client_stack_highest_byte - seg->start + 1;
VG_(register_stack)(seg->start, tst->client_stack_highest_byte);
if (debug)
VG_(printf)("tid %u: guessed client stack range [%#lx-%#lx]\n",
tst->tid, seg->start, tst->client_stack_highest_byte);
} else {
VG_(message)(Vg_UserMsg,
"!? New thread %u starts with SP(%#lx) unmapped\n",
tst->tid, sp);
tst->client_stack_highest_byte = 0;
tst->client_stack_szB = 0;
}
}
/* Returns True iff address range is something the client can
plausibly mess with: all of it is either already belongs to the
client or is free or a reservation. */
Bool ML_(valid_client_addr)(Addr start, SizeT size, ThreadId tid,
const HChar *syscallname)
{
Bool ret;
if (size == 0)
return True;
ret = VG_(am_is_valid_for_client_or_free_or_resvn)
(start,size,VKI_PROT_NONE);
if (0)
VG_(printf)("%s: test=%#lx-%#lx ret=%d\n",
syscallname, start, start+size-1, (Int)ret);
if (!ret && syscallname != NULL) {
VG_(message)(Vg_UserMsg, "Warning: client syscall %s tried "
"to modify addresses %#lx-%#lx\n",
syscallname, start, start+size-1);
if (VG_(clo_verbosity) > 1) {
VG_(get_and_pp_StackTrace)(tid, VG_(clo_backtrace_size));
}
}
return ret;
}
Bool ML_(client_signal_OK)(Int sigNo)
{
/* signal 0 is OK for kill */
Bool ret = sigNo >= 0 && sigNo <= VG_SIGVGRTUSERMAX;
//VG_(printf)("client_signal_OK(%d) -> %d\n", sigNo, ret);
return ret;
}
/* Handy small function to help stop wrappers from segfaulting when
presented with bogus client addresses. Is not used for generating
user-visible errors. */
Bool ML_(safe_to_deref) ( const void *start, SizeT size )
{
return VG_(am_is_valid_for_client)( (Addr)start, size, VKI_PROT_READ );
}
/* ---------------------------------------------------------------------
Doing mmap, mremap
------------------------------------------------------------------ */
/* AFAICT from kernel sources (mm/mprotect.c) and general experimentation,
munmap, mprotect (and mremap??) work at the page level. So addresses
and lengths must be adjusted for this. */
/* Mash around start and length so that the area exactly covers
an integral number of pages. If we don't do that, memcheck's
idea of addressible memory diverges from that of the
kernel's, which causes the leak detector to crash. */
static
void page_align_addr_and_len( Addr* a, SizeT* len)
{
Addr ra;
ra = VG_PGROUNDDN(*a);
*len = VG_PGROUNDUP(*a + *len) - ra;
*a = ra;
}
static void notify_core_of_mmap(Addr a, SizeT len, UInt prot,
UInt flags, Int fd, Off64T offset)
{
Bool d;
/* 'a' is the return value from a real kernel mmap, hence: */
vg_assert(VG_IS_PAGE_ALIGNED(a));
/* whereas len is whatever the syscall supplied. So: */
len = VG_PGROUNDUP(len);
d = VG_(am_notify_client_mmap)( a, len, prot, flags, fd, offset );
if (d)
VG_(discard_translations)( a, (ULong)len,
"notify_core_of_mmap" );
}
static void notify_tool_of_mmap(Addr a, SizeT len, UInt prot, ULong di_handle)
{
Bool rr, ww, xx;
/* 'a' is the return value from a real kernel mmap, hence: */
vg_assert(VG_IS_PAGE_ALIGNED(a));
/* whereas len is whatever the syscall supplied. So: */
len = VG_PGROUNDUP(len);
rr = toBool(prot & VKI_PROT_READ);
ww = toBool(prot & VKI_PROT_WRITE);
xx = toBool(prot & VKI_PROT_EXEC);
VG_TRACK( new_mem_mmap, a, len, rr, ww, xx, di_handle );
}
/* When a client mmap has been successfully done, this function must
be called. It notifies both aspacem and the tool of the new
mapping.
JRS 2008-Aug-14: But notice this is *very* obscure. The only place
it is called from is POST(sys_io_setup). In particular,
ML_(generic_PRE_sys_mmap), in m_syswrap, is the "normal case" handler for
client mmap. But it doesn't call this function; instead it does the
relevant notifications itself. Here, we just pass di_handle=0 to
notify_tool_of_mmap as we have no better information. But really this
function should be done away with; problem is I don't understand what
POST(sys_io_setup) does or how it works.
[However, this function is used lots for Darwin, because
ML_(generic_PRE_sys_mmap) cannot be used for Darwin.]
*/
void
ML_(notify_core_and_tool_of_mmap) ( Addr a, SizeT len, UInt prot,
UInt flags, Int fd, Off64T offset )
{
// XXX: unlike the other notify_core_and_tool* functions, this one doesn't
// do anything with debug info (ie. it doesn't call VG_(di_notify_mmap)).
// Should it? --njn
notify_core_of_mmap(a, len, prot, flags, fd, offset);
notify_tool_of_mmap(a, len, prot, 0/*di_handle*/);
}
void
ML_(notify_core_and_tool_of_munmap) ( Addr a, SizeT len )
{
Bool d;
page_align_addr_and_len(&a, &len);
d = VG_(am_notify_munmap)(a, len);
VG_TRACK( die_mem_munmap, a, len );
VG_(di_notify_munmap)( a, len );
if (d)
VG_(discard_translations)( a, (ULong)len,
"ML_(notify_core_and_tool_of_munmap)" );
}
void
ML_(notify_core_and_tool_of_mprotect) ( Addr a, SizeT len, Int prot )
{
Bool rr = toBool(prot & VKI_PROT_READ);
Bool ww = toBool(prot & VKI_PROT_WRITE);
Bool xx = toBool(prot & VKI_PROT_EXEC);
Bool d;
page_align_addr_and_len(&a, &len);
d = VG_(am_notify_mprotect)(a, len, prot);
VG_TRACK( change_mem_mprotect, a, len, rr, ww, xx );
VG_(di_notify_mprotect)( a, len, prot );
if (d)
VG_(discard_translations)( a, (ULong)len,
"ML_(notify_core_and_tool_of_mprotect)" );
}
#if HAVE_MREMAP
/* Expand (or shrink) an existing mapping, potentially moving it at
the same time (controlled by the MREMAP_MAYMOVE flag). Nightmare.
*/
static
SysRes do_mremap( Addr old_addr, SizeT old_len,
Addr new_addr, SizeT new_len,
UWord flags, ThreadId tid )
{
# define MIN_SIZET(_aa,_bb) (_aa) < (_bb) ? (_aa) : (_bb)
Bool ok, d;
NSegment const* old_seg;
Addr advised;
Bool f_fixed = toBool(flags & VKI_MREMAP_FIXED);
Bool f_maymove = toBool(flags & VKI_MREMAP_MAYMOVE);
if (0)
VG_(printf)("do_remap (old %#lx %lu) (new %#lx %lu) %s %s\n",
old_addr,old_len,new_addr,new_len,
flags & VKI_MREMAP_MAYMOVE ? "MAYMOVE" : "",
flags & VKI_MREMAP_FIXED ? "FIXED" : "");
if (0)
VG_(am_show_nsegments)(0, "do_remap: before");
if (flags & ~(VKI_MREMAP_FIXED | VKI_MREMAP_MAYMOVE))
goto eINVAL;
if (!VG_IS_PAGE_ALIGNED(old_addr))
goto eINVAL;
old_len = VG_PGROUNDUP(old_len);
new_len = VG_PGROUNDUP(new_len);
if (new_len == 0)
goto eINVAL;
/* kernel doesn't reject this, but we do. */
if (old_len == 0)
goto eINVAL;
/* reject wraparounds */
if (old_addr + old_len < old_addr)
goto eINVAL;
if (f_fixed == True && new_addr + new_len < new_len)
goto eINVAL;
/* kernel rejects all fixed, no-move requests (which are
meaningless). */
if (f_fixed == True && f_maymove == False)
goto eINVAL;
/* Stay away from non-client areas. */
if (!ML_(valid_client_addr)(old_addr, old_len, tid, "mremap(old_addr)"))
goto eINVAL;
/* In all remaining cases, if the old range does not fall within a
single segment, fail. */
old_seg = VG_(am_find_nsegment)( old_addr );
if (old_addr < old_seg->start || old_addr+old_len-1 > old_seg->end)
goto eINVAL;
if (old_seg->kind != SkAnonC && old_seg->kind != SkFileC &&
old_seg->kind != SkShmC)
goto eINVAL;
vg_assert(old_len > 0);
vg_assert(new_len > 0);
vg_assert(VG_IS_PAGE_ALIGNED(old_len));
vg_assert(VG_IS_PAGE_ALIGNED(new_len));
vg_assert(VG_IS_PAGE_ALIGNED(old_addr));
/* There are 3 remaining cases:
* maymove == False
new space has to be at old address, so:
- shrink -> unmap end
- same size -> do nothing
- grow -> if can grow in-place, do so, else fail
* maymove == True, fixed == False
new space can be anywhere, so:
- shrink -> unmap end
- same size -> do nothing
- grow -> if can grow in-place, do so, else
move to anywhere large enough, else fail
* maymove == True, fixed == True
new space must be at new address, so:
- if new address is not page aligned, fail
- if new address range overlaps old one, fail
- if new address range cannot be allocated, fail
- else move to new address range with new size
- else fail
*/
if (f_maymove == False) {
/* new space has to be at old address */
if (new_len < old_len)
goto shrink_in_place;
if (new_len > old_len)
goto grow_in_place_or_fail;
goto same_in_place;
}
if (f_maymove == True && f_fixed == False) {
/* new space can be anywhere */
if (new_len < old_len)
goto shrink_in_place;
if (new_len > old_len)
goto grow_in_place_or_move_anywhere_or_fail;
goto same_in_place;
}
if (f_maymove == True && f_fixed == True) {
/* new space can only be at the new address */
if (!VG_IS_PAGE_ALIGNED(new_addr))
goto eINVAL;
if (new_addr+new_len-1 < old_addr || new_addr > old_addr+old_len-1) {
/* no overlap */
} else {
goto eINVAL;
}
if (new_addr == 0)
goto eINVAL;
/* VG_(am_get_advisory_client_simple) interprets zero to mean
non-fixed, which is not what we want */
advised = VG_(am_get_advisory_client_simple)(new_addr, new_len, &ok);
if (!ok || advised != new_addr)
goto eNOMEM;
ok = VG_(am_relocate_nooverlap_client)
( &d, old_addr, old_len, new_addr, new_len );
if (ok) {
VG_TRACK( copy_mem_remap, old_addr, new_addr,
MIN_SIZET(old_len,new_len) );
if (new_len > old_len)
VG_TRACK( new_mem_mmap, new_addr+old_len, new_len-old_len,
old_seg->hasR, old_seg->hasW, old_seg->hasX,
0/*di_handle*/ );
VG_TRACK(die_mem_munmap, old_addr, old_len);
if (d) {
VG_(discard_translations)( old_addr, old_len, "do_remap(1)" );
VG_(discard_translations)( new_addr, new_len, "do_remap(2)" );
}
return VG_(mk_SysRes_Success)( new_addr );
}
goto eNOMEM;
}
/* end of the 3 cases */
/*NOTREACHED*/ vg_assert(0);
grow_in_place_or_move_anywhere_or_fail:
{
/* try growing it in-place */
Addr needA = old_addr + old_len;
SSizeT needL = new_len - old_len;
vg_assert(needL > 0);
vg_assert(needA > 0);
advised = VG_(am_get_advisory_client_simple)( needA, needL, &ok );
if (ok) {
/* Fixes bug #129866. */
ok = VG_(am_covered_by_single_free_segment) ( needA, needL );
}
if (ok && advised == needA) {
const NSegment *new_seg = VG_(am_extend_map_client)( old_addr, needL );
if (new_seg) {
VG_TRACK( new_mem_mmap, needA, needL,
new_seg->hasR,
new_seg->hasW, new_seg->hasX,
0/*di_handle*/ );
return VG_(mk_SysRes_Success)( old_addr );
}
}
/* that failed. Look elsewhere. */
advised = VG_(am_get_advisory_client_simple)( 0, new_len, &ok );
if (ok) {
Bool oldR = old_seg->hasR;
Bool oldW = old_seg->hasW;
Bool oldX = old_seg->hasX;
/* assert new area does not overlap old */
vg_assert(advised+new_len-1 < old_addr
|| advised > old_addr+old_len-1);
ok = VG_(am_relocate_nooverlap_client)
( &d, old_addr, old_len, advised, new_len );
if (ok) {
VG_TRACK( copy_mem_remap, old_addr, advised,
MIN_SIZET(old_len,new_len) );
if (new_len > old_len)
VG_TRACK( new_mem_mmap, advised+old_len, new_len-old_len,
oldR, oldW, oldX, 0/*di_handle*/ );
VG_TRACK(die_mem_munmap, old_addr, old_len);
if (d) {
VG_(discard_translations)( old_addr, old_len, "do_remap(4)" );
VG_(discard_translations)( advised, new_len, "do_remap(5)" );
}
return VG_(mk_SysRes_Success)( advised );
}
}
goto eNOMEM;
}
/*NOTREACHED*/ vg_assert(0);
grow_in_place_or_fail:
{
Addr needA = old_addr + old_len;
SizeT needL = new_len - old_len;
vg_assert(needA > 0);
advised = VG_(am_get_advisory_client_simple)( needA, needL, &ok );
if (ok) {
/* Fixes bug #129866. */
ok = VG_(am_covered_by_single_free_segment) ( needA, needL );
}
if (!ok || advised != needA)
goto eNOMEM;
const NSegment *new_seg = VG_(am_extend_map_client)( old_addr, needL );
if (!new_seg)
goto eNOMEM;
VG_TRACK( new_mem_mmap, needA, needL,
new_seg->hasR, new_seg->hasW, new_seg->hasX,
0/*di_handle*/ );
return VG_(mk_SysRes_Success)( old_addr );
}
/*NOTREACHED*/ vg_assert(0);
shrink_in_place:
{
SysRes sres = VG_(am_munmap_client)( &d, old_addr+new_len, old_len-new_len );
if (sr_isError(sres))
return sres;
VG_TRACK( die_mem_munmap, old_addr+new_len, old_len-new_len );
if (d)
VG_(discard_translations)( old_addr+new_len, old_len-new_len,
"do_remap(7)" );
return VG_(mk_SysRes_Success)( old_addr );
}
/*NOTREACHED*/ vg_assert(0);
same_in_place:
return VG_(mk_SysRes_Success)( old_addr );
/*NOTREACHED*/ vg_assert(0);
eINVAL:
return VG_(mk_SysRes_Error)( VKI_EINVAL );
eNOMEM:
return VG_(mk_SysRes_Error)( VKI_ENOMEM );
# undef MIN_SIZET
}
#endif /* HAVE_MREMAP */
/* ---------------------------------------------------------------------
File-descriptor tracking
------------------------------------------------------------------ */
/* One of these is allocated for each open file descriptor. */
typedef struct OpenFd
{
Int fd; /* The file descriptor */
HChar *pathname; /* NULL if not a regular file or unknown */
ExeContext *where; /* NULL if inherited from parent */
struct OpenFd *next, *prev;
} OpenFd;
/* List of allocated file descriptors. */
static OpenFd *allocated_fds = NULL;
/* Count of open file descriptors. */
static Int fd_count = 0;
/* Note the fact that a file descriptor was just closed. */
void ML_(record_fd_close)(Int fd)
{
OpenFd *i = allocated_fds;
if (fd >= VG_(fd_hard_limit))
return; /* Valgrind internal */
while(i) {
if(i->fd == fd) {
if(i->prev)
i->prev->next = i->next;
else
allocated_fds = i->next;
if(i->next)
i->next->prev = i->prev;
if(i->pathname)
VG_(free) (i->pathname);
VG_(free) (i);
fd_count--;
break;
}
i = i->next;
}
}
/* Note the fact that a file descriptor was just opened. If the
tid is -1, this indicates an inherited fd. If the pathname is NULL,
this either indicates a non-standard file (i.e. a pipe or socket or
some such thing) or that we don't know the filename. If the fd is
already open, then we're probably doing a dup2() to an existing fd,
so just overwrite the existing one. */
void ML_(record_fd_open_with_given_name)(ThreadId tid, Int fd,
const HChar *pathname)
{
OpenFd *i;
if (fd >= VG_(fd_hard_limit))
return; /* Valgrind internal */
/* Check to see if this fd is already open. */
i = allocated_fds;
while (i) {
if (i->fd == fd) {
if (i->pathname) VG_(free)(i->pathname);
break;
}
i = i->next;
}
/* Not already one: allocate an OpenFd */
if (i == NULL) {
i = VG_(malloc)("syswrap.rfdowgn.1", sizeof(OpenFd));
i->prev = NULL;
i->next = allocated_fds;
if(allocated_fds) allocated_fds->prev = i;
allocated_fds = i;
fd_count++;
}
i->fd = fd;
i->pathname = VG_(strdup)("syswrap.rfdowgn.2", pathname);
i->where = (tid == -1) ? NULL : VG_(record_ExeContext)(tid, 0/*first_ip_delta*/);
}
// Record opening of an fd, and find its name.
void ML_(record_fd_open_named)(ThreadId tid, Int fd)
{
const HChar* buf;
const HChar* name;
if (VG_(resolve_filename)(fd, &buf))
name = buf;
else
name = NULL;
ML_(record_fd_open_with_given_name)(tid, fd, name);
}
// Record opening of a nameless fd.
void ML_(record_fd_open_nameless)(ThreadId tid, Int fd)
{
ML_(record_fd_open_with_given_name)(tid, fd, NULL);
}
// Return if a given file descriptor is already recorded.
Bool ML_(fd_recorded)(Int fd)
{
OpenFd *i = allocated_fds;
while (i) {
if (i->fd == fd)
return True;
i = i->next;
}
return False;
}
/* Returned string must not be modified nor free'd. */
const HChar *ML_(find_fd_recorded_by_fd)(Int fd)
{
OpenFd *i = allocated_fds;
while (i) {
if (i->fd == fd)
return i->pathname;
i = i->next;
}
return NULL;
}
static
HChar *unix_to_name(struct vki_sockaddr_un *sa, UInt len, HChar *name)
{
if (sa == NULL || len == 0 || sa->sun_path[0] == '\0') {
VG_(sprintf)(name, "<unknown>");
} else {
VG_(sprintf)(name, "%s", sa->sun_path);
}
return name;
}
static
HChar *inet_to_name(struct vki_sockaddr_in *sa, UInt len, HChar *name)
{
if (sa == NULL || len == 0) {
VG_(sprintf)(name, "<unknown>");
} else if (sa->sin_port == 0) {
VG_(sprintf)(name, "<unbound>");
} else {
UInt addr = VG_(ntohl)(sa->sin_addr.s_addr);
VG_(sprintf)(name, "%u.%u.%u.%u:%u",
(addr>>24) & 0xFF, (addr>>16) & 0xFF,
(addr>>8) & 0xFF, addr & 0xFF,
VG_(ntohs)(sa->sin_port));
}
return name;
}
static
void inet6_format(HChar *s, const UChar ip[16])
{
static const unsigned char V4mappedprefix[12] = {0,0,0,0,0,0,0,0,0,0,0xff,0xff};
if (!VG_(memcmp)(ip, V4mappedprefix, 12)) {
const struct vki_in_addr *sin_addr =
(const struct vki_in_addr *)(ip + 12);
UInt addr = VG_(ntohl)(sin_addr->s_addr);
VG_(sprintf)(s, "::ffff:%u.%u.%u.%u",
(addr>>24) & 0xFF, (addr>>16) & 0xFF,
(addr>>8) & 0xFF, addr & 0xFF);
} else {
Bool compressing = False;
Bool compressed = False;
Int len = 0;
Int i;
for (i = 0; i < 16; i += 2) {
UInt word = ((UInt)ip[i] << 8) | (UInt)ip[i+1];
if (word == 0 && !compressed) {
compressing = True;
} else {
if (compressing) {
compressing = False;
compressed = True;
s[len++] = ':';
}
if (i > 0) {
s[len++] = ':';
}
len += VG_(sprintf)(s + len, "%x", word);
}
}
if (compressing) {
s[len++] = ':';
s[len++] = ':';
}
s[len++] = 0;
}
return;
}
static
HChar *inet6_to_name(struct vki_sockaddr_in6 *sa, UInt len, HChar *name)
{
if (sa == NULL || len == 0) {
VG_(sprintf)(name, "<unknown>");
} else if (sa->sin6_port == 0) {
VG_(sprintf)(name, "<unbound>");
} else {
HChar addr[100]; // large enough
inet6_format(addr, (void *)&(sa->sin6_addr));
VG_(sprintf)(name, "[%s]:%u", addr, VG_(ntohs)(sa->sin6_port));
}
return name;
}
/*
* Try get some details about a socket.
*/
static void
getsockdetails(Int fd)
{
union u {
struct vki_sockaddr a;
struct vki_sockaddr_in in;
struct vki_sockaddr_in6 in6;
struct vki_sockaddr_un un;
} laddr;
Int llen;
llen = sizeof(laddr);
VG_(memset)(&laddr, 0, llen);
if(VG_(getsockname)(fd, (struct vki_sockaddr *)&(laddr.a), &llen) != -1) {
switch(laddr.a.sa_family) {
case VKI_AF_INET: {
HChar lname[32]; // large enough
HChar pname[32]; // large enough
struct vki_sockaddr_in paddr;
Int plen = sizeof(struct vki_sockaddr_in);
if (VG_(getpeername)(fd, (struct vki_sockaddr *)&paddr, &plen) != -1) {
VG_(message)(Vg_UserMsg, "Open AF_INET socket %d: %s <-> %s\n", fd,
inet_to_name(&(laddr.in), llen, lname),
inet_to_name(&paddr, plen, pname));
} else {
VG_(message)(Vg_UserMsg, "Open AF_INET socket %d: %s <-> unbound\n",
fd, inet_to_name(&(laddr.in), llen, lname));
}
return;
}
case VKI_AF_INET6: {
HChar lname[128]; // large enough
HChar pname[128]; // large enough
struct vki_sockaddr_in6 paddr;
Int plen = sizeof(struct vki_sockaddr_in6);
if (VG_(getpeername)(fd, (struct vki_sockaddr *)&paddr, &plen) != -1) {
VG_(message)(Vg_UserMsg, "Open AF_INET6 socket %d: %s <-> %s\n", fd,
inet6_to_name(&(laddr.in6), llen, lname),
inet6_to_name(&paddr, plen, pname));
} else {
VG_(message)(Vg_UserMsg, "Open AF_INET6 socket %d: %s <-> unbound\n",
fd, inet6_to_name(&(laddr.in6), llen, lname));
}
return;
}
case VKI_AF_UNIX: {
static char lname[256];
VG_(message)(Vg_UserMsg, "Open AF_UNIX socket %d: %s\n", fd,
unix_to_name(&(laddr.un), llen, lname));
return;
}
default:
VG_(message)(Vg_UserMsg, "Open pf-%d socket %d:\n",
laddr.a.sa_family, fd);
return;
}
}
VG_(message)(Vg_UserMsg, "Open socket %d:\n", fd);
}
/* Dump out a summary, and a more detailed list, of open file descriptors. */
void VG_(show_open_fds) (const HChar* when)
{
OpenFd *i = allocated_fds;
VG_(message)(Vg_UserMsg, "FILE DESCRIPTORS: %d open %s.\n", fd_count, when);
while (i) {
if (i->pathname) {
VG_(message)(Vg_UserMsg, "Open file descriptor %d: %s\n", i->fd,
i->pathname);
} else {
Int val;
Int len = sizeof(val);
if (VG_(getsockopt)(i->fd, VKI_SOL_SOCKET, VKI_SO_TYPE, &val, &len)
== -1) {
VG_(message)(Vg_UserMsg, "Open file descriptor %d:\n", i->fd);
} else {
getsockdetails(i->fd);
}
}
if(i->where) {
VG_(pp_ExeContext)(i->where);
VG_(message)(Vg_UserMsg, "\n");
} else {
VG_(message)(Vg_UserMsg, " <inherited from parent>\n");
VG_(message)(Vg_UserMsg, "\n");
}
i = i->next;
}
VG_(message)(Vg_UserMsg, "\n");
}
/* If /proc/self/fd doesn't exist (e.g. you've got a Linux kernel that doesn't
have /proc support compiled in, or a non-Linux kernel), then we need to
find out what file descriptors we inherited from our parent process the
hard way - by checking each fd in turn. */
static
void init_preopened_fds_without_proc_self_fd(void)
{
struct vki_rlimit lim;
UInt count;
Int i;
if (VG_(getrlimit) (VKI_RLIMIT_NOFILE, &lim) == -1) {
/* Hmm. getrlimit() failed. Now we're screwed, so just choose
an arbitrarily high number. 1024 happens to be the limit in
the 2.4 Linux kernels. */
count = 1024;
} else {
count = lim.rlim_cur;
}
for (i = 0; i < count; i++)
if (VG_(fcntl)(i, VKI_F_GETFL, 0) != -1)
ML_(record_fd_open_named)(-1, i);
}
/* Initialize the list of open file descriptors with the file descriptors
we inherited from out parent process. */
void VG_(init_preopened_fds)(void)
{
// DDD: should probably use HAVE_PROC here or similar, instead.
#if defined(VGO_linux)
Int ret;
struct vki_dirent64 d;
SysRes f;
f = VG_(open)("/proc/self/fd", VKI_O_RDONLY, 0);
if (sr_isError(f)) {
init_preopened_fds_without_proc_self_fd();
return;
}
while ((ret = VG_(getdents64)(sr_Res(f), &d, sizeof(d))) != 0) {
if (ret == -1)
goto out;
if (VG_(strcmp)(d.d_name, ".") && VG_(strcmp)(d.d_name, "..")) {
HChar* s;
Int fno = VG_(strtoll10)(d.d_name, &s);
if (*s == '\0') {
if (fno != sr_Res(f))
if (VG_(clo_track_fds))
ML_(record_fd_open_named)(-1, fno);
} else {
VG_(message)(Vg_DebugMsg,
"Warning: invalid file name in /proc/self/fd: %s\n",
d.d_name);
}
}
VG_(lseek)(sr_Res(f), d.d_off, VKI_SEEK_SET);
}
out:
VG_(close)(sr_Res(f));
#elif defined(VGO_darwin)
init_preopened_fds_without_proc_self_fd();
#elif defined(VGO_solaris)
Int ret;
Char buf[VKI_MAXGETDENTS_SIZE];
SysRes f;
f = VG_(open)("/proc/self/fd", VKI_O_RDONLY, 0);
if (sr_isError(f)) {
init_preopened_fds_without_proc_self_fd();
return;
}
while ((ret = VG_(getdents64)(sr_Res(f), (struct vki_dirent64 *) buf,
sizeof(buf))) > 0) {
Int i = 0;
while (i < ret) {
/* Proceed one entry. */
struct vki_dirent64 *d = (struct vki_dirent64 *) (buf + i);
if (VG_(strcmp)(d->d_name, ".") && VG_(strcmp)(d->d_name, "..")) {
HChar *s;
Int fno = VG_(strtoll10)(d->d_name, &s);
if (*s == '\0') {
if (fno != sr_Res(f))
if (VG_(clo_track_fds))
ML_(record_fd_open_named)(-1, fno);
} else {
VG_(message)(Vg_DebugMsg,
"Warning: invalid file name in /proc/self/fd: %s\n",
d->d_name);
}
}
/* Move on the next entry. */
i += d->d_reclen;
}
}
VG_(close)(sr_Res(f));
#else
# error Unknown OS
#endif
}
static
HChar *strdupcat ( const HChar* cc, const HChar *s1, const HChar *s2,
ArenaId aid )
{
UInt len = VG_(strlen) ( s1 ) + VG_(strlen) ( s2 ) + 1;
HChar *result = VG_(arena_malloc) ( aid, cc, len );
VG_(strcpy) ( result, s1 );
VG_(strcat) ( result, s2 );
return result;
}
static
void pre_mem_read_sendmsg ( ThreadId tid, Bool read,
const HChar *msg, Addr base, SizeT size )
{
HChar *outmsg = strdupcat ( "di.syswrap.pmrs.1",
"sendmsg", msg, VG_AR_CORE );
PRE_MEM_READ( outmsg, base, size );
VG_(free) ( outmsg );
}
static
void pre_mem_write_recvmsg ( ThreadId tid, Bool read,
const HChar *msg, Addr base, SizeT size )
{
HChar *outmsg = strdupcat ( "di.syswrap.pmwr.1",
"recvmsg", msg, VG_AR_CORE );
if ( read )
PRE_MEM_READ( outmsg, base, size );
else
PRE_MEM_WRITE( outmsg, base, size );
VG_(free) ( outmsg );
}
static
void post_mem_write_recvmsg ( ThreadId tid, Bool read,
const HChar *fieldName, Addr base, SizeT size )
{
if ( !read )
POST_MEM_WRITE( base, size );
}
static
void msghdr_foreachfield (
ThreadId tid,
const HChar *name,
struct vki_msghdr *msg,
UInt length,
void (*foreach_func)( ThreadId, Bool, const HChar *, Addr, SizeT ),
Bool rekv /* "recv" apparently shadows some header decl on OSX108 */
)
{
HChar *fieldName;
if ( !msg )
return;
fieldName = VG_(malloc) ( "di.syswrap.mfef", VG_(strlen)(name) + 32 );
VG_(sprintf) ( fieldName, "(%s)", name );
foreach_func ( tid, True, fieldName, (Addr)&msg->msg_name, sizeof( msg->msg_name ) );
foreach_func ( tid, True, fieldName, (Addr)&msg->msg_namelen, sizeof( msg->msg_namelen ) );
foreach_func ( tid, True, fieldName, (Addr)&msg->msg_iov, sizeof( msg->msg_iov ) );
foreach_func ( tid, True, fieldName, (Addr)&msg->msg_iovlen, sizeof( msg->msg_iovlen ) );
foreach_func ( tid, True, fieldName, (Addr)&msg->msg_control, sizeof( msg->msg_control ) );
foreach_func ( tid, True, fieldName, (Addr)&msg->msg_controllen, sizeof( msg->msg_controllen ) );
/* msg_flags is completely ignored for send_mesg, recv_mesg doesn't read
the field, but does write to it. */
if ( rekv )
foreach_func ( tid, False, fieldName, (Addr)&msg->msg_flags, sizeof( msg->msg_flags ) );
if ( ML_(safe_to_deref)(&msg->msg_name, sizeof (void *))
&& msg->msg_name ) {
VG_(sprintf) ( fieldName, "(%s.msg_name)", name );
foreach_func ( tid, False, fieldName,
(Addr)msg->msg_name, msg->msg_namelen );
}
if ( ML_(safe_to_deref)(&msg->msg_iov, sizeof (void *))
&& msg->msg_iov ) {
struct vki_iovec *iov = msg->msg_iov;
UInt i;
VG_(sprintf) ( fieldName, "(%s.msg_iov)", name );
if (ML_(safe_to_deref)(&msg->msg_iovlen, sizeof (UInt))) {
foreach_func ( tid, True, fieldName, (Addr)iov,
msg->msg_iovlen * sizeof( struct vki_iovec ) );
for ( i = 0; i < msg->msg_iovlen && length > 0; ++i, ++iov ) {
if (ML_(safe_to_deref)(&iov->iov_len, sizeof (UInt))) {
UInt iov_len = iov->iov_len <= length ? iov->iov_len : length;
VG_(sprintf) ( fieldName, "(%s.msg_iov[%u])", name, i );
foreach_func ( tid, False, fieldName,
(Addr)iov->iov_base, iov_len );
length = length - iov_len;
}
}
}
}
if ( ML_(safe_to_deref) (&msg->msg_control, sizeof (void *))
&& msg->msg_control )
{
VG_(sprintf) ( fieldName, "(%s.msg_control)", name );
foreach_func ( tid, False, fieldName,
(Addr)msg->msg_control, msg->msg_controllen );
}
VG_(free) ( fieldName );
}
static void check_cmsg_for_fds(ThreadId tid, struct vki_msghdr *msg)
{
struct vki_cmsghdr *cm = VKI_CMSG_FIRSTHDR(msg);
while (cm) {
if (cm->cmsg_level == VKI_SOL_SOCKET &&
cm->cmsg_type == VKI_SCM_RIGHTS ) {
Int *fds = (Int *) VKI_CMSG_DATA(cm);
Int fdc = (cm->cmsg_len - VKI_CMSG_ALIGN(sizeof(struct vki_cmsghdr)))
/ sizeof(int);
Int i;
for (i = 0; i < fdc; i++)
if(VG_(clo_track_fds))
// XXX: must we check the range on these fds with
// ML_(fd_allowed)()?
ML_(record_fd_open_named)(tid, fds[i]);
}
cm = VKI_CMSG_NXTHDR(msg, cm);
}
}
/* GrP kernel ignores sa_len (at least on Darwin); this checks the rest */
static
void pre_mem_read_sockaddr ( ThreadId tid,
const HChar *description,
struct vki_sockaddr *sa, UInt salen )
{
HChar *outmsg;
struct vki_sockaddr_un* saun = (struct vki_sockaddr_un *)sa;
struct vki_sockaddr_in* sin = (struct vki_sockaddr_in *)sa;
struct vki_sockaddr_in6* sin6 = (struct vki_sockaddr_in6 *)sa;
# ifdef VKI_AF_BLUETOOTH
struct vki_sockaddr_rc* rc = (struct vki_sockaddr_rc *)sa;
# endif
# ifdef VKI_AF_NETLINK
struct vki_sockaddr_nl* nl = (struct vki_sockaddr_nl *)sa;
# endif
/* NULL/zero-length sockaddrs are legal */
if ( sa == NULL || salen == 0 ) return;
outmsg = VG_(malloc) ( "di.syswrap.pmr_sockaddr.1",
VG_(strlen)( description ) + 30 );
VG_(sprintf) ( outmsg, description, "sa_family" );
PRE_MEM_READ( outmsg, (Addr) &sa->sa_family, sizeof(vki_sa_family_t));
/* Don't do any extra checking if we cannot determine the sa_family. */
if (! ML_(safe_to_deref) (&sa->sa_family, sizeof(vki_sa_family_t))) {
VG_(free) (outmsg);
return;
}
switch (sa->sa_family) {
case VKI_AF_UNIX:
if (ML_(safe_to_deref) (&saun->sun_path, sizeof (Addr))) {
VG_(sprintf) ( outmsg, description, "sun_path" );
PRE_MEM_RASCIIZ( outmsg, (Addr) saun->sun_path );
// GrP fixme max of sun_len-2? what about nul char?
}
break;
case VKI_AF_INET:
VG_(sprintf) ( outmsg, description, "sin_port" );
PRE_MEM_READ( outmsg, (Addr) &sin->sin_port, sizeof (sin->sin_port) );
VG_(sprintf) ( outmsg, description, "sin_addr" );
PRE_MEM_READ( outmsg, (Addr) &sin->sin_addr, sizeof (sin->sin_addr) );
break;
case VKI_AF_INET6:
VG_(sprintf) ( outmsg, description, "sin6_port" );
PRE_MEM_READ( outmsg,
(Addr) &sin6->sin6_port, sizeof (sin6->sin6_port) );
VG_(sprintf) ( outmsg, description, "sin6_flowinfo" );
PRE_MEM_READ( outmsg,
(Addr) &sin6->sin6_flowinfo, sizeof (sin6->sin6_flowinfo) );
VG_(sprintf) ( outmsg, description, "sin6_addr" );
PRE_MEM_READ( outmsg,
(Addr) &sin6->sin6_addr, sizeof (sin6->sin6_addr) );
VG_(sprintf) ( outmsg, description, "sin6_scope_id" );
PRE_MEM_READ( outmsg,
(Addr) &sin6->sin6_scope_id, sizeof (sin6->sin6_scope_id) );
break;
# ifdef VKI_AF_BLUETOOTH
case VKI_AF_BLUETOOTH:
VG_(sprintf) ( outmsg, description, "rc_bdaddr" );
PRE_MEM_READ( outmsg, (Addr) &rc->rc_bdaddr, sizeof (rc->rc_bdaddr) );
VG_(sprintf) ( outmsg, description, "rc_channel" );
PRE_MEM_READ( outmsg, (Addr) &rc->rc_channel, sizeof (rc->rc_channel) );
break;
# endif
# ifdef VKI_AF_NETLINK
case VKI_AF_NETLINK:
VG_(sprintf)(outmsg, description, "nl_pid");
PRE_MEM_READ(outmsg, (Addr)&nl->nl_pid, sizeof(nl->nl_pid));
VG_(sprintf)(outmsg, description, "nl_groups");
PRE_MEM_READ(outmsg, (Addr)&nl->nl_groups, sizeof(nl->nl_groups));
break;
# endif
# ifdef VKI_AF_UNSPEC
case VKI_AF_UNSPEC:
break;
# endif
default:
/* No specific information about this address family.
Let's just check the full data following the family.
Note that this can give false positive if this (unknown)
struct sockaddr_???? has padding bytes between its elements. */
VG_(sprintf) ( outmsg, description, "sa_data" );
PRE_MEM_READ( outmsg, (Addr)&sa->sa_family + sizeof(sa->sa_family),
salen - sizeof(sa->sa_family));
break;
}
VG_(free) ( outmsg );
}
/* Dereference a pointer to a UInt. */
static UInt deref_UInt ( ThreadId tid, Addr a, const HChar* s )
{
UInt* a_p = (UInt*)a;
PRE_MEM_READ( s, (Addr)a_p, sizeof(UInt) );
if (a_p == NULL || ! ML_(safe_to_deref) (a_p, sizeof(UInt)))
return 0;
else
return *a_p;
}
void ML_(buf_and_len_pre_check) ( ThreadId tid, Addr buf_p, Addr buflen_p,
const HChar* buf_s, const HChar* buflen_s )
{
if (VG_(tdict).track_pre_mem_write) {
UInt buflen_in = deref_UInt( tid, buflen_p, buflen_s);
if (buflen_in > 0) {
VG_(tdict).track_pre_mem_write(
Vg_CoreSysCall, tid, buf_s, buf_p, buflen_in );
}
}
}
void ML_(buf_and_len_post_check) ( ThreadId tid, SysRes res,
Addr buf_p, Addr buflen_p, const HChar* s )
{
if (!sr_isError(res) && VG_(tdict).track_post_mem_write) {
UInt buflen_out = deref_UInt( tid, buflen_p, s);
if (buflen_out > 0 && buf_p != (Addr)NULL) {
VG_(tdict).track_post_mem_write( Vg_CoreSysCall, tid, buf_p, buflen_out );
}
}
}
/* ---------------------------------------------------------------------
Data seg end, for brk()
------------------------------------------------------------------ */
/* +--------+------------+
| anon | resvn |
+--------+------------+
^ ^ ^
| | boundary is page aligned
| VG_(brk_limit) -- no alignment constraint
VG_(brk_base) -- page aligned -- does not move
Both the anon part and the reservation part are always at least
one page.
*/
/* Set the new data segment end to NEWBRK. If this succeeds, return
NEWBRK, else return the current data segment end. */
static Addr do_brk ( Addr newbrk, ThreadId tid )
{
NSegment const* aseg;
Addr newbrkP;
SizeT delta;
Bool debug = False;
if (debug)
VG_(printf)("\ndo_brk: brk_base=%#lx brk_limit=%#lx newbrk=%#lx\n",
VG_(brk_base), VG_(brk_limit), newbrk);
if (0) VG_(am_show_nsegments)(0, "in_brk");
if (newbrk < VG_(brk_base))
/* Clearly impossible. */
goto bad;
if (newbrk < VG_(brk_limit)) {
/* shrinking the data segment. Be lazy and don't munmap the
excess area. */
NSegment const * seg = VG_(am_find_nsegment)(newbrk);
vg_assert(seg);
if (seg->hasT)
VG_(discard_translations)( newbrk, VG_(brk_limit) - newbrk,
"do_brk(shrink)" );
/* Since we're being lazy and not unmapping pages, we have to
zero out the area, so that if the area later comes back into
circulation, it will be filled with zeroes, as if it really
had been unmapped and later remapped. Be a bit paranoid and
try hard to ensure we're not going to segfault by doing the
write - check both ends of the range are in the same segment
and that segment is writable. */
NSegment const * seg2;
seg2 = VG_(am_find_nsegment)( VG_(brk_limit) - 1 );
vg_assert(seg2);
if (seg == seg2 && seg->hasW)
VG_(memset)( (void*)newbrk, 0, VG_(brk_limit) - newbrk );
VG_(brk_limit) = newbrk;
return newbrk;
}
/* otherwise we're expanding the brk segment. */
if (VG_(brk_limit) > VG_(brk_base))
aseg = VG_(am_find_nsegment)( VG_(brk_limit)-1 );
else
aseg = VG_(am_find_nsegment)( VG_(brk_limit) );
/* These should be assured by setup_client_dataseg in m_main. */
vg_assert(aseg);
vg_assert(aseg->kind == SkAnonC);
if (newbrk <= aseg->end + 1) {
/* still fits within the anon segment. */
VG_(brk_limit) = newbrk;
return newbrk;
}
newbrkP = VG_PGROUNDUP(newbrk);
delta = newbrkP - (aseg->end + 1);
vg_assert(delta > 0);
vg_assert(VG_IS_PAGE_ALIGNED(delta));
Bool overflow;
if (! VG_(am_extend_into_adjacent_reservation_client)( aseg->start, delta,
&overflow)) {
if (overflow)
VG_(umsg)("brk segment overflow in thread #%u: can't grow to %#lx\n",
tid, newbrkP);
else
VG_(umsg)("Cannot map memory to grow brk segment in thread #%u "
"to %#lx\n", tid, newbrkP);
VG_(umsg)("(see section Limitations in user manual)\n");
goto bad;
}
VG_(brk_limit) = newbrk;
return newbrk;
bad:
return VG_(brk_limit);
}
/* ---------------------------------------------------------------------
Vet file descriptors for sanity
------------------------------------------------------------------ */
/*
> - what does the "Bool soft" parameter mean?
(Tom Hughes, 3 Oct 05):
Whether or not to consider a file descriptor invalid if it is above
the current soft limit.
Basically if we are testing whether a newly created file descriptor is
valid (in a post handler) then we set soft to true, and if we are
testing whether a file descriptor that is about to be used (in a pre
handler) is valid [viz, an already-existing fd] then we set it to false.
The point is that if the (virtual) soft limit is lowered then any
existing descriptors can still be read/written/closed etc (so long as
they are below the valgrind reserved descriptors) but no new
descriptors can be created above the new soft limit.
(jrs 4 Oct 05: in which case, I've renamed it "isNewFd")
*/
/* Return true if we're allowed to use or create this fd */
Bool ML_(fd_allowed)(Int fd, const HChar *syscallname, ThreadId tid,
Bool isNewFd)
{
Bool allowed = True;
/* hard limits always apply */
if (fd < 0 || fd >= VG_(fd_hard_limit))
allowed = False;
/* hijacking the output fds is never allowed */
if (fd == VG_(log_output_sink).fd || fd == VG_(xml_output_sink).fd)
allowed = False;
/* if creating a new fd (rather than using an existing one), the
soft limit must also be observed */
if (isNewFd && fd >= VG_(fd_soft_limit))
allowed = False;
/* this looks like it ought to be included, but causes problems: */
/*
if (fd == 2 && VG_(debugLog_getLevel)() > 0)
allowed = False;
*/
/* The difficulty is as follows: consider a program P which expects
to be able to mess with (redirect) its own stderr (fd 2).
Usually to deal with P we would issue command line flags to send
logging somewhere other than stderr, so as not to disrupt P.
The problem is that -d unilaterally hijacks stderr with no
consultation with P. And so, if this check is enabled, P will
work OK normally but fail if -d is issued.
Basically -d is a hack and you take your chances when using it.
It's very useful for low level debugging -- particularly at
startup -- and having its presence change the behaviour of the
client is exactly what we don't want. */
/* croak? */
if ((!allowed) && VG_(showing_core_errors)() ) {
VG_(message)(Vg_UserMsg,
"Warning: invalid file descriptor %d in syscall %s()\n",
fd, syscallname);
if (fd == VG_(log_output_sink).fd && VG_(log_output_sink).fd >= 0)
VG_(message)(Vg_UserMsg,
" Use --log-fd=<number> to select an alternative log fd.\n");
if (fd == VG_(xml_output_sink).fd && VG_(xml_output_sink).fd >= 0)
VG_(message)(Vg_UserMsg,
" Use --xml-fd=<number> to select an alternative XML "
"output fd.\n");
// DDD: consider always printing this stack trace, it's useful.
// Also consider also making this a proper core error, ie.
// suppressible and all that.
if (VG_(clo_verbosity) > 1) {
VG_(get_and_pp_StackTrace)(tid, VG_(clo_backtrace_size));
}
}
return allowed;
}
/* ---------------------------------------------------------------------
Deal with a bunch of socket-related syscalls
------------------------------------------------------------------ */
/* ------ */
void
ML_(generic_PRE_sys_socketpair) ( ThreadId tid,
UWord arg0, UWord arg1,
UWord arg2, UWord arg3 )
{
/* int socketpair(int d, int type, int protocol, int sv[2]); */
PRE_MEM_WRITE( "socketcall.socketpair(sv)",
arg3, 2*sizeof(int) );
}
SysRes
ML_(generic_POST_sys_socketpair) ( ThreadId tid,
SysRes res,
UWord arg0, UWord arg1,
UWord arg2, UWord arg3 )
{
SysRes r = res;
Int fd1 = ((Int*)arg3)[0];
Int fd2 = ((Int*)arg3)[1];
vg_assert(!sr_isError(res)); /* guaranteed by caller */
POST_MEM_WRITE( arg3, 2*sizeof(int) );
if (!ML_(fd_allowed)(fd1, "socketcall.socketpair", tid, True) ||
!ML_(fd_allowed)(fd2, "socketcall.socketpair", tid, True)) {
VG_(close)(fd1);
VG_(close)(fd2);
r = VG_(mk_SysRes_Error)( VKI_EMFILE );
} else {
POST_MEM_WRITE( arg3, 2*sizeof(int) );
if (VG_(clo_track_fds)) {
ML_(record_fd_open_nameless)(tid, fd1);
ML_(record_fd_open_nameless)(tid, fd2);
}
}
return r;
}
/* ------ */
SysRes
ML_(generic_POST_sys_socket) ( ThreadId tid, SysRes res )
{
SysRes r = res;
vg_assert(!sr_isError(res)); /* guaranteed by caller */
if (!ML_(fd_allowed)(sr_Res(res), "socket", tid, True)) {
VG_(close)(sr_Res(res));
r = VG_(mk_SysRes_Error)( VKI_EMFILE );
} else {
if (VG_(clo_track_fds))
ML_(record_fd_open_nameless)(tid, sr_Res(res));
}
return r;
}
/* ------ */
void
ML_(generic_PRE_sys_bind) ( ThreadId tid,
UWord arg0, UWord arg1, UWord arg2 )
{
/* int bind(int sockfd, struct sockaddr *my_addr,
int addrlen); */
pre_mem_read_sockaddr(
tid, "socketcall.bind(my_addr.%s)",
(struct vki_sockaddr *) arg1, arg2
);
}
/* ------ */
void
ML_(generic_PRE_sys_accept) ( ThreadId tid,
UWord arg0, UWord arg1, UWord arg2 )
{
/* int accept(int s, struct sockaddr *addr, int *addrlen); */
Addr addr_p = arg1;
Addr addrlen_p = arg2;
if (addr_p != (Addr)NULL)
ML_(buf_and_len_pre_check) ( tid, addr_p, addrlen_p,
"socketcall.accept(addr)",
"socketcall.accept(addrlen_in)" );
}
SysRes
ML_(generic_POST_sys_accept) ( ThreadId tid,
SysRes res,
UWord arg0, UWord arg1, UWord arg2 )
{
SysRes r = res;
vg_assert(!sr_isError(res)); /* guaranteed by caller */
if (!ML_(fd_allowed)(sr_Res(res), "accept", tid, True)) {
VG_(close)(sr_Res(res));
r = VG_(mk_SysRes_Error)( VKI_EMFILE );
} else {
Addr addr_p = arg1;
Addr addrlen_p = arg2;
if (addr_p != (Addr)NULL)
ML_(buf_and_len_post_check) ( tid, res, addr_p, addrlen_p,
"socketcall.accept(addrlen_out)" );
if (VG_(clo_track_fds))
ML_(record_fd_open_nameless)(tid, sr_Res(res));
}
return r;
}
/* ------ */
void
ML_(generic_PRE_sys_sendto) ( ThreadId tid,
UWord arg0, UWord arg1, UWord arg2,
UWord arg3, UWord arg4, UWord arg5 )
{
/* int sendto(int s, const void *msg, int len,
unsigned int flags,
const struct sockaddr *to, int tolen); */
PRE_MEM_READ( "socketcall.sendto(msg)",
arg1, /* msg */
arg2 /* len */ );
pre_mem_read_sockaddr(
tid, "socketcall.sendto(to.%s)",
(struct vki_sockaddr *) arg4, arg5
);
}
/* ------ */
void
ML_(generic_PRE_sys_send) ( ThreadId tid,
UWord arg0, UWord arg1, UWord arg2 )
{
/* int send(int s, const void *msg, size_t len, int flags); */
PRE_MEM_READ( "socketcall.send(msg)",
arg1, /* msg */
arg2 /* len */ );
}
/* ------ */
void
ML_(generic_PRE_sys_recvfrom) ( ThreadId tid,
UWord arg0, UWord arg1, UWord arg2,
UWord arg3, UWord arg4, UWord arg5 )
{
/* int recvfrom(int s, void *buf, int len, unsigned int flags,
struct sockaddr *from, int *fromlen); */
Addr buf_p = arg1;
Int len = arg2;
Addr from_p = arg4;
Addr fromlen_p = arg5;
PRE_MEM_WRITE( "socketcall.recvfrom(buf)", buf_p, len );
if (from_p != (Addr)NULL)
ML_(buf_and_len_pre_check) ( tid, from_p, fromlen_p,
"socketcall.recvfrom(from)",
"socketcall.recvfrom(fromlen_in)" );
}
void
ML_(generic_POST_sys_recvfrom) ( ThreadId tid,
SysRes res,
UWord arg0, UWord arg1, UWord arg2,
UWord arg3, UWord arg4, UWord arg5 )
{
Addr buf_p = arg1;
Int len = arg2;
Addr from_p = arg4;
Addr fromlen_p = arg5;
vg_assert(!sr_isError(res)); /* guaranteed by caller */
if (from_p != (Addr)NULL)
ML_(buf_and_len_post_check) ( tid, res, from_p, fromlen_p,
"socketcall.recvfrom(fromlen_out)" );
POST_MEM_WRITE( buf_p, len );
}
/* ------ */
void
ML_(generic_PRE_sys_recv) ( ThreadId tid,
UWord arg0, UWord arg1, UWord arg2 )
{
/* int recv(int s, void *buf, int len, unsigned int flags); */
/* man 2 recv says:
The recv call is normally used only on a connected socket
(see connect(2)) and is identical to recvfrom with a NULL
from parameter.
*/
PRE_MEM_WRITE( "socketcall.recv(buf)",
arg1, /* buf */
arg2 /* len */ );
}
void
ML_(generic_POST_sys_recv) ( ThreadId tid,
UWord res,
UWord arg0, UWord arg1, UWord arg2 )
{
if (res >= 0 && arg1 != 0) {
POST_MEM_WRITE( arg1, /* buf */
arg2 /* len */ );
}
}
/* ------ */
void
ML_(generic_PRE_sys_connect) ( ThreadId tid,
UWord arg0, UWord arg1, UWord arg2 )
{
/* int connect(int sockfd,
struct sockaddr *serv_addr, int addrlen ); */
pre_mem_read_sockaddr( tid,
"socketcall.connect(serv_addr.%s)",
(struct vki_sockaddr *) arg1, arg2);
}
/* ------ */
void
ML_(generic_PRE_sys_setsockopt) ( ThreadId tid,
UWord arg0, UWord arg1, UWord arg2,
UWord arg3, UWord arg4 )
{
/* int setsockopt(int s, int level, int optname,
const void *optval, int optlen); */
PRE_MEM_READ( "socketcall.setsockopt(optval)",
arg3, /* optval */
arg4 /* optlen */ );
}
/* ------ */
void
ML_(generic_PRE_sys_getsockname) ( ThreadId tid,
UWord arg0, UWord arg1, UWord arg2 )
{
/* int getsockname(int s, struct sockaddr* name, int* namelen) */
Addr name_p = arg1;
Addr namelen_p = arg2;
/* Nb: name_p cannot be NULL */
ML_(buf_and_len_pre_check) ( tid, name_p, namelen_p,
"socketcall.getsockname(name)",
"socketcall.getsockname(namelen_in)" );
}
void
ML_(generic_POST_sys_getsockname) ( ThreadId tid,
SysRes res,
UWord arg0, UWord arg1, UWord arg2 )
{
Addr name_p = arg1;
Addr namelen_p = arg2;
vg_assert(!sr_isError(res)); /* guaranteed by caller */
ML_(buf_and_len_post_check) ( tid, res, name_p, namelen_p,
"socketcall.getsockname(namelen_out)" );
}
/* ------ */
void
ML_(generic_PRE_sys_getpeername) ( ThreadId tid,
UWord arg0, UWord arg1, UWord arg2 )
{
/* int getpeername(int s, struct sockaddr* name, int* namelen) */
Addr name_p = arg1;
Addr namelen_p = arg2;
/* Nb: name_p cannot be NULL */
ML_(buf_and_len_pre_check) ( tid, name_p, namelen_p,
"socketcall.getpeername(name)",
"socketcall.getpeername(namelen_in)" );
}
void
ML_(generic_POST_sys_getpeername) ( ThreadId tid,
SysRes res,
UWord arg0, UWord arg1, UWord arg2 )
{
Addr name_p = arg1;
Addr namelen_p = arg2;
vg_assert(!sr_isError(res)); /* guaranteed by caller */
ML_(buf_and_len_post_check) ( tid, res, name_p, namelen_p,
"socketcall.getpeername(namelen_out)" );
}
/* ------ */
void
ML_(generic_PRE_sys_sendmsg) ( ThreadId tid, const HChar *name,
struct vki_msghdr *msg )
{
msghdr_foreachfield ( tid, name, msg, ~0, pre_mem_read_sendmsg, False );
}
/* ------ */
void
ML_(generic_PRE_sys_recvmsg) ( ThreadId tid, const HChar *name,
struct vki_msghdr *msg )
{
msghdr_foreachfield ( tid, name, msg, ~0, pre_mem_write_recvmsg, True );
}
void
ML_(generic_POST_sys_recvmsg) ( ThreadId tid, const HChar *name,
struct vki_msghdr *msg, UInt length )
{
msghdr_foreachfield( tid, name, msg, length, post_mem_write_recvmsg, True );
check_cmsg_for_fds( tid, msg );
}
/* ---------------------------------------------------------------------
Deal with a bunch of IPC related syscalls
------------------------------------------------------------------ */
/* ------ */
void
ML_(generic_PRE_sys_semop) ( ThreadId tid,
UWord arg0, UWord arg1, UWord arg2 )
{
/* int semop(int semid, struct sembuf *sops, unsigned nsops); */
PRE_MEM_READ( "semop(sops)", arg1, arg2 * sizeof(struct vki_sembuf) );
}
/* ------ */
void
ML_(generic_PRE_sys_semtimedop) ( ThreadId tid,
UWord arg0, UWord arg1,
UWord arg2, UWord arg3 )
{
/* int semtimedop(int semid, struct sembuf *sops, unsigned nsops,
struct timespec *timeout); */
PRE_MEM_READ( "semtimedop(sops)", arg1, arg2 * sizeof(struct vki_sembuf) );
if (arg3 != 0)
PRE_MEM_READ( "semtimedop(timeout)", arg3, sizeof(struct vki_timespec) );
}
/* ------ */
static
UInt get_sem_count( Int semid )
{
struct vki_semid_ds buf;
union vki_semun arg;
SysRes res;
/* Doesn't actually seem to be necessary, but gcc-4.4.0 20081017
(experimental) otherwise complains that the use in the return
statement below is uninitialised. */
buf.sem_nsems = 0;
arg.buf = &buf;
# if defined(__NR_semctl)
res = VG_(do_syscall4)(__NR_semctl, semid, 0, VKI_IPC_STAT, *(UWord *)&arg);
# elif defined(__NR_semsys) /* Solaris */
res = VG_(do_syscall5)(__NR_semsys, VKI_SEMCTL, semid, 0, VKI_IPC_STAT,
*(UWord *)&arg);
# else
res = VG_(do_syscall5)(__NR_ipc, 3 /* IPCOP_semctl */, semid, 0,
VKI_IPC_STAT, (UWord)&arg);
# endif
if (sr_isError(res))
return 0;
return buf.sem_nsems;
}
void
ML_(generic_PRE_sys_semctl) ( ThreadId tid,
UWord arg0, UWord arg1,
UWord arg2, UWord arg3 )
{
/* int semctl(int semid, int semnum, int cmd, ...); */
union vki_semun arg = *(union vki_semun *)&arg3;
UInt nsems;
switch (arg2 /* cmd */) {
#if defined(VKI_IPC_INFO)
case VKI_IPC_INFO:
case VKI_SEM_INFO:
case VKI_IPC_INFO|VKI_IPC_64:
case VKI_SEM_INFO|VKI_IPC_64:
PRE_MEM_WRITE( "semctl(IPC_INFO, arg.buf)",
(Addr)arg.buf, sizeof(struct vki_seminfo) );
break;
#endif
case VKI_IPC_STAT:
#if defined(VKI_SEM_STAT)
case VKI_SEM_STAT:
#endif
PRE_MEM_WRITE( "semctl(IPC_STAT, arg.buf)",
(Addr)arg.buf, sizeof(struct vki_semid_ds) );
break;
#if defined(VKI_IPC_64)
case VKI_IPC_STAT|VKI_IPC_64:
#if defined(VKI_SEM_STAT)
case VKI_SEM_STAT|VKI_IPC_64:
#endif
#endif
#if defined(VKI_IPC_STAT64)
case VKI_IPC_STAT64:
#endif
#if defined(VKI_IPC_64) || defined(VKI_IPC_STAT64)
PRE_MEM_WRITE( "semctl(IPC_STAT, arg.buf)",
(Addr)arg.buf, sizeof(struct vki_semid64_ds) );
break;
#endif
case VKI_IPC_SET:
PRE_MEM_READ( "semctl(IPC_SET, arg.buf)",
(Addr)arg.buf, sizeof(struct vki_semid_ds) );
break;
#if defined(VKI_IPC_64)
case VKI_IPC_SET|VKI_IPC_64:
#endif
#if defined(VKI_IPC_SET64)
case VKI_IPC_SET64:
#endif
#if defined(VKI_IPC64) || defined(VKI_IPC_SET64)
PRE_MEM_READ( "semctl(IPC_SET, arg.buf)",
(Addr)arg.buf, sizeof(struct vki_semid64_ds) );
break;
#endif
case VKI_GETALL:
#if defined(VKI_IPC_64)
case VKI_GETALL|VKI_IPC_64:
#endif
nsems = get_sem_count( arg0 );
PRE_MEM_WRITE( "semctl(IPC_GETALL, arg.array)",
(Addr)arg.array, sizeof(unsigned short) * nsems );
break;
case VKI_SETALL:
#if defined(VKI_IPC_64)
case VKI_SETALL|VKI_IPC_64:
#endif
nsems = get_sem_count( arg0 );
PRE_MEM_READ( "semctl(IPC_SETALL, arg.array)",
(Addr)arg.array, sizeof(unsigned short) * nsems );
break;
}
}
void
ML_(generic_POST_sys_semctl) ( ThreadId tid,
UWord res,
UWord arg0, UWord arg1,
UWord arg2, UWord arg3 )
{
union vki_semun arg = *(union vki_semun *)&arg3;
UInt nsems;
switch (arg2 /* cmd */) {
#if defined(VKI_IPC_INFO)
case VKI_IPC_INFO:
case VKI_SEM_INFO:
case VKI_IPC_INFO|VKI_IPC_64:
case VKI_SEM_INFO|VKI_IPC_64:
POST_MEM_WRITE( (Addr)arg.buf, sizeof(struct vki_seminfo) );
break;
#endif
case VKI_IPC_STAT:
#if defined(VKI_SEM_STAT)
case VKI_SEM_STAT:
#endif
POST_MEM_WRITE( (Addr)arg.buf, sizeof(struct vki_semid_ds) );
break;
#if defined(VKI_IPC_64)
case VKI_IPC_STAT|VKI_IPC_64:
case VKI_SEM_STAT|VKI_IPC_64:
#endif
#if defined(VKI_IPC_STAT64)
case VKI_IPC_STAT64:
#endif
#if defined(VKI_IPC_64) || defined(VKI_IPC_STAT64)
POST_MEM_WRITE( (Addr)arg.buf, sizeof(struct vki_semid64_ds) );
break;
#endif
case VKI_GETALL:
#if defined(VKI_IPC_64)
case VKI_GETALL|VKI_IPC_64:
#endif
nsems = get_sem_count( arg0 );
POST_MEM_WRITE( (Addr)arg.array, sizeof(unsigned short) * nsems );
break;
}
}
/* ------ */
/* ------ */
static
SizeT get_shm_size ( Int shmid )
{
#if defined(__NR_shmctl)
# ifdef VKI_IPC_64
struct vki_shmid64_ds buf;
# if defined(VGP_amd64_linux) || defined(VGP_arm64_linux)
/* See bug 222545 comment 7 */
SysRes __res = VG_(do_syscall3)(__NR_shmctl, shmid,
VKI_IPC_STAT, (UWord)&buf);
# else
SysRes __res = VG_(do_syscall3)(__NR_shmctl, shmid,
VKI_IPC_STAT|VKI_IPC_64, (UWord)&buf);
# endif
# else /* !def VKI_IPC_64 */
struct vki_shmid_ds buf;
SysRes __res = VG_(do_syscall3)(__NR_shmctl, shmid, VKI_IPC_STAT, (UWord)&buf);
# endif /* def VKI_IPC_64 */
#elif defined(__NR_shmsys) /* Solaris */
struct vki_shmid_ds buf;
SysRes __res = VG_(do_syscall4)(__NR_shmsys, VKI_SHMCTL, shmid, VKI_IPC_STAT,
(UWord)&buf);
#else
struct vki_shmid_ds buf;
SysRes __res = VG_(do_syscall5)(__NR_ipc, 24 /* IPCOP_shmctl */, shmid,
VKI_IPC_STAT, 0, (UWord)&buf);
#endif
if (sr_isError(__res))
return 0;
return (SizeT) buf.shm_segsz;
}
UWord
ML_(generic_PRE_sys_shmat) ( ThreadId tid,
UWord arg0, UWord arg1, UWord arg2 )
{
/* void *shmat(int shmid, const void *shmaddr, int shmflg); */
SizeT segmentSize = get_shm_size ( arg0 );
UWord tmp;
Bool ok;
if (arg1 == 0) {
/* arm-linux only: work around the fact that
VG_(am_get_advisory_client_simple) produces something that is
VKI_PAGE_SIZE aligned, whereas what we want is something
VKI_SHMLBA aligned, and VKI_SHMLBA >= VKI_PAGE_SIZE. Hence
increase the request size by VKI_SHMLBA - VKI_PAGE_SIZE and
then round the result up to the next VKI_SHMLBA boundary.
See bug 222545 comment 15. So far, arm-linux is the only
platform where this is known to be necessary. */
vg_assert(VKI_SHMLBA >= VKI_PAGE_SIZE);
if (VKI_SHMLBA > VKI_PAGE_SIZE) {
segmentSize += VKI_SHMLBA - VKI_PAGE_SIZE;
}
tmp = VG_(am_get_advisory_client_simple)(0, segmentSize, &ok);
if (ok) {
if (VKI_SHMLBA > VKI_PAGE_SIZE) {
arg1 = VG_ROUNDUP(tmp, VKI_SHMLBA);
} else {
arg1 = tmp;
}
}
}
else if (!ML_(valid_client_addr)(arg1, segmentSize, tid, "shmat"))
arg1 = 0;
return arg1;
}
void
ML_(generic_POST_sys_shmat) ( ThreadId tid,
UWord res,
UWord arg0, UWord arg1, UWord arg2 )
{
SizeT segmentSize = VG_PGROUNDUP(get_shm_size(arg0));
if ( segmentSize > 0 ) {
UInt prot = VKI_PROT_READ|VKI_PROT_WRITE;
Bool d;
if (arg2 & VKI_SHM_RDONLY)
prot &= ~VKI_PROT_WRITE;
/* It isn't exactly correct to pass 0 for the fd and offset
here. The kernel seems to think the corresponding section
does have dev/ino numbers:
04e52000-04ec8000 rw-s 00000000 00:06 1966090 /SYSV00000000 (deleted)
However there is no obvious way to find them. In order to
cope with the discrepancy, aspacem's sync checker omits the
dev/ino correspondence check in cases where V does not know
the dev/ino. */
d = VG_(am_notify_client_shmat)( res, segmentSize, prot );
/* we don't distinguish whether it's read-only or
* read-write -- it doesn't matter really. */
VG_TRACK( new_mem_mmap, res, segmentSize, True, True, False,
0/*di_handle*/ );
if (d)
VG_(discard_translations)( (Addr)res,
(ULong)VG_PGROUNDUP(segmentSize),
"ML_(generic_POST_sys_shmat)" );
}
}
/* ------ */
Bool
ML_(generic_PRE_sys_shmdt) ( ThreadId tid, UWord arg0 )
{
/* int shmdt(const void *shmaddr); */
return ML_(valid_client_addr)(arg0, 1, tid, "shmdt");
}
void
ML_(generic_POST_sys_shmdt) ( ThreadId tid, UWord res, UWord arg0 )
{
NSegment const* s = VG_(am_find_nsegment)(arg0);
if (s != NULL) {
Addr s_start = s->start;
SizeT s_len = s->end+1 - s->start;
Bool d;
vg_assert(s->kind == SkShmC);
vg_assert(s->start == arg0);
d = VG_(am_notify_munmap)(s_start, s_len);
s = NULL; /* s is now invalid */
VG_TRACK( die_mem_munmap, s_start, s_len );
if (d)
VG_(discard_translations)( s_start,
(ULong)s_len,
"ML_(generic_POST_sys_shmdt)" );
}
}
/* ------ */
void
ML_(generic_PRE_sys_shmctl) ( ThreadId tid,
UWord arg0, UWord arg1, UWord arg2 )
{
/* int shmctl(int shmid, int cmd, struct shmid_ds *buf); */
switch (arg1 /* cmd */) {
#if defined(VKI_IPC_INFO)
case VKI_IPC_INFO:
PRE_MEM_WRITE( "shmctl(IPC_INFO, buf)",
arg2, sizeof(struct vki_shminfo) );
break;
#if defined(VKI_IPC_64)
case VKI_IPC_INFO|VKI_IPC_64:
PRE_MEM_WRITE( "shmctl(IPC_INFO, buf)",
arg2, sizeof(struct vki_shminfo64) );
break;
#endif
#endif
#if defined(VKI_SHM_INFO)
case VKI_SHM_INFO:
#if defined(VKI_IPC_64)
case VKI_SHM_INFO|VKI_IPC_64:
#endif
PRE_MEM_WRITE( "shmctl(SHM_INFO, buf)",
arg2, sizeof(struct vki_shm_info) );
break;
#endif
case VKI_IPC_STAT:
#if defined(VKI_SHM_STAT)
case VKI_SHM_STAT:
#endif
PRE_MEM_WRITE( "shmctl(IPC_STAT, buf)",
arg2, sizeof(struct vki_shmid_ds) );
break;
#if defined(VKI_IPC_64)
case VKI_IPC_STAT|VKI_IPC_64:
case VKI_SHM_STAT|VKI_IPC_64:
PRE_MEM_WRITE( "shmctl(IPC_STAT, arg.buf)",
arg2, sizeof(struct vki_shmid64_ds) );
break;
#endif
case VKI_IPC_SET:
PRE_MEM_READ( "shmctl(IPC_SET, arg.buf)",
arg2, sizeof(struct vki_shmid_ds) );
break;
#if defined(VKI_IPC_64)
case VKI_IPC_SET|VKI_IPC_64:
PRE_MEM_READ( "shmctl(IPC_SET, arg.buf)",
arg2, sizeof(struct vki_shmid64_ds) );
break;
#endif
}
}
void
ML_(generic_POST_sys_shmctl) ( ThreadId tid,
UWord res,
UWord arg0, UWord arg1, UWord arg2 )
{
switch (arg1 /* cmd */) {
#if defined(VKI_IPC_INFO)
case VKI_IPC_INFO:
POST_MEM_WRITE( arg2, sizeof(struct vki_shminfo) );
break;
case VKI_IPC_INFO|VKI_IPC_64:
POST_MEM_WRITE( arg2, sizeof(struct vki_shminfo64) );
break;
#endif
#if defined(VKI_SHM_INFO)
case VKI_SHM_INFO:
case VKI_SHM_INFO|VKI_IPC_64:
POST_MEM_WRITE( arg2, sizeof(struct vki_shm_info) );
break;
#endif
case VKI_IPC_STAT:
#if defined(VKI_SHM_STAT)
case VKI_SHM_STAT:
#endif
POST_MEM_WRITE( arg2, sizeof(struct vki_shmid_ds) );
break;
#if defined(VKI_IPC_64)
case VKI_IPC_STAT|VKI_IPC_64:
case VKI_SHM_STAT|VKI_IPC_64:
POST_MEM_WRITE( arg2, sizeof(struct vki_shmid64_ds) );
break;
#endif
}
}
/* ---------------------------------------------------------------------
Generic handler for mmap
------------------------------------------------------------------ */
/*
* Although mmap is specified by POSIX and the argument are generally
* consistent across platforms the precise details of the low level
* argument passing conventions differ. For example:
*
* - On x86-linux there is mmap (aka old_mmap) which takes the
* arguments in a memory block and the offset in bytes; and
* mmap2 (aka sys_mmap2) which takes the arguments in the normal
* way and the offset in pages.
*
* - On ppc32-linux there is mmap (aka sys_mmap) which takes the
* arguments in the normal way and the offset in bytes; and
* mmap2 (aka sys_mmap2) which takes the arguments in the normal
* way and the offset in pages.
*
* - On amd64-linux everything is simple and there is just the one
* call, mmap (aka sys_mmap) which takes the arguments in the
* normal way and the offset in bytes.
*
* - On s390x-linux there is mmap (aka old_mmap) which takes the
* arguments in a memory block and the offset in bytes. mmap2
* is also available (but not exported via unistd.h) with
* arguments in a memory block and the offset in pages.
*
* To cope with all this we provide a generic handler function here
* and then each platform implements one or more system call handlers
* which call this generic routine after extracting and normalising
* the arguments.
*/
SysRes
ML_(generic_PRE_sys_mmap) ( ThreadId tid,
UWord arg1, UWord arg2, UWord arg3,
UWord arg4, UWord arg5, Off64T arg6 )
{
Addr advised;
SysRes sres;
MapRequest mreq;
Bool mreq_ok;
# if defined(VGO_darwin)
// Nb: we can't use this on Darwin, it has races:
// * needs to RETRY if advisory succeeds but map fails
// (could have been some other thread in a nonblocking call)
// * needs to not use fixed-position mmap() on Darwin
// (mmap will cheerfully smash whatever's already there, which might
// be a new mapping from some other thread in a nonblocking call)
VG_(core_panic)("can't use ML_(generic_PRE_sys_mmap) on Darwin");
# endif
if (arg2 == 0) {
/* SuSV3 says: If len is zero, mmap() shall fail and no mapping
shall be established. */
return VG_(mk_SysRes_Error)( VKI_EINVAL );
}
if (!VG_IS_PAGE_ALIGNED(arg1)) {
/* zap any misaligned addresses. */
/* SuSV3 says misaligned addresses only cause the MAP_FIXED case
to fail. Here, we catch them all. */
return VG_(mk_SysRes_Error)( VKI_EINVAL );
}
if (!VG_IS_PAGE_ALIGNED(arg6)) {
/* zap any misaligned offsets. */
/* SuSV3 says: The off argument is constrained to be aligned and
sized according to the value returned by sysconf() when
passed _SC_PAGESIZE or _SC_PAGE_SIZE. */
return VG_(mk_SysRes_Error)( VKI_EINVAL );
}
/* Figure out what kind of allocation constraints there are
(fixed/hint/any), and ask aspacem what we should do. */
mreq.start = arg1;
mreq.len = arg2;
if (arg4 & VKI_MAP_FIXED) {
mreq.rkind = MFixed;
} else
#if defined(VKI_MAP_ALIGN) /* Solaris specific */
if (arg4 & VKI_MAP_ALIGN) {
mreq.rkind = MAlign;
if (mreq.start == 0) {
mreq.start = VKI_PAGE_SIZE;
}
/* VKI_MAP_FIXED and VKI_MAP_ALIGN don't like each other. */
arg4 &= ~VKI_MAP_ALIGN;
} else
#endif
if (arg1 != 0) {
mreq.rkind = MHint;
} else {
mreq.rkind = MAny;
}
/* Enquire ... */
advised = VG_(am_get_advisory)( &mreq, True/*client*/, &mreq_ok );
if (!mreq_ok) {
/* Our request was bounced, so we'd better fail. */
return VG_(mk_SysRes_Error)( VKI_EINVAL );
}
# if defined(VKI_MAP_32BIT)
/* MAP_32BIT is royally unportable, so if the client asks for it, try our
best to make it work (but without complexifying aspacemgr).
If the user requested MAP_32BIT, the mmap-ed space must be in the
first 2GB of the address space. So, return ENOMEM if aspacemgr
advisory is above the first 2GB. If MAP_FIXED is also requested,
MAP_32BIT has to be ignored.
Assumption about aspacemgr behaviour: aspacemgr scans the address space
from low addresses to find a free segment. No special effort is done
to keep the first 2GB 'free' for this MAP_32BIT. So, this will often
fail once the program has already allocated significant memory. */
if ((arg4 & VKI_MAP_32BIT) && !(arg4 & VKI_MAP_FIXED)) {
if (advised + arg2 >= 0x80000000)
return VG_(mk_SysRes_Error)( VKI_ENOMEM );
}
# endif
/* Otherwise we're OK (so far). Install aspacem's choice of
address, and let the mmap go through. */
sres = VG_(am_do_mmap_NO_NOTIFY)(advised, arg2, arg3,
arg4 | VKI_MAP_FIXED,
arg5, arg6);
# if defined(VKI_MAP_32BIT)
/* No recovery trial if the advisory was not accepted. */
if ((arg4 & VKI_MAP_32BIT) && !(arg4 & VKI_MAP_FIXED)
&& sr_isError(sres)) {
return VG_(mk_SysRes_Error)( VKI_ENOMEM );
}
# endif
/* A refinement: it may be that the kernel refused aspacem's choice
of address. If we were originally asked for a hinted mapping,
there is still a last chance: try again at any address.
Hence: */
if (mreq.rkind == MHint && sr_isError(sres)) {
mreq.start = 0;
mreq.len = arg2;
mreq.rkind = MAny;
advised = VG_(am_get_advisory)( &mreq, True/*client*/, &mreq_ok );
if (!mreq_ok) {
/* Our request was bounced, so we'd better fail. */
return VG_(mk_SysRes_Error)( VKI_EINVAL );
}
/* and try again with the kernel */
sres = VG_(am_do_mmap_NO_NOTIFY)(advised, arg2, arg3,
arg4 | VKI_MAP_FIXED,
arg5, arg6);
}
/* Yet another refinement : sometimes valgrind chooses an address
which is not acceptable by the kernel. This at least happens
when mmap-ing huge pages, using the flag MAP_HUGETLB.
valgrind aspacem does not know about huge pages, and modifying
it to handle huge pages is not straightforward (e.g. need
to understand special file system mount options).
So, let's just redo an mmap, without giving any constraint to
the kernel. If that succeeds, check with aspacem that the returned
address is acceptable.
This will give a similar effect as if the user would have
hinted that address.
The aspacem state will be correctly updated afterwards.
We however cannot do this last refinement when the user asked
for a fixed mapping, as the user asked a specific address. */
if (sr_isError(sres) && !(arg4 & VKI_MAP_FIXED)) {
advised = 0;
/* try mmap with NULL address and without VKI_MAP_FIXED
to let the kernel decide. */
sres = VG_(am_do_mmap_NO_NOTIFY)(advised, arg2, arg3,
arg4,
arg5, arg6);
if (!sr_isError(sres)) {
/* The kernel is supposed to know what it is doing, but let's
do a last sanity check anyway, as if the chosen address had
been initially hinted by the client. The whole point of this
last try was to allow mmap of huge pages to succeed without
making aspacem understand them, on the other hand the kernel
does not know about valgrind reservations, so this mapping
can end up in free space and reservations. */
mreq.start = (Addr)sr_Res(sres);
mreq.len = arg2;
mreq.rkind = MHint;
advised = VG_(am_get_advisory)( &mreq, True/*client*/, &mreq_ok );
vg_assert(mreq_ok && advised == mreq.start);
}
}
if (!sr_isError(sres)) {
ULong di_handle;
/* Notify aspacem. */
notify_core_of_mmap(
(Addr)sr_Res(sres), /* addr kernel actually assigned */
arg2, /* length */
arg3, /* prot */
arg4, /* the original flags value */
arg5, /* fd */
arg6 /* offset */
);
/* Load symbols? */
di_handle = VG_(di_notify_mmap)( (Addr)sr_Res(sres),
False/*allow_SkFileV*/, (Int)arg5 );
/* Notify the tool. */
notify_tool_of_mmap(
(Addr)sr_Res(sres), /* addr kernel actually assigned */
arg2, /* length */
arg3, /* prot */
di_handle /* so the tool can refer to the read debuginfo later,
if it wants. */
);
}
/* Stay sane */
if (!sr_isError(sres) && (arg4 & VKI_MAP_FIXED))
vg_assert(sr_Res(sres) == arg1);
return sres;
}
/* ---------------------------------------------------------------------
The Main Entertainment ... syscall wrappers
------------------------------------------------------------------ */
/* Note: the PRE() and POST() wrappers are for the actual functions
implementing the system calls in the OS kernel. These mostly have
names like sys_write(); a few have names like old_mmap(). See the
comment for ML_(syscall_table)[] for important info about the __NR_foo
constants and their relationship to the sys_foo() functions.
Some notes about names used for syscalls and args:
- For the --trace-syscalls=yes output, we use the sys_foo() name to avoid
ambiguity.
- For error messages, we generally use a somewhat generic name
for the syscall (eg. "write" rather than "sys_write"). This should be
good enough for the average user to understand what is happening,
without confusing them with names like "sys_write".
- Also, for error messages the arg names are mostly taken from the man
pages (even though many of those man pages are really for glibc
functions of the same name), rather than from the OS kernel source,
for the same reason -- a user presented with a "bogus foo(bar)" arg
will most likely look at the "foo" man page to see which is the "bar"
arg.
Note that we use our own vki_* types. The one exception is in
PRE_REG_READn calls, where pointer types haven't been changed, because
they don't need to be -- eg. for "foo*" to be used, the type foo need not
be visible.
XXX: some of these are arch-specific, and should be factored out.
*/
#define PRE(name) DEFN_PRE_TEMPLATE(generic, name)
#define POST(name) DEFN_POST_TEMPLATE(generic, name)
// Macros to support 64-bit syscall args split into two 32 bit values
#if defined(VG_LITTLEENDIAN)
#define MERGE64(lo,hi) ( ((ULong)(lo)) | (((ULong)(hi)) << 32) )
#define MERGE64_FIRST(name) name##_low
#define MERGE64_SECOND(name) name##_high
#elif defined(VG_BIGENDIAN)
#define MERGE64(hi,lo) ( ((ULong)(lo)) | (((ULong)(hi)) << 32) )
#define MERGE64_FIRST(name) name##_high
#define MERGE64_SECOND(name) name##_low
#else
#error Unknown endianness
#endif
PRE(sys_exit)
{
ThreadState* tst;
/* simple; just make this thread exit */
PRINT("exit( %ld )", SARG1);
PRE_REG_READ1(void, "exit", int, status);
tst = VG_(get_ThreadState)(tid);
/* Set the thread's status to be exiting, then claim that the
syscall succeeded. */
tst->exitreason = VgSrc_ExitThread;
tst->os_state.exitcode = ARG1;
SET_STATUS_Success(0);
}
PRE(sys_ni_syscall)
{
PRINT("unimplemented (by the kernel) syscall: %s! (ni_syscall)\n",
VG_SYSNUM_STRING(SYSNO));
PRE_REG_READ0(long, "ni_syscall");
SET_STATUS_Failure( VKI_ENOSYS );
}
PRE(sys_iopl)
{
PRINT("sys_iopl ( %lu )", ARG1);
PRE_REG_READ1(long, "iopl", unsigned long, level);
}
PRE(sys_fsync)
{
*flags |= SfMayBlock;
PRINT("sys_fsync ( %lu )", ARG1);
PRE_REG_READ1(long, "fsync", unsigned int, fd);
}
PRE(sys_fdatasync)
{
*flags |= SfMayBlock;
PRINT("sys_fdatasync ( %lu )", ARG1);
PRE_REG_READ1(long, "fdatasync", unsigned int, fd);
}
PRE(sys_msync)
{
*flags |= SfMayBlock;
PRINT("sys_msync ( %#lx, %lu, %#lx )", ARG1, ARG2, ARG3);
PRE_REG_READ3(long, "msync",
unsigned long, start, vki_size_t, length, int, flags);
PRE_MEM_READ( "msync(start)", ARG1, ARG2 );
}
// Nb: getpmsg() and putpmsg() are special additional syscalls used in early
// versions of LiS (Linux Streams). They are not part of the kernel.
// Therefore, we have to provide this type ourself, rather than getting it
// from the kernel sources.
struct vki_pmsg_strbuf {
int maxlen; /* no. of bytes in buffer */
int len; /* no. of bytes returned */
vki_caddr_t buf; /* pointer to data */
};
PRE(sys_getpmsg)
{
/* LiS getpmsg from http://www.gcom.com/home/linux/lis/ */
struct vki_pmsg_strbuf *ctrl;
struct vki_pmsg_strbuf *data;
*flags |= SfMayBlock;
PRINT("sys_getpmsg ( %ld, %#lx, %#lx, %#lx, %#lx )", SARG1, ARG2, ARG3,
ARG4, ARG5);
PRE_REG_READ5(int, "getpmsg",
int, fd, struct strbuf *, ctrl, struct strbuf *, data,
int *, bandp, int *, flagsp);
ctrl = (struct vki_pmsg_strbuf *)ARG2;
data = (struct vki_pmsg_strbuf *)ARG3;
if (ctrl && ctrl->maxlen > 0)
PRE_MEM_WRITE( "getpmsg(ctrl)", (Addr)ctrl->buf, ctrl->maxlen);
if (data && data->maxlen > 0)
PRE_MEM_WRITE( "getpmsg(data)", (Addr)data->buf, data->maxlen);
if (ARG4)
PRE_MEM_WRITE( "getpmsg(bandp)", (Addr)ARG4, sizeof(int));
if (ARG5)
PRE_MEM_WRITE( "getpmsg(flagsp)", (Addr)ARG5, sizeof(int));
}
POST(sys_getpmsg)
{
struct vki_pmsg_strbuf *ctrl;
struct vki_pmsg_strbuf *data;
vg_assert(SUCCESS);
ctrl = (struct vki_pmsg_strbuf *)ARG2;
data = (struct vki_pmsg_strbuf *)ARG3;
if (RES == 0 && ctrl && ctrl->len > 0) {
POST_MEM_WRITE( (Addr)ctrl->buf, ctrl->len);
}
if (RES == 0 && data && data->len > 0) {
POST_MEM_WRITE( (Addr)data->buf, data->len);
}
}
PRE(sys_putpmsg)
{
/* LiS putpmsg from http://www.gcom.com/home/linux/lis/ */
struct vki_pmsg_strbuf *ctrl;
struct vki_pmsg_strbuf *data;
*flags |= SfMayBlock;
PRINT("sys_putpmsg ( %ld, %#lx, %#lx, %ld, %ld )", SARG1, ARG2, ARG3,
SARG4, SARG5);
PRE_REG_READ5(int, "putpmsg",
int, fd, struct strbuf *, ctrl, struct strbuf *, data,
int, band, int, flags);
ctrl = (struct vki_pmsg_strbuf *)ARG2;
data = (struct vki_pmsg_strbuf *)ARG3;
if (ctrl && ctrl->len > 0)
PRE_MEM_READ( "putpmsg(ctrl)", (Addr)ctrl->buf, ctrl->len);
if (data && data->len > 0)
PRE_MEM_READ( "putpmsg(data)", (Addr)data->buf, data->len);
}
PRE(sys_getitimer)
{
struct vki_itimerval *value = (struct vki_itimerval*)ARG2;
PRINT("sys_getitimer ( %ld, %#lx )", SARG1, ARG2);
PRE_REG_READ2(long, "getitimer", int, which, struct itimerval *, value);
PRE_timeval_WRITE( "getitimer(&value->it_interval)", &(value->it_interval));
PRE_timeval_WRITE( "getitimer(&value->it_value)", &(value->it_value));
}
POST(sys_getitimer)
{
if (ARG2 != (Addr)NULL) {
struct vki_itimerval *value = (struct vki_itimerval*)ARG2;
POST_timeval_WRITE( &(value->it_interval) );
POST_timeval_WRITE( &(value->it_value) );
}
}
PRE(sys_setitimer)
{
PRINT("sys_setitimer ( %ld, %#lx, %#lx )", SARG1, ARG2, ARG3);
PRE_REG_READ3(long, "setitimer",
int, which,
struct itimerval *, value, struct itimerval *, ovalue);
if (ARG2 != (Addr)NULL) {
struct vki_itimerval *value = (struct vki_itimerval*)ARG2;
PRE_timeval_READ( "setitimer(&value->it_interval)",
&(value->it_interval));
PRE_timeval_READ( "setitimer(&value->it_value)",
&(value->it_value));
}
if (ARG3 != (Addr)NULL) {
struct vki_itimerval *ovalue = (struct vki_itimerval*)ARG3;
PRE_timeval_WRITE( "setitimer(&ovalue->it_interval)",
&(ovalue->it_interval));
PRE_timeval_WRITE( "setitimer(&ovalue->it_value)",
&(ovalue->it_value));
}
}
POST(sys_setitimer)
{
if (ARG3 != (Addr)NULL) {
struct vki_itimerval *ovalue = (struct vki_itimerval*)ARG3;
POST_timeval_WRITE( &(ovalue->it_interval) );
POST_timeval_WRITE( &(ovalue->it_value) );
}
}
PRE(sys_chroot)
{
PRINT("sys_chroot ( %#lx )", ARG1);
PRE_REG_READ1(long, "chroot", const char *, path);
PRE_MEM_RASCIIZ( "chroot(path)", ARG1 );
}
PRE(sys_madvise)
{
*flags |= SfMayBlock;
PRINT("sys_madvise ( %#lx, %lu, %ld )", ARG1, ARG2, SARG3);
PRE_REG_READ3(long, "madvise",
unsigned long, start, vki_size_t, length, int, advice);
}
#if HAVE_MREMAP
PRE(sys_mremap)
{
// Nb: this is different to the glibc version described in the man pages,
// which lacks the fifth 'new_address' argument.
if (ARG4 & VKI_MREMAP_FIXED) {
PRINT("sys_mremap ( %#lx, %lu, %lu, %#lx, %#lx )",
ARG1, ARG2, ARG3, ARG4, ARG5);
PRE_REG_READ5(unsigned long, "mremap",
unsigned long, old_addr, unsigned long, old_size,
unsigned long, new_size, unsigned long, flags,
unsigned long, new_addr);
} else {
PRINT("sys_mremap ( %#lx, %lu, %lu, 0x%lx )",
ARG1, ARG2, ARG3, ARG4);
PRE_REG_READ4(unsigned long, "mremap",
unsigned long, old_addr, unsigned long, old_size,
unsigned long, new_size, unsigned long, flags);
}
SET_STATUS_from_SysRes(
do_mremap((Addr)ARG1, ARG2, (Addr)ARG5, ARG3, ARG4, tid)
);
}
#endif /* HAVE_MREMAP */
PRE(sys_nice)
{
PRINT("sys_nice ( %ld )", SARG1);
PRE_REG_READ1(long, "nice", int, inc);
}
PRE(sys_mlock)
{
*flags |= SfMayBlock;
PRINT("sys_mlock ( %#lx, %lu )", ARG1, ARG2);
PRE_REG_READ2(long, "mlock", unsigned long, addr, vki_size_t, len);
}
PRE(sys_munlock)
{
*flags |= SfMayBlock;
PRINT("sys_munlock ( %#lx, %lu )", ARG1, ARG2);
PRE_REG_READ2(long, "munlock", unsigned long, addr, vki_size_t, len);
}
PRE(sys_mlockall)
{
*flags |= SfMayBlock;
PRINT("sys_mlockall ( %lx )", ARG1);
PRE_REG_READ1(long, "mlockall", int, flags);
}
PRE(sys_setpriority)
{
PRINT("sys_setpriority ( %ld, %ld, %ld )", SARG1, SARG2, SARG3);
PRE_REG_READ3(long, "setpriority", int, which, int, who, int, prio);
}
PRE(sys_getpriority)
{
PRINT("sys_getpriority ( %ld, %ld )", SARG1, SARG2);
PRE_REG_READ2(long, "getpriority", int, which, int, who);
}
PRE(sys_pwrite64)
{
*flags |= SfMayBlock;
#if VG_WORDSIZE == 4
PRINT("sys_pwrite64 ( %lu, %#lx, %lu, %lld )",
ARG1, ARG2, ARG3, (Long)MERGE64(ARG4,ARG5));
PRE_REG_READ5(ssize_t, "pwrite64",
unsigned int, fd, const char *, buf, vki_size_t, count,
vki_u32, MERGE64_FIRST(offset), vki_u32, MERGE64_SECOND(offset));
#elif VG_WORDSIZE == 8
PRINT("sys_pwrite64 ( %lu, %#lx, %lu, %ld )",
ARG1, ARG2, ARG3, SARG4);
PRE_REG_READ4(ssize_t, "pwrite64",
unsigned int, fd, const char *, buf, vki_size_t, count,
Word, offset);
#else
# error Unexpected word size
#endif
PRE_MEM_READ( "pwrite64(buf)", ARG2, ARG3 );
}
PRE(sys_sync)
{
*flags |= SfMayBlock;
PRINT("sys_sync ( )");
PRE_REG_READ0(long, "sync");
}
PRE(sys_fstatfs)
{
FUSE_COMPATIBLE_MAY_BLOCK();
PRINT("sys_fstatfs ( %lu, %#lx )", ARG1, ARG2);
PRE_REG_READ2(long, "fstatfs",
unsigned int, fd, struct statfs *, buf);
PRE_MEM_WRITE( "fstatfs(buf)", ARG2, sizeof(struct vki_statfs) );
}
POST(sys_fstatfs)
{
POST_MEM_WRITE( ARG2, sizeof(struct vki_statfs) );
}
PRE(sys_fstatfs64)
{
FUSE_COMPATIBLE_MAY_BLOCK();
PRINT("sys_fstatfs64 ( %lu, %lu, %#lx )", ARG1, ARG2, ARG3);
PRE_REG_READ3(long, "fstatfs64",
unsigned int, fd, vki_size_t, size, struct statfs64 *, buf);
PRE_MEM_WRITE( "fstatfs64(buf)", ARG3, ARG2 );
}
POST(sys_fstatfs64)
{
POST_MEM_WRITE( ARG3, ARG2 );
}
PRE(sys_getsid)
{
PRINT("sys_getsid ( %ld )", SARG1);
PRE_REG_READ1(long, "getsid", vki_pid_t, pid);
}
PRE(sys_pread64)
{
*flags |= SfMayBlock;
#if VG_WORDSIZE == 4
PRINT("sys_pread64 ( %lu, %#lx, %lu, %lld )",
ARG1, ARG2, ARG3, (Long)MERGE64(ARG4,ARG5));
PRE_REG_READ5(ssize_t, "pread64",
unsigned int, fd, char *, buf, vki_size_t, count,
vki_u32, MERGE64_FIRST(offset), vki_u32, MERGE64_SECOND(offset));
#elif VG_WORDSIZE == 8
PRINT("sys_pread64 ( %lu, %#lx, %lu, %ld )",
ARG1, ARG2, ARG3, SARG4);
PRE_REG_READ4(ssize_t, "pread64",
unsigned int, fd, char *, buf, vki_size_t, count,
Word, offset);
#else
# error Unexpected word size
#endif
PRE_MEM_WRITE( "pread64(buf)", ARG2, ARG3 );
}
POST(sys_pread64)
{
vg_assert(SUCCESS);
if (RES > 0) {
POST_MEM_WRITE( ARG2, RES );
}
}
PRE(sys_mknod)
{
FUSE_COMPATIBLE_MAY_BLOCK();
PRINT("sys_mknod ( %#lx(%s), %#lx, %#lx )", ARG1, (HChar*)ARG1, ARG2, ARG3 );
PRE_REG_READ3(long, "mknod",
const char *, pathname, int, mode, unsigned, dev);
PRE_MEM_RASCIIZ( "mknod(pathname)", ARG1 );
}
PRE(sys_flock)
{
*flags |= SfMayBlock;
PRINT("sys_flock ( %lu, %lu )", ARG1, ARG2 );
PRE_REG_READ2(long, "flock", unsigned int, fd, unsigned int, operation);
}
// Pre_read a char** argument.
void ML_(pre_argv_envp)(Addr a, ThreadId tid, const HChar *s1, const HChar *s2)
{
while (True) {
Addr a_deref;
Addr* a_p = (Addr*)a;
PRE_MEM_READ( s1, (Addr)a_p, sizeof(Addr) );
a_deref = *a_p;
if (0 == a_deref)
break;
PRE_MEM_RASCIIZ( s2, a_deref );
a += sizeof(char*);
}
}
static Bool i_am_the_only_thread ( void )
{
Int c = VG_(count_living_threads)();
vg_assert(c >= 1); /* stay sane */
return c == 1;
}
/* Wait until all other threads disappear. */
void VG_(reap_threads)(ThreadId self)
{
while (!i_am_the_only_thread()) {
/* Let other thread(s) run */
VG_(vg_yield)();
VG_(poll_signals)(self);
}
vg_assert(i_am_the_only_thread());
}
// XXX: prototype here seemingly doesn't match the prototype for i386-linux,
// but it seems to work nonetheless...
PRE(sys_execve)
{
HChar* path = NULL; /* path to executable */
HChar** envp = NULL;
HChar** argv = NULL;
HChar** arg2copy;
HChar* launcher_basename = NULL;
ThreadState* tst;
Int i, j, tot_args;
SysRes res;
Bool setuid_allowed, trace_this_child;
PRINT("sys_execve ( %#lx(%s), %#lx, %#lx )", ARG1, (char*)ARG1, ARG2, ARG3);
PRE_REG_READ3(vki_off_t, "execve",
char *, filename, char **, argv, char **, envp);
PRE_MEM_RASCIIZ( "execve(filename)", ARG1 );
if (ARG2 != 0)
ML_(pre_argv_envp)( ARG2, tid, "execve(argv)", "execve(argv[i])" );
if (ARG3 != 0)
ML_(pre_argv_envp)( ARG3, tid, "execve(envp)", "execve(envp[i])" );
vg_assert(VG_(is_valid_tid)(tid));
tst = VG_(get_ThreadState)(tid);
/* Erk. If the exec fails, then the following will have made a
mess of things which makes it hard for us to continue. The
right thing to do is piece everything together again in
POST(execve), but that's close to impossible. Instead, we make
an effort to check that the execve will work before actually
doing it. */
/* Check that the name at least begins in client-accessible storage. */
if (ARG1 == 0 /* obviously bogus */
|| !VG_(am_is_valid_for_client)( ARG1, 1, VKI_PROT_READ )) {
SET_STATUS_Failure( VKI_EFAULT );
return;
}
// debug-only printing
if (0) {
VG_(printf)("ARG1 = %p(%s)\n", (void*)ARG1, (HChar*)ARG1);
if (ARG2) {
VG_(printf)("ARG2 = ");
Int q;
HChar** vec = (HChar**)ARG2;
for (q = 0; vec[q]; q++)
VG_(printf)("%p(%s) ", vec[q], vec[q]);
VG_(printf)("\n");
} else {
VG_(printf)("ARG2 = null\n");
}
}
// Decide whether or not we want to follow along
{ // Make 'child_argv' be a pointer to the child's arg vector
// (skipping the exe name)
const HChar** child_argv = (const HChar**)ARG2;
if (child_argv && child_argv[0] == NULL)
child_argv = NULL;
trace_this_child = VG_(should_we_trace_this_child)( (HChar*)ARG1, child_argv );
}
// Do the important checks: it is a file, is executable, permissions are
// ok, etc. We allow setuid executables to run only in the case when
// we are not simulating them, that is, they to be run natively.
setuid_allowed = trace_this_child ? False : True;
res = VG_(pre_exec_check)((const HChar *)ARG1, NULL, setuid_allowed);
if (sr_isError(res)) {
SET_STATUS_Failure( sr_Err(res) );
return;
}
/* If we're tracing the child, and the launcher name looks bogus
(possibly because launcher.c couldn't figure it out, see
comments therein) then we have no option but to fail. */
if (trace_this_child
&& (VG_(name_of_launcher) == NULL
|| VG_(name_of_launcher)[0] != '/')) {
SET_STATUS_Failure( VKI_ECHILD ); /* "No child processes" */
return;
}
/* After this point, we can't recover if the execve fails. */
VG_(debugLog)(1, "syswrap", "Exec of %s\n", (HChar*)ARG1);
// Terminate gdbserver if it is active.
if (VG_(clo_vgdb) != Vg_VgdbNo) {
// If the child will not be traced, we need to terminate gdbserver
// to cleanup the gdbserver resources (e.g. the FIFO files).
// If child will be traced, we also terminate gdbserver: the new
// Valgrind will start a fresh gdbserver after exec.
VG_(gdbserver) (0);
}
/* Resistance is futile. Nuke all other threads. POSIX mandates
this. (Really, nuke them all, since the new process will make
its own new thread.) */
VG_(nuke_all_threads_except)( tid, VgSrc_ExitThread );
VG_(reap_threads)(tid);
// Set up the child's exe path.
//
if (trace_this_child) {
// We want to exec the launcher. Get its pre-remembered path.
path = VG_(name_of_launcher);
// VG_(name_of_launcher) should have been acquired by m_main at
// startup.
vg_assert(path);
launcher_basename = VG_(strrchr)(path, '/');
if (launcher_basename == NULL || launcher_basename[1] == 0) {
launcher_basename = path; // hmm, tres dubious
} else {
launcher_basename++;
}
} else {
path = (HChar*)ARG1;
}
// Set up the child's environment.
//
// Remove the valgrind-specific stuff from the environment so the
// child doesn't get vgpreload_core.so, vgpreload_<tool>.so, etc.
// This is done unconditionally, since if we are tracing the child,
// the child valgrind will set up the appropriate client environment.
// Nb: we make a copy of the environment before trying to mangle it
// as it might be in read-only memory (this was bug #101881).
//
// Then, if tracing the child, set VALGRIND_LIB for it.
//
if (ARG3 == 0) {
envp = NULL;
} else {
envp = VG_(env_clone)( (HChar**)ARG3 );
if (envp == NULL) goto hosed;
VG_(env_remove_valgrind_env_stuff)( envp, True /*ro_strings*/, NULL );
}
if (trace_this_child) {
// Set VALGRIND_LIB in ARG3 (the environment)
VG_(env_setenv)( &envp, VALGRIND_LIB, VG_(libdir));
}
// Set up the child's args. If not tracing it, they are
// simply ARG2. Otherwise, they are
//
// [launcher_basename] ++ VG_(args_for_valgrind) ++ [ARG1] ++ ARG2[1..]
//
// except that the first VG_(args_for_valgrind_noexecpass) args
// are omitted.
//
if (!trace_this_child) {
argv = (HChar**)ARG2;
} else {
vg_assert( VG_(args_for_valgrind) );
vg_assert( VG_(args_for_valgrind_noexecpass) >= 0 );
vg_assert( VG_(args_for_valgrind_noexecpass)
<= VG_(sizeXA)( VG_(args_for_valgrind) ) );
/* how many args in total will there be? */
// launcher basename
tot_args = 1;
// V's args
tot_args += VG_(sizeXA)( VG_(args_for_valgrind) );
tot_args -= VG_(args_for_valgrind_noexecpass);
// name of client exe
tot_args++;
// args for client exe, skipping [0]
arg2copy = (HChar**)ARG2;
if (arg2copy && arg2copy[0]) {
for (i = 1; arg2copy[i]; i++)
tot_args++;
}
// allocate
argv = VG_(malloc)( "di.syswrap.pre_sys_execve.1",
(tot_args+1) * sizeof(HChar*) );
// copy
j = 0;
argv[j++] = launcher_basename;
for (i = 0; i < VG_(sizeXA)( VG_(args_for_valgrind) ); i++) {
if (i < VG_(args_for_valgrind_noexecpass))
continue;
argv[j++] = * (HChar**) VG_(indexXA)( VG_(args_for_valgrind), i );
}
argv[j++] = (HChar*)ARG1;
if (arg2copy && arg2copy[0])
for (i = 1; arg2copy[i]; i++)
argv[j++] = arg2copy[i];
argv[j++] = NULL;
// check
vg_assert(j == tot_args+1);
}
/*
Set the signal state up for exec.
We need to set the real signal state to make sure the exec'd
process gets SIG_IGN properly.
Also set our real sigmask to match the client's sigmask so that
the exec'd child will get the right mask. First we need to
clear out any pending signals so they they don't get delivered,
which would confuse things.
XXX This is a bug - the signals should remain pending, and be
delivered to the new process after exec. There's also a
race-condition, since if someone delivers us a signal between
the sigprocmask and the execve, we'll still get the signal. Oh
well.
*/
{
vki_sigset_t allsigs;
vki_siginfo_t info;
/* What this loop does: it queries SCSS (the signal state that
the client _thinks_ the kernel is in) by calling
VG_(do_sys_sigaction), and modifies the real kernel signal
state accordingly. */
for (i = 1; i < VG_(max_signal); i++) {
vki_sigaction_fromK_t sa_f;
vki_sigaction_toK_t sa_t;
VG_(do_sys_sigaction)(i, NULL, &sa_f);
VG_(convert_sigaction_fromK_to_toK)(&sa_f, &sa_t);
if (sa_t.ksa_handler == VKI_SIG_IGN)
VG_(sigaction)(i, &sa_t, NULL);
else {
sa_t.ksa_handler = VKI_SIG_DFL;
VG_(sigaction)(i, &sa_t, NULL);
}
}
VG_(sigfillset)(&allsigs);
while(VG_(sigtimedwait_zero)(&allsigs, &info) > 0)
;
VG_(sigprocmask)(VKI_SIG_SETMASK, &tst->sig_mask, NULL);
}
if (0) {
HChar **cpp;
VG_(printf)("exec: %s\n", path);
for (cpp = argv; cpp && *cpp; cpp++)
VG_(printf)("argv: %s\n", *cpp);
if (0)
for (cpp = envp; cpp && *cpp; cpp++)
VG_(printf)("env: %s\n", *cpp);
}
SET_STATUS_from_SysRes(
VG_(do_syscall3)(__NR_execve, (UWord)path, (UWord)argv, (UWord)envp)
);
/* If we got here, then the execve failed. We've already made way
too much of a mess to continue, so we have to abort. */
hosed:
vg_assert(FAILURE);
VG_(message)(Vg_UserMsg, "execve(%#lx(%s), %#lx, %#lx) failed, errno %lu\n",
ARG1, (HChar*)ARG1, ARG2, ARG3, ERR);
VG_(message)(Vg_UserMsg, "EXEC FAILED: I can't recover from "
"execve() failing, so I'm dying.\n");
VG_(message)(Vg_UserMsg, "Add more stringent tests in PRE(sys_execve), "
"or work out how to recover.\n");
VG_(exit)(101);
}
PRE(sys_access)
{
PRINT("sys_access ( %#lx(%s), %ld )", ARG1, (HChar*)ARG1, SARG2);
PRE_REG_READ2(long, "access", const char *, pathname, int, mode);
PRE_MEM_RASCIIZ( "access(pathname)", ARG1 );
}
PRE(sys_alarm)
{
PRINT("sys_alarm ( %lu )", ARG1);
PRE_REG_READ1(unsigned long, "alarm", unsigned int, seconds);
}
PRE(sys_brk)
{
Addr brk_limit = VG_(brk_limit);
Addr brk_new;
/* libc says: int brk(void *end_data_segment);
kernel says: void* brk(void* end_data_segment); (more or less)
libc returns 0 on success, and -1 (and sets errno) on failure.
Nb: if you ask to shrink the dataseg end below what it
currently is, that always succeeds, even if the dataseg end
doesn't actually change (eg. brk(0)). Unless it seg faults.
Kernel returns the new dataseg end. If the brk() failed, this
will be unchanged from the old one. That's why calling (kernel)
brk(0) gives the current dataseg end (libc brk() just returns
zero in that case).
Both will seg fault if you shrink it back into a text segment.
*/
PRINT("sys_brk ( %#lx )", ARG1);
PRE_REG_READ1(unsigned long, "brk", unsigned long, end_data_segment);
brk_new = do_brk(ARG1, tid);
SET_STATUS_Success( brk_new );
if (brk_new == ARG1) {
/* brk() succeeded */
if (brk_new < brk_limit) {
/* successfully shrunk the data segment. */
VG_TRACK( die_mem_brk, (Addr)ARG1,
brk_limit-ARG1 );
} else
if (brk_new > brk_limit) {
/* successfully grew the data segment */
VG_TRACK( new_mem_brk, brk_limit,
ARG1-brk_limit, tid );
}
} else {
/* brk() failed */
vg_assert(brk_limit == brk_new);
}
}
PRE(sys_chdir)
{
FUSE_COMPATIBLE_MAY_BLOCK();
PRINT("sys_chdir ( %#lx(%s) )", ARG1,(char*)ARG1);
PRE_REG_READ1(long, "chdir", const char *, path);
PRE_MEM_RASCIIZ( "chdir(path)", ARG1 );
}
PRE(sys_chmod)
{
FUSE_COMPATIBLE_MAY_BLOCK();
PRINT("sys_chmod ( %#lx(%s), %lu )", ARG1, (HChar*)ARG1, ARG2);
PRE_REG_READ2(long, "chmod", const char *, path, vki_mode_t, mode);
PRE_MEM_RASCIIZ( "chmod(path)", ARG1 );
}
PRE(sys_chown)
{
FUSE_COMPATIBLE_MAY_BLOCK();
PRINT("sys_chown ( %#lx(%s), 0x%lx, 0x%lx )", ARG1,(char*)ARG1,ARG2,ARG3);
PRE_REG_READ3(long, "chown",
const char *, path, vki_uid_t, owner, vki_gid_t, group);
PRE_MEM_RASCIIZ( "chown(path)", ARG1 );
}
PRE(sys_lchown)
{
FUSE_COMPATIBLE_MAY_BLOCK();
PRINT("sys_lchown ( %#lx(%s), 0x%lx, 0x%lx )", ARG1,(char*)ARG1,ARG2,ARG3);
PRE_REG_READ3(long, "lchown",
const char *, path, vki_uid_t, owner, vki_gid_t, group);
PRE_MEM_RASCIIZ( "lchown(path)", ARG1 );
}
PRE(sys_close)
{
FUSE_COMPATIBLE_MAY_BLOCK();
PRINT("sys_close ( %lu )", ARG1);
PRE_REG_READ1(long, "close", unsigned int, fd);
/* Detect and negate attempts by the client to close Valgrind's log fd */
if ( (!ML_(fd_allowed)(ARG1, "close", tid, False))
/* If doing -d style logging (which is to fd=2), don't
allow that to be closed either. */
|| (ARG1 == 2/*stderr*/ && VG_(debugLog_getLevel)() > 0) )
SET_STATUS_Failure( VKI_EBADF );
}
POST(sys_close)
{
if (VG_(clo_track_fds)) ML_(record_fd_close)(ARG1);
}
PRE(sys_dup)
{
PRINT("sys_dup ( %lu )", ARG1);
PRE_REG_READ1(long, "dup", unsigned int, oldfd);
}
POST(sys_dup)
{
vg_assert(SUCCESS);
if (!ML_(fd_allowed)(RES, "dup", tid, True)) {
VG_(close)(RES);
SET_STATUS_Failure( VKI_EMFILE );
} else {
if (VG_(clo_track_fds))
ML_(record_fd_open_named)(tid, RES);
}
}
PRE(sys_dup2)
{
PRINT("sys_dup2 ( %lu, %lu )", ARG1, ARG2);
PRE_REG_READ2(long, "dup2", unsigned int, oldfd, unsigned int, newfd);
if (!ML_(fd_allowed)(ARG2, "dup2", tid, True))
SET_STATUS_Failure( VKI_EBADF );
}
POST(sys_dup2)
{
vg_assert(SUCCESS);
if (VG_(clo_track_fds))
ML_(record_fd_open_named)(tid, RES);
}
PRE(sys_fchdir)
{
FUSE_COMPATIBLE_MAY_BLOCK();
PRINT("sys_fchdir ( %lu )", ARG1);
PRE_REG_READ1(long, "fchdir", unsigned int, fd);
}
PRE(sys_fchown)
{
FUSE_COMPATIBLE_MAY_BLOCK();
PRINT("sys_fchown ( %lu, %lu, %lu )", ARG1, ARG2, ARG3);
PRE_REG_READ3(long, "fchown",
unsigned int, fd, vki_uid_t, owner, vki_gid_t, group);
}
PRE(sys_fchmod)
{
FUSE_COMPATIBLE_MAY_BLOCK();
PRINT("sys_fchmod ( %lu, %lu )", ARG1, ARG2);
PRE_REG_READ2(long, "fchmod", unsigned int, fildes, vki_mode_t, mode);
}
PRE(sys_newfstat)
{
FUSE_COMPATIBLE_MAY_BLOCK();
PRINT("sys_newfstat ( %lu, %#lx )", ARG1, ARG2);
PRE_REG_READ2(long, "fstat", unsigned int, fd, struct stat *, buf);
PRE_MEM_WRITE( "fstat(buf)", ARG2, sizeof(struct vki_stat) );
}
POST(sys_newfstat)
{
POST_MEM_WRITE( ARG2, sizeof(struct vki_stat) );
}
#if !defined(VGO_solaris) && !defined(VGP_arm64_linux)
static vki_sigset_t fork_saved_mask;
// In Linux, the sys_fork() function varies across architectures, but we
// ignore the various args it gets, and so it looks arch-neutral. Hmm.
PRE(sys_fork)
{
Bool is_child;
Int child_pid;
vki_sigset_t mask;
PRINT("sys_fork ( )");
PRE_REG_READ0(long, "fork");
/* Block all signals during fork, so that we can fix things up in
the child without being interrupted. */
VG_(sigfillset)(&mask);
VG_(sigprocmask)(VKI_SIG_SETMASK, &mask, &fork_saved_mask);
VG_(do_atfork_pre)(tid);
SET_STATUS_from_SysRes( VG_(do_syscall0)(__NR_fork) );
if (!SUCCESS) return;
#if defined(VGO_linux)
// RES is 0 for child, non-0 (the child's PID) for parent.
is_child = ( RES == 0 ? True : False );
child_pid = ( is_child ? -1 : RES );
#elif defined(VGO_darwin)
// RES is the child's pid. RESHI is 1 for child, 0 for parent.
is_child = RESHI;
child_pid = RES;
#else
# error Unknown OS
#endif
if (is_child) {
VG_(do_atfork_child)(tid);
/* restore signal mask */
VG_(sigprocmask)(VKI_SIG_SETMASK, &fork_saved_mask, NULL);
/* If --child-silent-after-fork=yes was specified, set the
output file descriptors to 'impossible' values. This is
noticed by send_bytes_to_logging_sink in m_libcprint.c, which
duly stops writing any further output. */
if (VG_(clo_child_silent_after_fork)) {
if (!VG_(log_output_sink).is_socket)
VG_(log_output_sink).fd = -1;
if (!VG_(xml_output_sink).is_socket)
VG_(xml_output_sink).fd = -1;
}
} else {
VG_(do_atfork_parent)(tid);
PRINT(" fork: process %d created child %d\n", VG_(getpid)(), child_pid);
/* restore signal mask */
VG_(sigprocmask)(VKI_SIG_SETMASK, &fork_saved_mask, NULL);
}
}
#endif // !defined(VGO_solaris) && !defined(VGP_arm64_linux)
PRE(sys_ftruncate)
{
*flags |= SfMayBlock;
PRINT("sys_ftruncate ( %lu, %lu )", ARG1, ARG2);
PRE_REG_READ2(long, "ftruncate", unsigned int, fd, unsigned long, length);
}
PRE(sys_truncate)
{
*flags |= SfMayBlock;
PRINT("sys_truncate ( %#lx(%s), %lu )", ARG1, (HChar*)ARG1, ARG2);
PRE_REG_READ2(long, "truncate",
const char *, path, unsigned long, length);
PRE_MEM_RASCIIZ( "truncate(path)", ARG1 );
}
PRE(sys_ftruncate64)
{
*flags |= SfMayBlock;
#if VG_WORDSIZE == 4
PRINT("sys_ftruncate64 ( %lu, %llu )", ARG1, MERGE64(ARG2,ARG3));
PRE_REG_READ3(long, "ftruncate64",
unsigned int, fd,
UWord, MERGE64_FIRST(length), UWord, MERGE64_SECOND(length));
#else
PRINT("sys_ftruncate64 ( %lu, %lu )", ARG1, ARG2);
PRE_REG_READ2(long, "ftruncate64",
unsigned int,fd, UWord,length);
#endif
}
PRE(sys_truncate64)
{
*flags |= SfMayBlock;
#if VG_WORDSIZE == 4
PRINT("sys_truncate64 ( %#lx, %lld )", ARG1, (Long)MERGE64(ARG2, ARG3));
PRE_REG_READ3(long, "truncate64",
const char *, path,
UWord, MERGE64_FIRST(length), UWord, MERGE64_SECOND(length));
#else
PRINT("sys_truncate64 ( %#lx, %lld )", ARG1, (Long)ARG2);
PRE_REG_READ2(long, "truncate64",
const char *,path, UWord,length);
#endif
PRE_MEM_RASCIIZ( "truncate64(path)", ARG1 );
}
PRE(sys_getdents)
{
*flags |= SfMayBlock;
PRINT("sys_getdents ( %lu, %#lx, %lu )", ARG1, ARG2, ARG3);
PRE_REG_READ3(long, "getdents",
unsigned int, fd, struct vki_dirent *, dirp,
unsigned int, count);
PRE_MEM_WRITE( "getdents(dirp)", ARG2, ARG3 );
}
POST(sys_getdents)
{
vg_assert(SUCCESS);
if (RES > 0)
POST_MEM_WRITE( ARG2, RES );
}
PRE(sys_getdents64)
{
*flags |= SfMayBlock;
PRINT("sys_getdents64 ( %lu, %#lx, %lu )",ARG1, ARG2, ARG3);
PRE_REG_READ3(long, "getdents64",
unsigned int, fd, struct vki_dirent64 *, dirp,
unsigned int, count);
PRE_MEM_WRITE( "getdents64(dirp)", ARG2, ARG3 );
}
POST(sys_getdents64)
{
vg_assert(SUCCESS);
if (RES > 0)
POST_MEM_WRITE( ARG2, RES );
}
PRE(sys_getgroups)
{
PRINT("sys_getgroups ( %ld, %#lx )", SARG1, ARG2);
PRE_REG_READ2(long, "getgroups", int, size, vki_gid_t *, list);
if (ARG1 > 0)
PRE_MEM_WRITE( "getgroups(list)", ARG2, ARG1 * sizeof(vki_gid_t) );
}
POST(sys_getgroups)
{
vg_assert(SUCCESS);
if (ARG1 > 0 && RES > 0)
POST_MEM_WRITE( ARG2, RES * sizeof(vki_gid_t) );
}
PRE(sys_getcwd)
{
// Comment from linux/fs/dcache.c:
// NOTE! The user-level library version returns a character pointer.
// The kernel system call just returns the length of the buffer filled
// (which includes the ending '\0' character), or a negative error
// value.
// Is this Linux-specific? If so it should be moved to syswrap-linux.c.
PRINT("sys_getcwd ( %#lx, %llu )", ARG1,(ULong)ARG2);
PRE_REG_READ2(long, "getcwd", char *, buf, unsigned long, size);
PRE_MEM_WRITE( "getcwd(buf)", ARG1, ARG2 );
}
POST(sys_getcwd)
{
vg_assert(SUCCESS);
if (RES != (Addr)NULL)
POST_MEM_WRITE( ARG1, RES );
}
PRE(sys_geteuid)
{
PRINT("sys_geteuid ( )");
PRE_REG_READ0(long, "geteuid");
}
PRE(sys_getegid)
{
PRINT("sys_getegid ( )");
PRE_REG_READ0(long, "getegid");
}
PRE(sys_getgid)
{
PRINT("sys_getgid ( )");
PRE_REG_READ0(long, "getgid");
}
PRE(sys_getpid)
{
PRINT("sys_getpid ()");
PRE_REG_READ0(long, "getpid");
}
PRE(sys_getpgid)
{
PRINT("sys_getpgid ( %ld )", SARG1);
PRE_REG_READ1(long, "getpgid", vki_pid_t, pid);
}
PRE(sys_getpgrp)
{
PRINT("sys_getpgrp ()");
PRE_REG_READ0(long, "getpgrp");
}
PRE(sys_getppid)
{
PRINT("sys_getppid ()");
PRE_REG_READ0(long, "getppid");
}
static void common_post_getrlimit(ThreadId tid, UWord a1, UWord a2)
{
POST_MEM_WRITE( a2, sizeof(struct vki_rlimit) );
#ifdef _RLIMIT_POSIX_FLAG
// Darwin will sometimes set _RLIMIT_POSIX_FLAG on getrlimit calls.
// Unset it here to make the switch case below work correctly.
a1 &= ~_RLIMIT_POSIX_FLAG;
#endif
switch (a1) {
case VKI_RLIMIT_NOFILE:
((struct vki_rlimit *)a2)->rlim_cur = VG_(fd_soft_limit);
((struct vki_rlimit *)a2)->rlim_max = VG_(fd_hard_limit);
break;
case VKI_RLIMIT_DATA:
*((struct vki_rlimit *)a2) = VG_(client_rlimit_data);
break;
case VKI_RLIMIT_STACK:
*((struct vki_rlimit *)a2) = VG_(client_rlimit_stack);
break;
}
}
PRE(sys_old_getrlimit)
{
PRINT("sys_old_getrlimit ( %lu, %#lx )", ARG1, ARG2);
PRE_REG_READ2(long, "old_getrlimit",
unsigned int, resource, struct rlimit *, rlim);
PRE_MEM_WRITE( "old_getrlimit(rlim)", ARG2, sizeof(struct vki_rlimit) );
}
POST(sys_old_getrlimit)
{
common_post_getrlimit(tid, ARG1, ARG2);
}
PRE(sys_getrlimit)
{
PRINT("sys_getrlimit ( %lu, %#lx )", ARG1, ARG2);
PRE_REG_READ2(long, "getrlimit",
unsigned int, resource, struct rlimit *, rlim);
PRE_MEM_WRITE( "getrlimit(rlim)", ARG2, sizeof(struct vki_rlimit) );
}
POST(sys_getrlimit)
{
common_post_getrlimit(tid, ARG1, ARG2);
}
PRE(sys_getrusage)
{
PRINT("sys_getrusage ( %ld, %#lx )", SARG1, ARG2);
PRE_REG_READ2(long, "getrusage", int, who, struct rusage *, usage);
PRE_MEM_WRITE( "getrusage(usage)", ARG2, sizeof(struct vki_rusage) );
}
POST(sys_getrusage)
{
vg_assert(SUCCESS);
if (RES == 0)
POST_MEM_WRITE( ARG2, sizeof(struct vki_rusage) );
}
PRE(sys_gettimeofday)
{
PRINT("sys_gettimeofday ( %#lx, %#lx )", ARG1,ARG2);
PRE_REG_READ2(long, "gettimeofday",
struct timeval *, tv, struct timezone *, tz);
// GrP fixme does darwin write to *tz anymore?
if (ARG1 != 0)
PRE_timeval_WRITE( "gettimeofday(tv)", ARG1 );
if (ARG2 != 0)
PRE_MEM_WRITE( "gettimeofday(tz)", ARG2, sizeof(struct vki_timezone) );
}
POST(sys_gettimeofday)
{
vg_assert(SUCCESS);
if (RES == 0) {
if (ARG1 != 0)
POST_timeval_WRITE( ARG1 );
if (ARG2 != 0)
POST_MEM_WRITE( ARG2, sizeof(struct vki_timezone) );
}
}
PRE(sys_settimeofday)
{
PRINT("sys_settimeofday ( %#lx, %#lx )", ARG1,ARG2);
PRE_REG_READ2(long, "settimeofday",
struct timeval *, tv, struct timezone *, tz);
if (ARG1 != 0)
PRE_timeval_READ( "settimeofday(tv)", ARG1 );
if (ARG2 != 0) {
PRE_MEM_READ( "settimeofday(tz)", ARG2, sizeof(struct vki_timezone) );
/* maybe should warn if tz->tz_dsttime is non-zero? */
}
}
PRE(sys_getuid)
{
PRINT("sys_getuid ( )");
PRE_REG_READ0(long, "getuid");
}
void ML_(PRE_unknown_ioctl)(ThreadId tid, UWord request, UWord arg)
{
/* We don't have any specific information on it, so
try to do something reasonable based on direction and
size bits. The encoding scheme is described in
/usr/include/asm/ioctl.h or /usr/include/sys/ioccom.h .
According to Simon Hausmann, _IOC_READ means the kernel
writes a value to the ioctl value passed from the user
space and the other way around with _IOC_WRITE. */
#if defined(VGO_solaris)
/* Majority of Solaris ioctl requests does not honour direction hints. */
UInt dir = _VKI_IOC_NONE;
#else
UInt dir = _VKI_IOC_DIR(request);
#endif
UInt size = _VKI_IOC_SIZE(request);
if (SimHintiS(SimHint_lax_ioctls, VG_(clo_sim_hints))) {
/*
* Be very lax about ioctl handling; the only
* assumption is that the size is correct. Doesn't
* require the full buffer to be initialized when
* writing. Without this, using some device
* drivers with a large number of strange ioctl
* commands becomes very tiresome.
*/
} else if (/* size == 0 || */ dir == _VKI_IOC_NONE) {
static UWord unknown_ioctl[10];
static Int moans = sizeof(unknown_ioctl) / sizeof(unknown_ioctl[0]);
if (moans > 0 && !VG_(clo_xml)) {
/* Check if have not already moaned for this request. */
UInt i;
for (i = 0; i < sizeof(unknown_ioctl)/sizeof(unknown_ioctl[0]); i++) {
if (unknown_ioctl[i] == request)
break;
if (unknown_ioctl[i] == 0) {
unknown_ioctl[i] = request;
moans--;
VG_(umsg)("Warning: noted but unhandled ioctl 0x%lx"
" with no size/direction hints.\n", request);
VG_(umsg)(" This could cause spurious value errors to appear.\n");
VG_(umsg)(" See README_MISSING_SYSCALL_OR_IOCTL for "
"guidance on writing a proper wrapper.\n" );
//VG_(get_and_pp_StackTrace)(tid, VG_(clo_backtrace_size));
return;
}
}
}
} else {
//VG_(message)(Vg_UserMsg, "UNKNOWN ioctl %#lx\n", request);
//VG_(get_and_pp_StackTrace)(tid, VG_(clo_backtrace_size));
if ((dir & _VKI_IOC_WRITE) && size > 0)
PRE_MEM_READ( "ioctl(generic)", arg, size);
if ((dir & _VKI_IOC_READ) && size > 0)
PRE_MEM_WRITE( "ioctl(generic)", arg, size);
}
}
void ML_(POST_unknown_ioctl)(ThreadId tid, UInt res, UWord request, UWord arg)
{
/* We don't have any specific information on it, so
try to do something reasonable based on direction and
size bits. The encoding scheme is described in
/usr/include/asm/ioctl.h or /usr/include/sys/ioccom.h .
According to Simon Hausmann, _IOC_READ means the kernel
writes a value to the ioctl value passed from the user
space and the other way around with _IOC_WRITE. */
UInt dir = _VKI_IOC_DIR(request);
UInt size = _VKI_IOC_SIZE(request);
if (size > 0 && (dir & _VKI_IOC_READ)
&& res == 0
&& arg != (Addr)NULL)
{
POST_MEM_WRITE(arg, size);
}
}
/*
If we're sending a SIGKILL to one of our own threads, then simulate
it rather than really sending the signal, so that the target thread
gets a chance to clean up. Returns True if we did the killing (or
no killing is necessary), and False if the caller should use the
normal kill syscall.
"pid" is any pid argument which can be passed to kill; group kills
(< -1, 0), and owner kills (-1) are ignored, on the grounds that
they'll most likely hit all the threads and we won't need to worry
about cleanup. In truth, we can't fully emulate these multicast
kills.
"tgid" is a thread group id. If it is not -1, then the target
thread must be in that thread group.
*/
Bool ML_(do_sigkill)(Int pid, Int tgid)
{
ThreadState *tst;
ThreadId tid;
if (pid <= 0)
return False;
tid = VG_(lwpid_to_vgtid)(pid);
if (tid == VG_INVALID_THREADID)
return False; /* none of our threads */
tst = VG_(get_ThreadState)(tid);
if (tst == NULL || tst->status == VgTs_Empty)
return False; /* hm, shouldn't happen */
if (tgid != -1 && tst->os_state.threadgroup != tgid)
return False; /* not the right thread group */
/* Check to see that the target isn't already exiting. */
if (!VG_(is_exiting)(tid)) {
if (VG_(clo_trace_signals))
VG_(message)(Vg_DebugMsg,
"Thread %u being killed with SIGKILL\n",
tst->tid);
tst->exitreason = VgSrc_FatalSig;
tst->os_state.fatalsig = VKI_SIGKILL;
if (!VG_(is_running_thread)(tid))
VG_(get_thread_out_of_syscall)(tid);
}
return True;
}
PRE(sys_kill)
{
PRINT("sys_kill ( %ld, %ld )", SARG1, SARG2);
PRE_REG_READ2(long, "kill", int, pid, int, signal);
if (!ML_(client_signal_OK)(ARG2)) {
SET_STATUS_Failure( VKI_EINVAL );
return;
}
/* If we're sending SIGKILL, check to see if the target is one of
our threads and handle it specially. */
if (ARG2 == VKI_SIGKILL && ML_(do_sigkill)(ARG1, -1))
SET_STATUS_Success(0);
else
/* re syscall3: Darwin has a 3rd arg, which is a flag (boolean)
affecting how posix-compliant the call is. I guess it is
harmless to pass the 3rd arg on other platforms; hence pass
it on all. */
SET_STATUS_from_SysRes( VG_(do_syscall3)(SYSNO, ARG1, ARG2, ARG3) );
if (VG_(clo_trace_signals))
VG_(message)(Vg_DebugMsg, "kill: sent signal %ld to pid %ld\n",
SARG2, SARG1);
/* This kill might have given us a pending signal. Ask for a check once
the syscall is done. */
*flags |= SfPollAfter;
}
PRE(sys_link)
{
*flags |= SfMayBlock;
PRINT("sys_link ( %#lx(%s), %#lx(%s) )", ARG1,(char*)ARG1,ARG2,(char*)ARG2);
PRE_REG_READ2(long, "link", const char *, oldpath, const char *, newpath);
PRE_MEM_RASCIIZ( "link(oldpath)", ARG1);
PRE_MEM_RASCIIZ( "link(newpath)", ARG2);
}
PRE(sys_newlstat)
{
PRINT("sys_newlstat ( %#lx(%s), %#lx )", ARG1,(char*)ARG1,ARG2);
PRE_REG_READ2(long, "lstat", char *, file_name, struct stat *, buf);
PRE_MEM_RASCIIZ( "lstat(file_name)", ARG1 );
PRE_MEM_WRITE( "lstat(buf)", ARG2, sizeof(struct vki_stat) );
}
POST(sys_newlstat)
{
vg_assert(SUCCESS);
POST_MEM_WRITE( ARG2, sizeof(struct vki_stat) );
}
PRE(sys_mkdir)
{
*flags |= SfMayBlock;
PRINT("sys_mkdir ( %#lx(%s), %ld )", ARG1, (HChar*)ARG1, SARG2);
PRE_REG_READ2(long, "mkdir", const char *, pathname, int, mode);
PRE_MEM_RASCIIZ( "mkdir(pathname)", ARG1 );
}
PRE(sys_mprotect)
{
PRINT("sys_mprotect ( %#lx, %lu, %lu )", ARG1, ARG2, ARG3);
PRE_REG_READ3(long, "mprotect",
unsigned long, addr, vki_size_t, len, unsigned long, prot);
if (!ML_(valid_client_addr)(ARG1, ARG2, tid, "mprotect")) {
SET_STATUS_Failure( VKI_ENOMEM );
}
#if defined(VKI_PROT_GROWSDOWN)
else
if (ARG3 & (VKI_PROT_GROWSDOWN|VKI_PROT_GROWSUP)) {
/* Deal with mprotects on growable stack areas.
The critical files to understand all this are mm/mprotect.c
in the kernel and sysdeps/unix/sysv/linux/dl-execstack.c in
glibc.
The kernel provides PROT_GROWSDOWN and PROT_GROWSUP which
round the start/end address of mprotect to the start/end of
the underlying vma and glibc uses that as an easy way to
change the protection of the stack by calling mprotect on the
last page of the stack with PROT_GROWSDOWN set.
The sanity check provided by the kernel is that the vma must
have the VM_GROWSDOWN/VM_GROWSUP flag set as appropriate. */
UInt grows = ARG3 & (VKI_PROT_GROWSDOWN|VKI_PROT_GROWSUP);
NSegment const *aseg = VG_(am_find_nsegment)(ARG1);
NSegment const *rseg;
vg_assert(aseg);
if (grows == VKI_PROT_GROWSDOWN) {
rseg = VG_(am_next_nsegment)( aseg, False/*backwards*/ );
if (rseg &&
rseg->kind == SkResvn &&
rseg->smode == SmUpper &&
rseg->end+1 == aseg->start) {
Addr end = ARG1 + ARG2;
ARG1 = aseg->start;
ARG2 = end - aseg->start;
ARG3 &= ~VKI_PROT_GROWSDOWN;
} else {
SET_STATUS_Failure( VKI_EINVAL );
}
} else if (grows == VKI_PROT_GROWSUP) {
rseg = VG_(am_next_nsegment)( aseg, True/*forwards*/ );
if (rseg &&
rseg->kind == SkResvn &&
rseg->smode == SmLower &&
aseg->end+1 == rseg->start) {
ARG2 = aseg->end - ARG1 + 1;
ARG3 &= ~VKI_PROT_GROWSUP;
} else {
SET_STATUS_Failure( VKI_EINVAL );
}
} else {
/* both GROWSUP and GROWSDOWN */
SET_STATUS_Failure( VKI_EINVAL );
}
}
#endif // defined(VKI_PROT_GROWSDOWN)
}
POST(sys_mprotect)
{
Addr a = ARG1;
SizeT len = ARG2;
Int prot = ARG3;
ML_(notify_core_and_tool_of_mprotect)(a, len, prot);
}
PRE(sys_munmap)
{
if (0) VG_(printf)(" munmap( %#lx )\n", ARG1);
PRINT("sys_munmap ( %#lx, %llu )", ARG1,(ULong)ARG2);
PRE_REG_READ2(long, "munmap", unsigned long, start, vki_size_t, length);
if (!ML_(valid_client_addr)(ARG1, ARG2, tid, "munmap"))
SET_STATUS_Failure( VKI_EINVAL );
}
POST(sys_munmap)
{
Addr a = ARG1;
SizeT len = ARG2;
ML_(notify_core_and_tool_of_munmap)( a, len );
}
PRE(sys_mincore)
{
PRINT("sys_mincore ( %#lx, %llu, %#lx )", ARG1,(ULong)ARG2,ARG3);
PRE_REG_READ3(long, "mincore",
unsigned long, start, vki_size_t, length,
unsigned char *, vec);
PRE_MEM_WRITE( "mincore(vec)", ARG3, VG_PGROUNDUP(ARG2) / VKI_PAGE_SIZE );
}
POST(sys_mincore)
{
POST_MEM_WRITE( ARG3, VG_PGROUNDUP(ARG2) / VKI_PAGE_SIZE );
}
PRE(sys_nanosleep)
{
*flags |= SfMayBlock|SfPostOnFail;
PRINT("sys_nanosleep ( %#lx, %#lx )", ARG1,ARG2);
PRE_REG_READ2(long, "nanosleep",
struct timespec *, req, struct timespec *, rem);
PRE_MEM_READ( "nanosleep(req)", ARG1, sizeof(struct vki_timespec) );
if (ARG2 != 0)
PRE_MEM_WRITE( "nanosleep(rem)", ARG2, sizeof(struct vki_timespec) );
}
POST(sys_nanosleep)
{
vg_assert(SUCCESS || FAILURE);
if (ARG2 != 0 && FAILURE && ERR == VKI_EINTR)
POST_MEM_WRITE( ARG2, sizeof(struct vki_timespec) );
}
#if defined(VGO_linux) || defined(VGO_solaris)
/* Handles the case where the open is of /proc/self/auxv or
/proc/<pid>/auxv, and just gives out a copy of the fd for the
fake file we cooked up at startup (in m_main). Also, seeks the
cloned fd back to the start.
Returns True if auxv open was handled (status is set). */
Bool ML_(handle_auxv_open)(SyscallStatus *status, const HChar *filename,
int flags)
{
HChar name[30]; // large enough
if (!ML_(safe_to_deref)((const void *) filename, 1))
return False;
/* Opening /proc/<pid>/auxv or /proc/self/auxv? */
VG_(sprintf)(name, "/proc/%d/auxv", VG_(getpid)());
if (!VG_STREQ(filename, name) && !VG_STREQ(filename, "/proc/self/auxv"))
return False;
/* Allow to open the file only for reading. */
if (flags & (VKI_O_WRONLY | VKI_O_RDWR)) {
SET_STATUS_Failure(VKI_EACCES);
return True;
}
# if defined(VGO_solaris)
VG_(sprintf)(name, "/proc/self/fd/%d", VG_(cl_auxv_fd));
SysRes sres = VG_(open)(name, flags, 0);
SET_STATUS_from_SysRes(sres);
# else
SysRes sres = VG_(dup)(VG_(cl_auxv_fd));
SET_STATUS_from_SysRes(sres);
if (!sr_isError(sres)) {
OffT off = VG_(lseek)(sr_Res(sres), 0, VKI_SEEK_SET);
if (off < 0)
SET_STATUS_Failure(VKI_EMFILE);
}
# endif
return True;
}
#endif // defined(VGO_linux) || defined(VGO_solaris)
PRE(sys_open)
{
if (ARG2 & VKI_O_CREAT) {
// 3-arg version
PRINT("sys_open ( %#lx(%s), %ld, %ld )",ARG1, (HChar*)ARG1, SARG2, SARG3);
PRE_REG_READ3(long, "open",
const char *, filename, int, flags, int, mode);
} else {
// 2-arg version
PRINT("sys_open ( %#lx(%s), %ld )",ARG1, (HChar*)ARG1, SARG2);
PRE_REG_READ2(long, "open",
const char *, filename, int, flags);
}
PRE_MEM_RASCIIZ( "open(filename)", ARG1 );
#if defined(VGO_linux)
/* Handle the case where the open is of /proc/self/cmdline or
/proc/<pid>/cmdline, and just give it a copy of the fd for the
fake file we cooked up at startup (in m_main). Also, seek the
cloned fd back to the start. */
{
HChar name[30]; // large enough
HChar* arg1s = (HChar*) ARG1;
SysRes sres;
VG_(sprintf)(name, "/proc/%d/cmdline", VG_(getpid)());
if (ML_(safe_to_deref)( arg1s, 1 ) &&
(VG_STREQ(arg1s, name) || VG_STREQ(arg1s, "/proc/self/cmdline"))
)
{
sres = VG_(dup)( VG_(cl_cmdline_fd) );
SET_STATUS_from_SysRes( sres );
if (!sr_isError(sres)) {
OffT off = VG_(lseek)( sr_Res(sres), 0, VKI_SEEK_SET );
if (off < 0)
SET_STATUS_Failure( VKI_EMFILE );
}
return;
}
}
/* Handle also the case of /proc/self/auxv or /proc/<pid>/auxv. */
if (ML_(handle_auxv_open)(status, (const HChar *)ARG1, ARG2))
return;
#endif // defined(VGO_linux)
/* Otherwise handle normally */
*flags |= SfMayBlock;
}
POST(sys_open)
{
vg_assert(SUCCESS);
if (!ML_(fd_allowed)(RES, "open", tid, True)) {
VG_(close)(RES);
SET_STATUS_Failure( VKI_EMFILE );
} else {
if (VG_(clo_track_fds))
ML_(record_fd_open_with_given_name)(tid, RES, (HChar*)ARG1);
}
}
PRE(sys_read)
{
*flags |= SfMayBlock;
PRINT("sys_read ( %lu, %#lx, %lu )", ARG1, ARG2, ARG3);
PRE_REG_READ3(ssize_t, "read",
unsigned int, fd, char *, buf, vki_size_t, count);
if (!ML_(fd_allowed)(ARG1, "read", tid, False))
SET_STATUS_Failure( VKI_EBADF );
else
PRE_MEM_WRITE( "read(buf)", ARG2, ARG3 );
}
POST(sys_read)
{
vg_assert(SUCCESS);
POST_MEM_WRITE( ARG2, RES );
}
PRE(sys_write)
{
Bool ok;
*flags |= SfMayBlock;
PRINT("sys_write ( %lu, %#lx, %lu )", ARG1, ARG2, ARG3);
PRE_REG_READ3(ssize_t, "write",
unsigned int, fd, const char *, buf, vki_size_t, count);
/* check to see if it is allowed. If not, try for an exemption from
--sim-hints=enable-outer (used for self hosting). */
ok = ML_(fd_allowed)(ARG1, "write", tid, False);
if (!ok && ARG1 == 2/*stderr*/
&& SimHintiS(SimHint_enable_outer, VG_(clo_sim_hints)))
ok = True;
#if defined(VGO_solaris)
if (!ok && VG_(vfork_fildes_addr) != NULL &&
*VG_(vfork_fildes_addr) >= 0 && *VG_(vfork_fildes_addr) == ARG1)
ok = True;
#endif
if (!ok)
SET_STATUS_Failure( VKI_EBADF );
else
PRE_MEM_READ( "write(buf)", ARG2, ARG3 );
}
PRE(sys_creat)
{
*flags |= SfMayBlock;
PRINT("sys_creat ( %#lx(%s), %ld )", ARG1, (HChar*)ARG1, SARG2);
PRE_REG_READ2(long, "creat", const char *, pathname, int, mode);
PRE_MEM_RASCIIZ( "creat(pathname)", ARG1 );
}
POST(sys_creat)
{
vg_assert(SUCCESS);
if (!ML_(fd_allowed)(RES, "creat", tid, True)) {
VG_(close)(RES);
SET_STATUS_Failure( VKI_EMFILE );
} else {
if (VG_(clo_track_fds))
ML_(record_fd_open_with_given_name)(tid, RES, (HChar*)ARG1);
}
}
PRE(sys_poll)
{
/* struct pollfd {
int fd; -- file descriptor
short events; -- requested events
short revents; -- returned events
};
int poll(struct pollfd *ufds, unsigned int nfds, int timeout)
*/
UInt i;
struct vki_pollfd* ufds = (struct vki_pollfd *)ARG1;
*flags |= SfMayBlock;
PRINT("sys_poll ( %#lx, %lu, %ld )\n", ARG1, ARG2, SARG3);
PRE_REG_READ3(long, "poll",
struct vki_pollfd *, ufds, unsigned int, nfds, long, timeout);
for (i = 0; i < ARG2; i++) {
PRE_MEM_READ( "poll(ufds.fd)",
(Addr)(&ufds[i].fd), sizeof(ufds[i].fd) );
PRE_MEM_READ( "poll(ufds.events)",
(Addr)(&ufds[i].events), sizeof(ufds[i].events) );
PRE_MEM_WRITE( "poll(ufds.revents)",
(Addr)(&ufds[i].revents), sizeof(ufds[i].revents) );
}
}
POST(sys_poll)
{
if (RES >= 0) {
UInt i;
struct vki_pollfd* ufds = (struct vki_pollfd *)ARG1;
for (i = 0; i < ARG2; i++)
POST_MEM_WRITE( (Addr)(&ufds[i].revents), sizeof(ufds[i].revents) );
}
}
PRE(sys_readlink)
{
FUSE_COMPATIBLE_MAY_BLOCK();
Word saved = SYSNO;
PRINT("sys_readlink ( %#lx(%s), %#lx, %llu )", ARG1,(char*)ARG1,ARG2,(ULong)ARG3);
PRE_REG_READ3(long, "readlink",
const char *, path, char *, buf, int, bufsiz);
PRE_MEM_RASCIIZ( "readlink(path)", ARG1 );
PRE_MEM_WRITE( "readlink(buf)", ARG2,ARG3 );
{
#if defined(VGO_linux)
/*
* Handle the case where readlink is looking at /proc/self/exe or
* /proc/<pid>/exe.
*/
HChar name[30]; // large enough
HChar* arg1s = (HChar*) ARG1;
VG_(sprintf)(name, "/proc/%d/exe", VG_(getpid)());
if (ML_(safe_to_deref)(arg1s, 1) &&
(VG_STREQ(arg1s, name) || VG_STREQ(arg1s, "/proc/self/exe"))
)
{
VG_(sprintf)(name, "/proc/self/fd/%d", VG_(cl_exec_fd));
SET_STATUS_from_SysRes( VG_(do_syscall3)(saved, (UWord)name,
ARG2, ARG3));
} else
#elif defined(VGO_solaris)
/* Same for Solaris, but /proc/self/path/a.out and
/proc/<pid>/path/a.out. */
HChar name[30]; // large enough
HChar* arg1s = (HChar*) ARG1;
VG_(sprintf)(name, "/proc/%d/path/a.out", VG_(getpid)());
if (ML_(safe_to_deref)(arg1s, 1) &&
(VG_STREQ(arg1s, name) || VG_STREQ(arg1s, "/proc/self/path/a.out"))
)
{
VG_(sprintf)(name, "/proc/self/path/%d", VG_(cl_exec_fd));
SET_STATUS_from_SysRes( VG_(do_syscall3)(saved, (UWord)name,
ARG2, ARG3));
} else
#endif
{
/* Normal case */
SET_STATUS_from_SysRes( VG_(do_syscall3)(saved, ARG1, ARG2, ARG3));
}
}
if (SUCCESS && RES > 0)
POST_MEM_WRITE( ARG2, RES );
}
PRE(sys_readv)
{
Int i;
struct vki_iovec * vec;
*flags |= SfMayBlock;
PRINT("sys_readv ( %lu, %#lx, %lu )", ARG1, ARG2, ARG3);
PRE_REG_READ3(ssize_t, "readv",
unsigned long, fd, const struct iovec *, vector,
unsigned long, count);
if (!ML_(fd_allowed)(ARG1, "readv", tid, False)) {
SET_STATUS_Failure( VKI_EBADF );
} else {
if ((Int)ARG3 >= 0)
PRE_MEM_READ( "readv(vector)", ARG2, ARG3 * sizeof(struct vki_iovec) );
if (ARG2 != 0) {
/* ToDo: don't do any of the following if the vector is invalid */
vec = (struct vki_iovec *)ARG2;
for (i = 0; i < (Int)ARG3; i++)
PRE_MEM_WRITE( "readv(vector[...])",
(Addr)vec[i].iov_base, vec[i].iov_len );
}
}
}
POST(sys_readv)
{
vg_assert(SUCCESS);
if (RES > 0) {
Int i;
struct vki_iovec * vec = (struct vki_iovec *)ARG2;
Int remains = RES;
/* RES holds the number of bytes read. */
for (i = 0; i < (Int)ARG3; i++) {
Int nReadThisBuf = vec[i].iov_len;
if (nReadThisBuf > remains) nReadThisBuf = remains;
POST_MEM_WRITE( (Addr)vec[i].iov_base, nReadThisBuf );
remains -= nReadThisBuf;
if (remains < 0) VG_(core_panic)("readv: remains < 0");
}
}
}
PRE(sys_rename)
{
FUSE_COMPATIBLE_MAY_BLOCK();
PRINT("sys_rename ( %#lx(%s), %#lx(%s) )", ARG1,(char*)ARG1,ARG2,(char*)ARG2);
PRE_REG_READ2(long, "rename", const char *, oldpath, const char *, newpath);
PRE_MEM_RASCIIZ( "rename(oldpath)", ARG1 );
PRE_MEM_RASCIIZ( "rename(newpath)", ARG2 );
}
PRE(sys_rmdir)
{
*flags |= SfMayBlock;
PRINT("sys_rmdir ( %#lx(%s) )", ARG1,(char*)ARG1);
PRE_REG_READ1(long, "rmdir", const char *, pathname);
PRE_MEM_RASCIIZ( "rmdir(pathname)", ARG1 );
}
PRE(sys_select)
{
*flags |= SfMayBlock;
PRINT("sys_select ( %ld, %#lx, %#lx, %#lx, %#lx )", SARG1, ARG2, ARG3,
ARG4, ARG5);
PRE_REG_READ5(long, "select",
int, n, vki_fd_set *, readfds, vki_fd_set *, writefds,
vki_fd_set *, exceptfds, struct vki_timeval *, timeout);
// XXX: this possibly understates how much memory is read.
if (ARG2 != 0)
PRE_MEM_READ( "select(readfds)",
ARG2, ARG1/8 /* __FD_SETSIZE/8 */ );
if (ARG3 != 0)
PRE_MEM_READ( "select(writefds)",
ARG3, ARG1/8 /* __FD_SETSIZE/8 */ );
if (ARG4 != 0)
PRE_MEM_READ( "select(exceptfds)",
ARG4, ARG1/8 /* __FD_SETSIZE/8 */ );
if (ARG5 != 0)
PRE_timeval_READ( "select(timeout)", ARG5 );
}
PRE(sys_setgid)
{
PRINT("sys_setgid ( %lu )", ARG1);
PRE_REG_READ1(long, "setgid", vki_gid_t, gid);
}
PRE(sys_setsid)
{
PRINT("sys_setsid ( )");
PRE_REG_READ0(long, "setsid");
}
PRE(sys_setgroups)
{
PRINT("setgroups ( %llu, %#lx )", (ULong)ARG1, ARG2);
PRE_REG_READ2(long, "setgroups", int, size, vki_gid_t *, list);
if (ARG1 > 0)
PRE_MEM_READ( "setgroups(list)", ARG2, ARG1 * sizeof(vki_gid_t) );
}
PRE(sys_setpgid)
{
PRINT("setpgid ( %ld, %ld )", SARG1, SARG2);
PRE_REG_READ2(long, "setpgid", vki_pid_t, pid, vki_pid_t, pgid);
}
PRE(sys_setregid)
{
PRINT("sys_setregid ( %lu, %lu )", ARG1, ARG2);
PRE_REG_READ2(long, "setregid", vki_gid_t, rgid, vki_gid_t, egid);
}
PRE(sys_setreuid)
{
PRINT("sys_setreuid ( 0x%lx, 0x%lx )", ARG1, ARG2);
PRE_REG_READ2(long, "setreuid", vki_uid_t, ruid, vki_uid_t, euid);
}
PRE(sys_setrlimit)
{
UWord arg1 = ARG1;
PRINT("sys_setrlimit ( %lu, %#lx )", ARG1, ARG2);
PRE_REG_READ2(long, "setrlimit",
unsigned int, resource, struct rlimit *, rlim);
PRE_MEM_READ( "setrlimit(rlim)", ARG2, sizeof(struct vki_rlimit) );
#ifdef _RLIMIT_POSIX_FLAG
// Darwin will sometimes set _RLIMIT_POSIX_FLAG on setrlimit calls.
// Unset it here to make the if statements below work correctly.
arg1 &= ~_RLIMIT_POSIX_FLAG;
#endif
if (!VG_(am_is_valid_for_client)(ARG2, sizeof(struct vki_rlimit),
VKI_PROT_READ)) {
SET_STATUS_Failure( VKI_EFAULT );
}
else if (((struct vki_rlimit *)ARG2)->rlim_cur
> ((struct vki_rlimit *)ARG2)->rlim_max) {
SET_STATUS_Failure( VKI_EINVAL );
}
else if (arg1 == VKI_RLIMIT_NOFILE) {
if (((struct vki_rlimit *)ARG2)->rlim_cur > VG_(fd_hard_limit) ||
((struct vki_rlimit *)ARG2)->rlim_max != VG_(fd_hard_limit)) {
SET_STATUS_Failure( VKI_EPERM );
}
else {
VG_(fd_soft_limit) = ((struct vki_rlimit *)ARG2)->rlim_cur;
SET_STATUS_Success( 0 );
}
}
else if (arg1 == VKI_RLIMIT_DATA) {
if (((struct vki_rlimit *)ARG2)->rlim_cur > VG_(client_rlimit_data).rlim_max ||
((struct vki_rlimit *)ARG2)->rlim_max > VG_(client_rlimit_data).rlim_max) {
SET_STATUS_Failure( VKI_EPERM );
}
else {
VG_(client_rlimit_data) = *(struct vki_rlimit *)ARG2;
SET_STATUS_Success( 0 );
}
}
else if (arg1 == VKI_RLIMIT_STACK && tid == 1) {
if (((struct vki_rlimit *)ARG2)->rlim_cur > VG_(client_rlimit_stack).rlim_max ||
((struct vki_rlimit *)ARG2)->rlim_max > VG_(client_rlimit_stack).rlim_max) {
SET_STATUS_Failure( VKI_EPERM );
}
else {
/* Change the value of client_stack_szB to the rlim_cur value but
only if it is smaller than the size of the allocated stack for the
client.
TODO: All platforms should set VG_(clstk_max_size) as part of their
setup_client_stack(). */
if ((VG_(clstk_max_size) == 0)
|| (((struct vki_rlimit *) ARG2)->rlim_cur <= VG_(clstk_max_size)))
VG_(threads)[tid].client_stack_szB = ((struct vki_rlimit *)ARG2)->rlim_cur;
VG_(client_rlimit_stack) = *(struct vki_rlimit *)ARG2;
SET_STATUS_Success( 0 );
}
}
}
PRE(sys_setuid)
{
PRINT("sys_setuid ( %lu )", ARG1);
PRE_REG_READ1(long, "setuid", vki_uid_t, uid);
}
PRE(sys_newstat)
{
FUSE_COMPATIBLE_MAY_BLOCK();
PRINT("sys_newstat ( %#lx(%s), %#lx )", ARG1,(char*)ARG1,ARG2);
PRE_REG_READ2(long, "stat", char *, file_name, struct stat *, buf);
PRE_MEM_RASCIIZ( "stat(file_name)", ARG1 );
PRE_MEM_WRITE( "stat(buf)", ARG2, sizeof(struct vki_stat) );
}
POST(sys_newstat)
{
POST_MEM_WRITE( ARG2, sizeof(struct vki_stat) );
}
PRE(sys_statfs)
{
FUSE_COMPATIBLE_MAY_BLOCK();
PRINT("sys_statfs ( %#lx(%s), %#lx )",ARG1,(char*)ARG1,ARG2);
PRE_REG_READ2(long, "statfs", const char *, path, struct statfs *, buf);
PRE_MEM_RASCIIZ( "statfs(path)", ARG1 );
PRE_MEM_WRITE( "statfs(buf)", ARG2, sizeof(struct vki_statfs) );
}
POST(sys_statfs)
{
POST_MEM_WRITE( ARG2, sizeof(struct vki_statfs) );
}
PRE(sys_statfs64)
{
PRINT("sys_statfs64 ( %#lx(%s), %llu, %#lx )",ARG1,(char*)ARG1,(ULong)ARG2,ARG3);
PRE_REG_READ3(long, "statfs64",
const char *, path, vki_size_t, size, struct statfs64 *, buf);
PRE_MEM_RASCIIZ( "statfs64(path)", ARG1 );
PRE_MEM_WRITE( "statfs64(buf)", ARG3, ARG2 );
}
POST(sys_statfs64)
{
POST_MEM_WRITE( ARG3, ARG2 );
}
PRE(sys_symlink)
{
*flags |= SfMayBlock;
PRINT("sys_symlink ( %#lx(%s), %#lx(%s) )",ARG1,(char*)ARG1,ARG2,(char*)ARG2);
PRE_REG_READ2(long, "symlink", const char *, oldpath, const char *, newpath);
PRE_MEM_RASCIIZ( "symlink(oldpath)", ARG1 );
PRE_MEM_RASCIIZ( "symlink(newpath)", ARG2 );
}
PRE(sys_time)
{
/* time_t time(time_t *t); */
PRINT("sys_time ( %#lx )",ARG1);
PRE_REG_READ1(long, "time", int *, t);
if (ARG1 != 0) {
PRE_MEM_WRITE( "time(t)", ARG1, sizeof(vki_time_t) );
}
}
POST(sys_time)
{
if (ARG1 != 0) {
POST_MEM_WRITE( ARG1, sizeof(vki_time_t) );
}
}
PRE(sys_times)
{
PRINT("sys_times ( %#lx )", ARG1);
PRE_REG_READ1(long, "times", struct tms *, buf);
if (ARG1 != 0) {
PRE_MEM_WRITE( "times(buf)", ARG1, sizeof(struct vki_tms) );
}
}
POST(sys_times)
{
if (ARG1 != 0) {
POST_MEM_WRITE( ARG1, sizeof(struct vki_tms) );
}
}
PRE(sys_umask)
{
PRINT("sys_umask ( %ld )", SARG1);
PRE_REG_READ1(long, "umask", int, mask);
}
PRE(sys_unlink)
{
*flags |= SfMayBlock;
PRINT("sys_unlink ( %#lx(%s) )", ARG1,(char*)ARG1);
PRE_REG_READ1(long, "unlink", const char *, pathname);
PRE_MEM_RASCIIZ( "unlink(pathname)", ARG1 );
}
PRE(sys_newuname)
{
PRINT("sys_newuname ( %#lx )", ARG1);
PRE_REG_READ1(long, "uname", struct new_utsname *, buf);
PRE_MEM_WRITE( "uname(buf)", ARG1, sizeof(struct vki_new_utsname) );
}
POST(sys_newuname)
{
if (ARG1 != 0) {
POST_MEM_WRITE( ARG1, sizeof(struct vki_new_utsname) );
}
}
PRE(sys_waitpid)
{
*flags |= SfMayBlock;
PRINT("sys_waitpid ( %ld, %#lx, %ld )", SARG1, ARG2, SARG3);
PRE_REG_READ3(long, "waitpid",
vki_pid_t, pid, unsigned int *, status, int, options);
if (ARG2 != (Addr)NULL)
PRE_MEM_WRITE( "waitpid(status)", ARG2, sizeof(int) );
}
POST(sys_waitpid)
{
if (ARG2 != (Addr)NULL)
POST_MEM_WRITE( ARG2, sizeof(int) );
}
PRE(sys_wait4)
{
*flags |= SfMayBlock;
PRINT("sys_wait4 ( %ld, %#lx, %ld, %#lx )", SARG1, ARG2, SARG3, ARG4);
PRE_REG_READ4(long, "wait4",
vki_pid_t, pid, unsigned int *, status, int, options,
struct rusage *, rusage);
if (ARG2 != (Addr)NULL)
PRE_MEM_WRITE( "wait4(status)", ARG2, sizeof(int) );
if (ARG4 != (Addr)NULL)
PRE_MEM_WRITE( "wait4(rusage)", ARG4, sizeof(struct vki_rusage) );
}
POST(sys_wait4)
{
if (ARG2 != (Addr)NULL)
POST_MEM_WRITE( ARG2, sizeof(int) );
if (ARG4 != (Addr)NULL)
POST_MEM_WRITE( ARG4, sizeof(struct vki_rusage) );
}
PRE(sys_writev)
{
Int i;
struct vki_iovec * vec;
*flags |= SfMayBlock;
PRINT("sys_writev ( %lu, %#lx, %lu )", ARG1, ARG2, ARG3);
PRE_REG_READ3(ssize_t, "writev",
unsigned long, fd, const struct iovec *, vector,
unsigned long, count);
if (!ML_(fd_allowed)(ARG1, "writev", tid, False)) {
SET_STATUS_Failure( VKI_EBADF );
} else {
if ((Int)ARG3 >= 0)
PRE_MEM_READ( "writev(vector)",
ARG2, ARG3 * sizeof(struct vki_iovec) );
if (ARG2 != 0) {
/* ToDo: don't do any of the following if the vector is invalid */
vec = (struct vki_iovec *)ARG2;
for (i = 0; i < (Int)ARG3; i++)
PRE_MEM_READ( "writev(vector[...])",
(Addr)vec[i].iov_base, vec[i].iov_len );
}
}
}
PRE(sys_utimes)
{
FUSE_COMPATIBLE_MAY_BLOCK();
PRINT("sys_utimes ( %#lx(%s), %#lx )", ARG1,(char*)ARG1,ARG2);
PRE_REG_READ2(long, "utimes", char *, filename, struct timeval *, tvp);
PRE_MEM_RASCIIZ( "utimes(filename)", ARG1 );
if (ARG2 != 0) {
PRE_timeval_READ( "utimes(tvp[0])", ARG2 );
PRE_timeval_READ( "utimes(tvp[1])", ARG2+sizeof(struct vki_timeval) );
}
}
PRE(sys_acct)
{
PRINT("sys_acct ( %#lx(%s) )", ARG1,(char*)ARG1);
PRE_REG_READ1(long, "acct", const char *, filename);
PRE_MEM_RASCIIZ( "acct(filename)", ARG1 );
}
PRE(sys_pause)
{
*flags |= SfMayBlock;
PRINT("sys_pause ( )");
PRE_REG_READ0(long, "pause");
}
PRE(sys_sigaltstack)
{
PRINT("sigaltstack ( %#lx, %#lx )",ARG1,ARG2);
PRE_REG_READ2(int, "sigaltstack",
const vki_stack_t *, ss, vki_stack_t *, oss);
if (ARG1 != 0) {
const vki_stack_t *ss = (vki_stack_t *)ARG1;
PRE_MEM_READ( "sigaltstack(ss)", (Addr)&ss->ss_sp, sizeof(ss->ss_sp) );
PRE_MEM_READ( "sigaltstack(ss)", (Addr)&ss->ss_flags, sizeof(ss->ss_flags) );
PRE_MEM_READ( "sigaltstack(ss)", (Addr)&ss->ss_size, sizeof(ss->ss_size) );
}
if (ARG2 != 0) {
PRE_MEM_WRITE( "sigaltstack(oss)", ARG2, sizeof(vki_stack_t) );
}
/* Be safe. */
if (ARG1 && !ML_(safe_to_deref((void*)ARG1, sizeof(vki_stack_t)))) {
SET_STATUS_Failure(VKI_EFAULT);
return;
}
if (ARG2 && !ML_(safe_to_deref((void*)ARG2, sizeof(vki_stack_t)))) {
SET_STATUS_Failure(VKI_EFAULT);
return;
}
SET_STATUS_from_SysRes(
VG_(do_sys_sigaltstack) (tid, (vki_stack_t*)ARG1,
(vki_stack_t*)ARG2)
);
}
POST(sys_sigaltstack)
{
vg_assert(SUCCESS);
if (RES == 0 && ARG2 != 0)
POST_MEM_WRITE( ARG2, sizeof(vki_stack_t));
}
PRE(sys_sethostname)
{
PRINT("sys_sethostname ( %#lx, %ld )", ARG1, SARG2);
PRE_REG_READ2(long, "sethostname", char *, name, int, len);
PRE_MEM_READ( "sethostname(name)", ARG1, ARG2 );
}
#undef PRE
#undef POST
#endif // defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_solaris)
/*--------------------------------------------------------------------*/
/*--- end ---*/
/*--------------------------------------------------------------------*/
|
the_stack_data/42621.c | /*
FPR - Fundamentos de Programação
Marília Silva | https://maliarte.com.br
* Apoie o projeto de educação tecnológica no Brasil
* deixe uma estrela e saiba mais no instagram
@maliartemar @barbarostecnologis
Caractere mais importante para sting é o 'barra 0' -> lê-se "\0"
int vetor[30]; 0...29
char vet[30] 0..29 mas diferente do vetor de outro tipo não será ocupado
espaço da memória após \0
ex: char vetor[7] - capacidade de caracteres
| c | a | r | l | o | s | \0 |
0 1 2 3 4 5 6
oq efetivamente guardou:
6 caracteres
29/09/2021
STRINGS
Exemplo 1: Determinar o número de caracteres de uma string.
*/
//importação de bibliotecas
#include <stdio.h>
#include <string.h>
//declaração de protótipos
int quantidadeCaracteres (char str[]);
//main
void main ()
{
//declaração de variáveis
char palavra[30];
int quant;
//lendo a palavra
fflush (stdin);
printf ("Entre com uma palavra: ");
gets (palavra); //get string - lê uma string, independente do tamanho e dos caracteres que a compõem
//chamando a função
quant = quantidadeCaracteres (palavra);
//exibindo o resultado
printf ("\nA palavra %s possui %d caracteres.", palavra, quant);
}
//implementação das funções
int quantidadeCaracteres (char str[])
{
//declaração de variáveis
int i, cont = 0;
for (i=0;str[i]!='\0';i++)
{
cont++;
}
//retornando o resultado
return cont;
} |
the_stack_data/57949581.c | #include <stdio.h>
#include <string.h>
int flag_cry[] = {0x6a,0x68,0x7f,0x6e,0x68,0x66,0x2d,0x6b,0x61,0x6c,0x6a,0x2d,0x79,0x6c,0x60,0x2d,0x62,0x61,0x6c,0x7f,0x6c,0x66,0x2d,0x6f,0x78,0x2d,0x64,0x7e,0x79,0x68};
int fantastik_fonksiyon(const char* s){
int flag_key = 0xD;
int len = strlen(s);
int len_f = sizeof(flag_cry) / sizeof(int);
if(len != len_f){
return 0;
}
int i;
char real_flag[len_f+1];
for(i=0;i<len_f;i++){
real_flag[i] = flag_cry[i] ^ flag_key;
}
for(i=0;i<len_f;i++){
if(real_flag[i] != s[i]){
return 0;
}
}
return 1;
}
int main(int argc, char *argv[]) {
if(argc < 2){
printf("Kullanim: %s <deger>", argv[0]);
}else{
if(fantastik_fonksiyon(argv[1])){
printf("beni cok kiriyorsun :(");
}else{
printf("deger yanlis :)");
}
}
return 0;
}
|
the_stack_data/85421.c | #include <stdio.h>
main()
{
int a = 21;
int c ;
c = a;
printf("Line 1 - = 运算符实例,c 的值 = %d\n", c );
c += a;
printf("Line 2 - += 运算符实例,c 的值 = %d\n", c );
c -= a;
printf("Line 3 - -= 运算符实例,c 的值 = %d\n", c );
c *= a;
printf("Line 4 - *= 运算符实例,c 的值 = %d\n", c );
c /= a;
printf("Line 5 - /= 运算符实例,c 的值 = %d\n", c );
c = 200;
c %= a;
printf("Line 6 - %= 运算符实例,c 的值 = %d\n", c );
c <<= 2;
printf("Line 7 - <<= 运算符实例,c 的值 = %d\n", c );
c >>= 2;
printf("Line 8 - >>= 运算符实例,c 的值 = %d\n", c );
c &= 2;
printf("Line 9 - &= 运算符实例,c 的值 = %d\n", c );
c ^= 2;
printf("Line 10 - ^= 运算符实例,c 的值 = %d\n", c );
c |= 2;
printf("Line 11 - |= 运算符实例,c 的值 = %d\n", c );
}
|
the_stack_data/1113707.c | // Implementation of Stack Functions Using Arrays in C with static memory allocation
// A stack implemented here stores integer values and has operations like push, pop, peek etc.
#include<stdio.h>
#include<string.h>
#define MAX 25
int Stack[MAX], Top = -1, ele, i = 0;
void push();
void pop();
void peek();
void display();
int isFull();
int isEmpty();
int main(){
int opt;
printf("STACK OPERATIONS: 1. PUSH 2. POP 3. PEEK 4.DISPLAY 5.EXIT");
do{
//printf("\nEnter your choice: ");
scanf("%d",&opt);
switch(opt)
{
case(1):
{
push();
break;
}
case(2):
{
pop();
break;
}
case(3):
{
peek();
break;
}
case(4):
{
display();
break;
}
case(5):
{
printf("\nExit Operation");
break;
}
default: printf("Please enter a valid choice (1/2/3/4/5) !");
}
}while(opt != 5);
return 0;
}
void push(){
int flag1 = isFull();
if (flag1 == 1){
printf("\nStack Overflow | Top = %d", Top);
}
else{
//printf("Enter value to be pushed: ");
scanf("%d ",&ele);
Top++;
Stack[Top]=ele;
}
}
void pop(){
int flag2 = isEmpty();
if(flag2 == 1){
printf("\nStack Underflow, Top = %d", Top);
}
else{
ele = Stack[Top];
Top--;
printf("\nThe Popped element is %d",ele);
}
}
void peek(){
printf("\nThe top data element of stack = %d",Stack[Top]);
}
int isEmpty(){
if(Top == -1){
return 1;
}
}
int isFull(){
if(Top == (MAX - 1)){
return 1;
}
else
return 0;
}
void display(){
if(Top>=0){
printf("\nThe elements in Stack are: ");
for(int i = 0; i<=Top;i++)
printf("%d ", Stack[i]);
}
else
printf("\nStack is empty !");
}
|
the_stack_data/1134041.c | /*****************************************************************************
*
* $DEC0DE v1.1, Nov 2017.
*
* Remove encryption systems used to protect Atari ST programs.
*
* This source file can be compiled on any Operating Systems supporting gcc.
* For non-Linux systems, the following gcc ports are available:
* - gcc for Mac OS X https://github.com/kennethreitz/osx-gcc-installer
* - gcc for Windows http://www.mingw.org
* - gcc for Atari http://vincent.riviere.free.fr/soft/m68k-atari-mint
*
* Depending on the target Operating System, run gcc as follows:
* - For Linux:
* $ gcc -O -Wall -Wextra -m32 -static dec0de.c -o dec0de
* - For Mac OS X:
* $ gcc -O -Wall -Wextra -m32 -mmacosx-version-min=10.5 dec0de.c -o dec0de
* - For Windows:
* $ gcc -O -Wall -Wextra -std=c99 dec0de.c -o dec0de.exe
* - For Atari ST:
* $ m68k-atari-mint-gcc -O -Wall -Wextra dec0de.c -o dec0de.prg
* or
* $ m68k-atari-mint-gcc -O -Wall -Wextra dec0de.c -o dec0de.ttp
*
* On Linux, Mac or Windows, run the resulting program from the command prompt.
* To obtain usage information, run the program as follows:
* $ dec0de -h
*
* On Atari ST, launch dec0de.prg or dec0de.ttp from the GEM desktop.
* dec0de.prg provides an interactive mode, while dec0de.ttp expects
* parameters to be provided through the command line.
*
* Versions history:
*
* - v1.0, Dec 2016, initial version supporting:
* NTM/Cameo Toxic Packer v1.0,
* R.AL Little Protection v01 & Megaprot v0.02,
* Orion Sly Packer v2.0,
* Cameo Cooper v0.5 & v0.6,
* Illegal Anti-bitos v1.0, v1.4, v1.6 & v1.61,
* Zippy Little Protection v2.05 & v2.06,
* Yoda Lock-o-matic v1.3.
*
* - v1.1, Nov 2017, adds support for:
* Criminals In Disguise (CID) Encrypter v1.0bp,
* Rob Northen Copylock Protection System series 1 (1988) & series 2 (1989).
*
* Code & reverse engineering: Orion ^ The Replicants ^ Fuzion
* Reverse engineering: Maartau ^ Atari Legend ^ Elite
* ASCII logo: Senser ^ Effect ^ Vectronix
*
* Git repository: https://github.com/orionfuzion/dec0de
* Contact: [email protected] or [email protected]
*
*****************************************************************************/
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <limits.h>
#include <errno.h>
/*****************************************************************************
* Declarations & macros
*****************************************************************************/
#define DEC0DE_NAME "DEC0DE"
#define DEC0DE_VERSION "1.1"
#define DEC0DE_DATE "Nov 2017"
#define DEC0DE_VERSION_FULL \
"$" DEC0DE_NAME " v" DEC0DE_VERSION ", " DEC0DE_DATE "."
#define DEC0DE_AUTHOR \
"Orion ^ The Replicants"
#define DEC0DE_TEAM \
DEC0DE_AUTHOR " + Maartau ^ Atari Legend"
#define DEC0DE_REPO \
"https://github.com/orionfuzion/dec0de"
#define DEC0DE_EMAIL \
"[email protected]"
#if defined(__atarist__)
#define TARGET_ST
#else
#undef TARGET_ST
#endif
/* For compatibility with Windows open() */
#ifndef O_BINARY
#define O_BINARY 0
#endif
//#define DEBUG
static int log_count;
#define LOG_INFO(_f, _a...) \
do { \
fprintf(stdout, _f, ##_a); \
fflush(stdout); \
log_count++; \
} while (0)
#define LOG_ERROR(_f, _a...) \
do { \
fprintf(stderr, _f, ##_a); \
fflush(stderr); \
log_count++; \
} while (0)
#define LOG_WARN(_f, _a...) \
do { \
fprintf(stdout, _f, ##_a); \
fflush(stdout); \
log_count++; \
} while (0)
#define ASSERT(_a) \
do { \
if (!(_a)) { \
LOG_ERROR("Assertion failed at %s:%d\n", \
__FUNCTION__, __LINE__); \
abort(); \
} \
} while (0)
#define __ASM_STR2(s) # s
#define __ASM_STR(s) __ASM_STR2(s)
#define USED __attribute__((used))
#define MARKER_MAGIC 0xdec0de11
struct pattern_t;
struct prot_t;
struct prog_t;
/*
* Protection identification pattern.
*/
typedef struct pattern_t {
unsigned int type;
size_t offset;
size_t eoffset;
size_t delta;
size_t count;
size_t ecount;
unsigned char* buf;
unsigned char* mask;
} pattern_t;
/*
* Decoding function.
*/
typedef int (*decode_func_t) (struct prog_t* prog,
unsigned char* buf,
size_t size);
/*
* Protection description.
*/
typedef struct prot_t {
struct prot_t* parent;
const char* name;
unsigned char varnum;
size_t doffset;
pattern_t** patterns;
decode_func_t decode;
void* private;
} prot_t;
/*
* Patterns and protections declaration macros.
*/
#define PATTERN_NONE 0
#define PATTERN_PROG 1
#define PATTERN_BIN 2
#define PATTERN_ANY (PATTERN_PROG | PATTERN_BIN)
#define PATTERN_NEXT ((size_t) -2)
#define PATTERN_BUFFER(_p...) { _p, }
#define DECLARE_PATTERN(_name, _type, _offset, _delta, _count, _buf) \
static unsigned char _name ## __buf[] = _buf; \
static pattern_t _name = { \
.type = _type, \
.offset = _offset, \
.delta = _delta, \
.count = _count, \
.buf = _name ## __buf, \
.mask = NULL, \
}
#define DECLARE_PATTERN_WITH_MASK(_name, _type, _offset, _delta, \
_count, _buf, _mask) \
static unsigned char _name ## __buf[] = _buf; \
static unsigned char _name ## __msk[] = _mask; \
static pattern_t _name = { \
.type = _type, \
.offset = _offset, \
.delta = _delta, \
.count = _count, \
.buf = _name ## __buf, \
.mask = _name ## __msk, \
}
#define PATTERNS_LIST(_l...) { _l, NULL, }
static pattern_t pattern_none = { .type = PATTERN_NONE, };
#define DECLARE_PROTECTION(_name, _desc, _doffset, _plist, \
_func, _priv) \
static pattern_t* _name ## patterns[] = _plist; \
static prot_t _name = { \
.parent = NULL, \
.name = _desc, \
.varnum = 0, \
.doffset = _doffset, \
.patterns = _name ## patterns, \
.decode = _func, \
.private = _priv, \
}
#define DECLARE_PROTECTION_PARENT(_name, _desc, _varnum, _doffset, \
_plist, _func, _priv) \
static pattern_t* _name ## patterns[] = _plist; \
static prot_t _name = { \
.parent = &_name, \
.name = _desc, \
.varnum = _varnum, \
.doffset = _doffset, \
.patterns = _name ## patterns, \
.decode = _func, \
.private = _priv, \
}
#define DECLARE_PROTECTION_VARIANT(_name, _parent, _varnum, _doffset, \
_plist, _func, _priv) \
static pattern_t* _name ## patterns[] = _plist; \
static prot_t _name = { \
.parent = _parent, \
.name = NULL, \
.varnum = _varnum, \
.doffset = _doffset, \
.patterns = _name ## patterns, \
.decode = _func, \
.private = _priv, \
}
#define PROT_DECODE(_p) \
((_p)->decode ? (_p)->decode : \
((_p)->parent ? (_p)->parent->decode : NULL))
/*
* Program description.
*/
typedef struct prog_t {
char* name; /* File name */
size_t fsize; /* File size */
size_t hsize; /* Program header size (if any) */
size_t size; /* Effective program size */
size_t dsize; /* Decoded program size */
size_t doffset; /* Decoded program offset */
unsigned int binary; /* Decoded program is binary (not a GEMDOS) */
prot_t* prot; /* Corresponding protection */
unsigned char* text; /* Text buffer */
unsigned char* marker; /* Marker at buffer's end */
unsigned char buf[]; /* File buffer */
} prog_t;
/*
* GEMDOS program header.
*
* See http://toshyp.atari.org/en/005005.html
*/
typedef struct prog_hdr_t {
uint8_t ph_branch[2]; /* WORD: branch to start of the program */
/* (must be 0x601a!) */
uint8_t ph_tlen[4]; /* LONG: length of the TEXT segment */
uint8_t ph_dlen[4]; /* LONG: length of the DATA segment */
uint8_t ph_blen[4]; /* LONG: length of the BSS segment */
uint8_t ph_slen[4]; /* LONG: length of the symbol table */
uint8_t ph_res1[4]; /* LONG: reserved, should be 0 */
/* (required by PureC) */
uint8_t ph_prgflags[4]; /* LONG: program flags */
uint8_t ph_absflag[2]; /* WORD: 0 = relocation info present */
} prog_hdr_t;
/*
* Instruction pattern matching description.
*/
typedef struct instr_match_t {
uint32_t op32[2];
uint32_t mask32[2];
uint16_t stride;
} instr_match_t;
/*****************************************************************************
* Platform-specific behavior
*****************************************************************************/
#if defined(TARGET_ST)
static int prog_atstart (void);
static void prog_atexit (void);
static int ia_mode_avail (void);
static int ia_mode_enter (void);
static void pp_newline (void);
static int key_wait (void);
/*
* VT-52 Terminal Control Sequences.
*
* See http://toshyp.atari.org/en/VT_52_terminal.html#VT-52_20terminal
*/
#define CLEAR_HOME "\33E"
#define CLEAR_DOWN "\33J"
#define CLEAR_SOL "\33o"
#define CUR_OFF "\33f"
#define SAVE_POS "\33j"
#define LOAD_POS "\33k"
#define REV_ON "\33p"
#define REV_OFF "\33q"
#define WRAP_ON "\33v"
#define WRAP_OFF "\33w"
#define PP_LINEBRK "\n"
#define PP_NEWLINE() pp_newline()
#define IA_MODE_AVAIL() ia_mode_avail()
#define IA_MODE_ENTER() ia_mode_enter()
#define PROG_ATSTART() prog_atstart()
#define PROG_ATEXIT() prog_atexit()
#define PROG_NAME(_a) \
({ \
static const char* _pname = DEC0DE_NAME; \
(void) (_a); \
_pname; \
})
#define LOG_INFO_MORE(_t) \
do { \
LOG_INFO(_t "\n" REV_ON "Press any key to continue" REV_OFF); \
key_wait(); \
LOG_INFO(CLEAR_HOME); \
} while (0)
#else /* !TARGET_ST */
#define PP_LINEBRK ""
#define PP_NEWLINE() do { } while (0)
#define IA_MODE_AVAIL() ({ 0; })
#define IA_MODE_ENTER() ({ 1; })
#define PROG_ATSTART() ({ 0; })
#define PROG_ATEXIT() do { } while (0)
#define PROG_NAME(_a) ((_a)[0])
#define LOG_INFO_MORE(_t) LOG_INFO(_t "\n")
#endif /* !TARGET_ST */
/*****************************************************************************
* Decoding helper routines
*****************************************************************************/
#define SIZE_32 sizeof(uint32_t)
static inline uint32_t read32 (const unsigned char* buf)
{
uint32_t w32;
#if defined(TARGET_ST)
w32 = *(uint32_t*) buf;
#else
w32 = 0;
w32 |= (((uint32_t) buf[0]) << 24);
w32 |= (((uint32_t) buf[1]) << 16);
w32 |= (((uint32_t) buf[2]) << 8);
w32 |= (((uint32_t) buf[3]) << 0);
#endif
return w32;
}
static inline void write32 (uint32_t w32, unsigned char* buf)
{
#if defined(TARGET_ST)
*(uint32_t*) buf = w32;
#else
buf[0] = (unsigned char) ((w32 >> 24) & 0xff);
buf[1] = (unsigned char) ((w32 >> 16) & 0xff);
buf[2] = (unsigned char) ((w32 >> 8) & 0xff);
buf[3] = (unsigned char) ((w32 >> 0) & 0xff);
#endif
}
#define SIZE_16 sizeof(uint16_t)
static inline uint16_t read16 (const unsigned char* buf)
{
uint16_t w16;
#if defined(TARGET_ST)
w16 = *(uint16_t*) buf;
#else
w16 = 0;
w16 |= (uint16_t) (((uint16_t) buf[0]) << 8);
w16 |= (uint16_t) (((uint16_t) buf[1]) << 0);
#endif
return w16;
}
static inline void write16 (uint16_t w16, unsigned char* buf)
{
#if defined(TARGET_ST)
*(uint16_t*) buf = w16;
#else
buf[0] = (unsigned char) ((w16 >> 8) & 0xff);
buf[1] = (unsigned char) ((w16 >> 0) & 0xff);
#endif
}
#define SIZE_8 sizeof(uint8_t)
static inline uint8_t read8 (const unsigned char* buf)
{
return (uint8_t) buf[0];
}
static inline void write8 (uint8_t w8, unsigned char* buf)
{
buf[0] = (unsigned char) w8;
}
#define BIT(_b) (1 << (_b))
#define ROR32(_w32,_b) \
((((_w32) & ((uint32_t) (BIT(_b) - 1))) << (32 - (_b))) | \
(((_w32) & ((uint32_t) ~(BIT(_b) - 1))) >> (_b)))
#define ROL32(_w32,_b) \
((((_w32) & ((uint32_t) ((BIT(_b) - 1) << (32 - (_b))))) >> (32 - (_b)))|\
(((_w32) & ((uint32_t) ~((BIT(_b) - 1) << (32 - (_b))))) << (_b)))
#define ROR16(_w16,_b) \
((((_w16) & ((uint16_t) (BIT(_b) - 1))) << (16 - (_b))) | \
(((_w16) & ((uint16_t) ~(BIT(_b) - 1))) >> (_b)))
#define ROL16(_w16,_b) \
((((_w16) & ((uint16_t) ((BIT(_b) - 1) << (16 - (_b))))) >> (16 - (_b)))|\
(((_w16) & ((uint16_t) ~((BIT(_b) - 1) << (16 - (_b))))) << (_b)))
#define ROR8(_w8,_b) \
((((_w8) & ((uint8_t) (BIT(_b) - 1))) << (8 - (_b))) | \
(((_w8) & ((uint8_t) ~(BIT(_b) - 1))) >> (_b)))
#define ROL8(_w8,_b) \
((((_w8) & ((uint8_t) ((BIT(_b) - 1) << (8 - (_b))))) >> (8 - (_b))) | \
(((_w8) & ((uint8_t) ~((BIT(_b) - 1) << (8 - (_b))))) << (_b)))
#define SWAP32(_w32) \
((((_w32) & (uint32_t) 0xffff0000) >> 16) | \
(((_w32) & (uint32_t) 0x0000ffff) << 16))
#define NEG8(_w8) (((uint8_t) 0) - (_w8))
#define NEG16(_w16) (((uint16_t) 0) - (_w16))
#define NEG32(_w32) (((uint32_t) 0) - (_w32))
#define DBF_SIZE8(_s) ((((uint32_t)(_s)) & (uint32_t) 0x0000ffff) + 1)
#define DBF_SIZE16(_s) ((((uint32_t)(_s)) & (uint32_t) 0x0001ffff) + 1)
#define DBF_SIZE32(_s) ((((uint32_t)(_s)) & (uint32_t) 0x0003ffff) + 1)
static inline int cmp_instr (uint32_t w32_1, uint32_t w32_2,
instr_match_t* instr)
{
return ((instr->op32[0] == (w32_1 & instr->mask32[0])) &&
(instr->op32[1] == (w32_2 & instr->mask32[1])));
}
/*****************************************************************************
* Program loading, fixup & saving
*****************************************************************************/
/*
* Release resources allocated to the currently loaded protected program.
*/
static void release_prog (prog_t* prog)
{
if (prog->name) {
free(prog->name);
}
free(prog);
}
/*
* Load a protected program and create a program descriptor.
*/
static prog_t* load_prog (const char* name)
{
int fd;
off_t off;
ssize_t sz;
size_t sz_buf;
size_t count;
prog_t* prog = NULL;
unsigned char* buf;
fd = open(name, O_BINARY | O_RDONLY);
if (fd == -1) {
LOG_ERROR("Cannot open file '%s': %s\n", name, strerror(errno));
return NULL;
}
off = lseek(fd, 0, SEEK_END);
if (off == (off_t) -1) {
LOG_ERROR("Cannot seek to end of file '%s': %s\n",
name, strerror(errno));
goto err;
}
if ((((size_t)off) <= sizeof(prog_hdr_t)) ||
(((size_t)off) > (8 * 1024 * 1024))) {
off = 0;
}
/*
* Allocate an extra 32-bits word for safely allowing buffer overflow:
* - when creating a fixup (relocation table) offset.
* - when decrypting the last word (overflow may happen if file size and
* decrypted word size are not compatible).
*
* Allocate another extra 32-bits word as a marker used to detect
* unexpected buffer overflow.
*/
sz_buf = (((size_t) off) + (SIZE_32 - 1)) & ~(SIZE_32 - 1);
sz_buf += 2 * SIZE_32;
prog = malloc(sz_buf + sizeof(prog_t));
if (!prog) {
LOG_ERROR("Cannot allocate a program buffer of %zu bytes\n",
sz_buf + sizeof(prog_t));
goto err;
}
memset(prog, 0, sizeof(prog_t));
prog->name = malloc(strlen(name) + 1);
if (!prog->name) {
LOG_ERROR("Cannot allocate a name string of %zu bytes\n",
strlen(name) + 1);
goto err;
}
strcpy(prog->name, name);
prog->fsize = (size_t) off;
prog->marker = prog->buf + sz_buf - SIZE_32;
off = lseek(fd, 0, SEEK_SET);
if (off == (off_t) -1) {
LOG_ERROR("Cannot seek to start of file '%s': %s\n",
name, strerror(errno));
goto err;
}
count = prog->fsize;
buf = prog->buf;
while (count) {
sz = read(fd, buf, count);
if (sz == (ssize_t) -1) {
if (errno == EINTR) {
continue;
}
LOG_ERROR("Failed to read %zu bytes from file '%s': %s\n",
count, name, strerror(errno));
goto err;
}
if (sz == 0) {
break;
}
count -= (size_t) sz;
buf += sz;
}
if (count) {
LOG_ERROR("Unexpected EOF while reading from file '%s', file size=%zu"
" bytes, unread bytes=%zu, last read result=%zd\n",
name, prog->fsize, count, (size_t) sz);
goto err;
}
while (buf != prog->marker) {
*buf = '\0';
buf++;
}
write32(MARKER_MAGIC, prog->marker);
prog->hsize = ((read16(prog->buf) == (uint16_t) 0x601a) ?
sizeof(prog_hdr_t) : 0);
prog->size = prog->fsize - prog->hsize;
prog->text = prog->buf + prog->hsize;
ret:
(void) close(fd);
return prog;
err:
if (prog) {
release_prog(prog);
prog = NULL;
}
goto ret;
}
/*
* Save the decoded program.
*/
static int save_prog (prog_t* prog, const char* name)
{
unsigned char* buf;
size_t count;
ssize_t sz;
int fd;
ASSERT(prog->prot && prog->dsize && prog->doffset);
fd = open(name, O_BINARY | O_RDWR | O_CREAT | O_EXCL, 0666);
if (fd == -1) {
LOG_ERROR("Cannot create file '%s': %s\n", name, strerror(errno));
return 1;
}
buf = prog->text + prog->doffset;
count = prog->dsize;
while (count) {
sz = write(fd, buf, count);
if (sz == (ssize_t) -1) {
if (errno == EINTR) {
continue;
}
LOG_ERROR("Failed to write %zu bytes to file '%s': %s\n",
count, name, strerror(errno));
goto err;
}
count -= (size_t) sz;
buf += sz;
}
(void) close(fd);
return 0;
err:
(void) close(fd);
(void) unlink(name);
return 1;
}
/*
* Dump the header of the decoded program in case of error.
*/
static void dump_hdr (prog_t* prog)
{
size_t doffset = prog->doffset;
unsigned char* dbuf = prog->text + doffset;
unsigned int i;
PP_NEWLINE();
LOG_ERROR("File size: %zu bytes\n", prog->fsize);
LOG_ERROR("Dec0ded program offset: %zu bytes\n", prog->hsize + doffset);
LOG_ERROR("Dec0ded program size: %zu bytes\n", prog->size - doffset);
LOG_ERROR("Dec0ded header: ");
for (i = 0; i < (unsigned int) sizeof(prog_hdr_t); i++) {
LOG_ERROR("%02x", (unsigned int) dbuf[i]);
}
LOG_ERROR("\n");
}
/*
* Performs checks and fixes on the decoded program prior to saving it.
*/
static int fixup_prog (prog_t* prog)
{
prot_t* prot = prog->prot;
unsigned char* dbuf;
prog_hdr_t* hdr;
size_t doffset;
size_t sz_dec;
size_t sz_text;
size_t sz_data;
size_t sz_bss;
size_t sz_symb;
size_t sz;
size_t i;
uint32_t res1;
ASSERT(sizeof(prog_hdr_t) == 28);
ASSERT(prot);
/*
* Actual decoded program offset and size.
*/
doffset = prog->doffset;
if (!doffset) {
prog->doffset = doffset = prot->doffset;
ASSERT(doffset);
}
sz_dec = prog->dsize;
if (!sz_dec) {
prog->dsize = sz_dec = prog->size - doffset;
}
/*
* Check for unexpected buffer overflow during decrypting.
*/
if (read32(prog->marker) != (uint32_t) MARKER_MAGIC) {
LOG_ERROR("Buffer overflow detected after dec0ding program\n");
return 1;
}
/*
* Do not perform GEMDOS fixup checking if decoded program is binary.
*/
if (prog->binary) {
return 0;
}
/*
* The program size must be greater than the GEMDOS header size.
*/
if ((ssize_t) sz_dec < (ssize_t) sizeof(prog_hdr_t)) {
LOG_ERROR("Invalid dec0ded program size=%zu bytes\n", sz_dec);
return 1;
}
dbuf = prog->text + doffset;
hdr = (prog_hdr_t*) dbuf;
sz_text = (size_t) read32((unsigned char*)&hdr->ph_tlen);
sz_data = (size_t) read32((unsigned char*)&hdr->ph_dlen);
sz_bss = (size_t) read32((unsigned char*)&hdr->ph_blen);
sz_symb = (size_t) read32((unsigned char*)&hdr->ph_slen);
/*
* Check text size.
*/
if (sz_text > sz_dec - sizeof(prog_hdr_t)) {
LOG_ERROR("Invalid text size=%zu bytes\n", sz_text);
goto dump;
}
/*
* Check data size.
*/
if (sz_data > sz_dec - sizeof(prog_hdr_t)) {
LOG_ERROR("Invalid data size=%zu bytes\n", sz_data);
goto dump;
}
/*
* Check symbols size.
*/
if (sz_symb > sz_dec - sizeof(prog_hdr_t)) {
LOG_ERROR("Invalid symbols size=%zu bytes\n", sz_symb);
goto dump;
}
/*
* Check bss size.
*/
if (sz_bss > (8 * 1024 * 1024)) {
LOG_ERROR("Invalid bss size=%zu bytes\n", sz_bss);
goto dump;
}
/*
* Check reserved field.
*/
res1 = read32((unsigned char*)&hdr->ph_res1);
if (res1 != 0) {
LOG_WARN("Warning: unexpected non-null reserved field=0x%08x\n", res1);
}
/*
* Check aggregated size (header + text + data + symbols).
*/
sz = sizeof(prog_hdr_t) + sz_text + sz_data + sz_symb;
if (sz > sz_dec) {
LOG_ERROR("Invalid aggregated size=%zu bytes\n", sz);
goto dump;
}
/*
* Check relocation table (fixups).
*/
if (read16((unsigned char*)&hdr->ph_absflag) == 0) {
uint32_t rel_off;
uint8_t off8;
/*
* ph_absflag is null, a relocation table may be present.
*/
if (sz + SIZE_32 > sz_dec) {
LOG_ERROR("Truncated starting fixup offset\n");
goto dump;
}
/*
* A non-zero fixup offset indicates that a relocation table is
* actually present.
*/
rel_off = ((((uint32_t)read8(dbuf + sz + SIZE_8*0)) << 24) |
(((uint32_t)read8(dbuf + sz + SIZE_8*1)) << 16) |
(((uint32_t)read8(dbuf + sz + SIZE_8*2)) << 8) |
(((uint32_t)read8(dbuf + sz + SIZE_8*3)) << 0));
sz += SIZE_32;
if (rel_off != (uint32_t) 0) {
/*
* Check relocation table entries.
*/
if ((rel_off & 0x1) ||
(rel_off + (uint32_t) SIZE_32 >
(uint32_t) (sz_text + sz_data))) {
LOG_ERROR("Invalid starting fixup offset=0x%x\n",
(unsigned int) rel_off);
goto dump;
}
for (;;) {
if (sz + SIZE_8 > sz_dec) {
/*
* Allow non-null terminated relocation table.
*/
LOG_WARN("Warning: unexpected non-null terminated "
"relocation table\n");
break;
}
off8 = read8(dbuf + sz);
sz += SIZE_8;
if (off8 == 0) {
break;
} else if (off8 == 1) {
rel_off += (uint32_t) 254;
} else if (off8 & 0x1) {
LOG_ERROR("Invalid (odd) 8-bits fixup offset\n");
goto dump;
} else {
rel_off += (uint32_t) off8;
}
if (rel_off + (uint32_t) SIZE_32 >
(uint32_t) (sz_text + sz_data)) {
LOG_ERROR("Invalid fixup offset=0x%x\n",
(unsigned int) rel_off);
goto dump;
}
}
}
} else {
/*
* ph_absflag is not null, there is no relocation table.
*
* Some TOS handle files with ph_absflag being non-zero incorrectly.
* Therefore it is better to represent a program having no fixups
* with a null ph_absflag and a null 32-bits word as the fixup offset.
*/
write16(0, (unsigned char*)&hdr->ph_absflag);
write8(0, dbuf + sz + SIZE_8*0);
write8(0, dbuf + sz + SIZE_8*1);
write8(0, dbuf + sz + SIZE_8*2);
write8(0, dbuf + sz + SIZE_8*3);
/*
* Buffer overflow is safely handled here since an extra 32-bits word
* has been provisioned at buffer allocation time.
*/
sz += SIZE_32;
}
for (i = 0; (ssize_t)i < (ssize_t)(sz_dec - sz); i++) {
write8('\0', dbuf + sz + i);
}
/*
* Some crypters may corrupt the branch value, reset it explicitly.
*/
write16(0x601a, (unsigned char*)&hdr->ph_branch);
/*
* Save the effective size of the GEMDOS program.
*/
prog->dsize = sz;
return 0;
dump:
LOG_ERROR("Program dec0ding failed!\n");
dump_hdr(prog);
return 1;
}
/*****************************************************************************
* Toxic Packer v1.0 by NTM/Cameo ^ The Replicants
*****************************************************************************/
#define TP1_OFF 0x1f2
static int decode_tp1 (prog_t* prog, unsigned char* buf, size_t size)
{
uint32_t key32 = 0xbabebabe;
uint16_t key16;
uint16_t w16;
size_t i;
(void) prog;
for (i = 0; i < size; i += SIZE_16) {
w16 = read16(buf + i);
w16 ^= (uint16_t) (key32 & (uint32_t) 0x0000ffff);
key16 = (uint16_t) (key32 & (uint32_t) 0x0000ffff);
key16 = ROR16(key16, 3);
key16 += 0x9876;
key32 = (key32 & (uint32_t) 0xffff0000) | (uint32_t) key16;
key32 = ROR32(key32, 2);
write16(w16, buf + i);
}
return 0;
}
DECLARE_PATTERN(pattern1_tp1,
PATTERN_ANY,
0x94, 0, 80,
PATTERN_BUFFER(
0x42, 0xb9, 0x00, 0xff, 0xfa, 0x06, /* clr.l $fffa06 */
0x2b, 0x47, 0x00, 0x24, /* move.l d7,$24(a5) */
0x2b, 0x47, 0x00, 0x10, /* move.l d7,$10(a5) */
0xe4, 0x98, /* ror.l #2,d0 */
0xd0, 0xad, 0x00, 0x24, /* add.l $24(a5),d0 */
0x90, 0xad, 0x00, 0x10, /* sub.l $10(a5),d0 */
0x46, 0x79, 0x00, 0xff, 0x82, 0x40, /* not.w $ff8240 */
0x4e, 0x73, /* rte */
0x20, 0x3c, 0x12, 0x34, 0x56, 0x78, /* move.l #$12345678,d0 */
0x41, 0xfa, 0x01, 0x36, /* lea pc+$138,a0 */
0x43, 0xfa, 0x2d, 0xf2, /* lea pc+$2df4,a1 */
0x20, 0x2a, 0x00, 0x24, /* move.l $24(a2),d0 */
0xb1, 0x58, /* 1: eor.w d0,(a0)+ */
0xe6, 0x58, /* ror.w #3,d0 */
0x06, 0x40, 0x98, 0x76, /* addi.w #$8976,d0 */
0x4e, 0x42, /* trap #2 */
0xb3, 0xc8, /* cmpa.l a0,a1 */
0x6c, 0x00, 0xff, 0xf2, /* bge 1b*/
0x21, 0xf8, 0x02, 0x00, 0x00, 0x68, /* move.l $200.w,$68.w */
0x23, 0xf8, 0x02, 0x04,
0x00, 0xff, 0xfa, 0x06 /* move.l $204,$fffa06 */
)
);
DECLARE_PROTECTION(prot_tp1,
"Toxic Packer v1.0 by NTM/Cameo ^ The Replicants",
TP1_OFF,
PATTERNS_LIST(
&pattern1_tp1
),
decode_tp1,
NULL
);
/*****************************************************************************
* Little Protection v01 by R.AL ^ The Replicants
* Supposedly installed by the Toxic Packer v2.0 by NTM/Cameo ^ The Replicants
*****************************************************************************/
#define RAL_LP_OFF 0x356
static int decode_ral_lp (prog_t* prog, unsigned char* buf, size_t size)
{
uint32_t key32 = 0x6085c752;
uint16_t w16;
size_t i;
(void) prog;
for (i = 0; i < size; i += SIZE_16) {
key32 = (key32 & (uint32_t) 0x0000ffff) * (uint32_t) 0x00003141;
key32 += 1;
w16 = read16(buf + i);
w16 ^= (uint16_t) (key32 & (uint32_t) 0x0000ffff);
write16(w16, buf + i);
}
return 0;
}
DECLARE_PATTERN(pattern1_ral_lp,
PATTERN_ANY,
0x3c, 0, 56,
PATTERN_BUFFER(
0x11, 0xd8, 0x00, 0x7f, /* move.b (a0)+, $7c.w */
0xd0, 0xb8, 0x00, 0x7c, /* add.l $7c.w,d0 */
0xb1, 0xfc, 0x00, 0x00, 0x35, 0x3a, /* cmpa.l #$353a,a0 */
0x6d, 0x04, /* blt.s 1f */
0x41, 0xf8, 0x32, 0x00, /* lea $3200.w,a0 */
0xd0, 0xb8, 0x00, 0x24, /* 1: add.l $24.w,d0 */
0xd0, 0xaf, 0x00, 0x02, /* add.l 2(a7),d0 */
0x00, 0x57, 0xa7, 0x10, /* ori.w #$a710,(a7) */
0x4e, 0x73, /* rte */
0x42, 0x80, /* clr.l d0 */
0x42, 0xb8, 0x00, 0x7c, /* clr.l $7c.w */
0x41, 0xf8, 0x32, 0x00, /* lea $3200,a0 */
0x21, 0xfc, 0x00, 0x00, 0x32, 0x22,
0x00, 0x24, /* move.l #$3222,$24.w */
0x46, 0xfc, 0xa7, 0x00 /* move #$a700,sr */
)
);
DECLARE_PROTECTION(prot_ral_lp,
"Little Protection v01 by R.AL ^ The Replicants",
RAL_LP_OFF,
PATTERNS_LIST(
&pattern1_ral_lp
),
decode_ral_lp,
NULL
);
/*****************************************************************************
* Megaprot v0.02 by R.AL ^ The Replicants
* Installed by the Toxic Packer v3.0 by NTM/Cameo ^ The Replicants
* https://demozoo.org/productions/95784/
*****************************************************************************/
#define RAL_MP_OFF 0x822
static int decode_ral_mp (prog_t* prog, unsigned char* buf, size_t size)
{
uint32_t key32 = 0xe45d2af8;
uint32_t w32;
uint32_t bit1;
uint32_t bit21;
size_t i;
(void) prog;
for (i = 0; i < size; i += SIZE_32) {
key32 <<= 1;
bit1 = (key32 & (uint32_t) BIT(1)) >> 1;
bit21 = (key32 & (uint32_t) BIT(21)) >> 21;
if (bit1 != bit21) {
key32 += 1;
}
w32 = read32(buf + i);
w32 += key32;
key32 += w32;
write32(w32, buf + i);
}
return 0;
}
DECLARE_PATTERN(pattern1_ral_mp,
PATTERN_ANY,
0x36, 0, 50,
PATTERN_BUFFER(
0x20, 0x78, 0x04, 0x26, /* movea.l $426.w,a0 */
0x20, 0xb8, 0x04, 0x2a, /* move.l $42a.w,(a0) */
0x20, 0x6f, 0x00, 0x02, /* movea.l 2(a7),a0 */
0x21, 0xc8, 0x04, 0x26, /* move.l a0,$426.w */
0x21, 0xd0, 0x04, 0x2a, /* move.l (a0),$42a.w */
0x20, 0x28, 0xff, 0xfc, /* move.l -4(a0),d0 */
0x46, 0x80, /* not.l d0 */
0x48, 0x40, /* swap d0 */
0xb1, 0x90, /* eor.l d0,(a0) */
0x4e, 0x73, /* rte */
0x41, 0xfa, 0xff, 0xde, /* lea pc-$20,a0 */
0x21, 0xc8, 0x00, 0x24, /* move.l a0,$24.w */
0x41, 0xfa, 0xff, 0xc8, /* lea pc-$36,a0 */
0x21, 0xc8, 0x00, 0x10, /* move.l a0,$10.w */
0x4a, 0xfc /* illegal */
)
);
DECLARE_PATTERN(pattern2_ral_mp,
PATTERN_ANY,
0x81a, 0, 8,
PATTERN_BUFFER(
0x63, 0x73, 0x97, 0xeb, 0xd8, 0x13, 0xd2, 0xfa /* Encrypted code */
)
);
DECLARE_PROTECTION(prot_ral_mp,
"Megaprot v0.02 by R.AL ^ The Replicants",
RAL_MP_OFF,
PATTERNS_LIST(
&pattern1_ral_mp,
&pattern2_ral_mp
),
decode_ral_mp,
NULL
);
/*****************************************************************************
* Sly Packer v2.0 by Orion ^ The Replicants
* https://demozoo.org/productions/127902/
*****************************************************************************/
#define SLY_OFF 0x720
static int calc_rand_sly (unsigned char* buf, uint16_t* rand)
{
uint32_t w32;
uint16_t rand16;
w32 = read32(buf - SLY_OFF + 0x67c);
w32 = w32 ^ (uint32_t) 0xbbb7dc8a;
rand16 = (uint16_t) (w32 & (uint32_t) 0x0000ffff);
*rand = rand16;
return 0;
}
static int decode_sly (prog_t* prog, unsigned char* buf, size_t size)
{
uint32_t key32;
uint16_t rand16;
uint16_t w16;
size_t i;
(void) prog;
if (calc_rand_sly(buf, &rand16)) {
LOG_ERROR("Cannot determine random number\n");
return 1;
}
key32 = 0x9cf142b3;
key32 = key32 ^ (uint32_t) rand16;
for (i = 0; i < size; i += SIZE_16) {
w16 = read16(buf + i);
rand16 = ~rand16;
key32 = key32 + (uint32_t) rand16;
w16 = (~w16) ^ (uint16_t) (key32 & (uint32_t) 0x0000ffff);
key32 = SWAP32(key32);
write16(w16, buf + i);
}
return 0;
}
DECLARE_PATTERN(pattern1_sly,
PATTERN_ANY,
0xac, 0, 28,
PATTERN_BUFFER(
0x41, 0xf8, 0x82, 0x09, /* lea $ffff8209.w,a0 */
0x10, 0x10, /* move.b (a0),d0 */
0x12, 0x10, /* 1: move.b (a0),d1 */
0xb2, 0x00, /* cmp.b d0,d1 */
0x67, 0xfa, /* beq.s 1b */
0x02, 0x01, 0x00, 0x1f, /* andi.b #$1f,d1 */
0x94, 0x01, /* sub.b d1,d2 */
0xe5, 0x29, /* lsl.b d2,d1 */
0x4f, 0xf8, 0x00, 0x14, /* lea $14.w,a7 */
0x46, 0xfc, 0xff, 0xff /* move #$ffff,sr */
)
);
DECLARE_PATTERN(pattern2_sly,
PATTERN_ANY,
0x6e2, 0, 22,
PATTERN_BUFFER(
0xd0, 0xb8, 0x00, 0x24, /* add.l $24.w,d0 */
0xb3, 0x80, /* eor.l d1,d0 */
0x48, 0x40, /* swap d0 */
0x51, 0xca, 0xff, 0xf4, /* dbf d2,pc-$a */
0xb1, 0x91, /* eor.l d0,(a1) */
0x4c, 0xf8, 0x07, 0x07, 0x00, 0x40, /* movem.l $40.w,d0-d2/a0-a2 */
0x4e, 0x73 /* rte */
)
);
DECLARE_PROTECTION(prot_sly,
"Sly Packer v2.0 by Orion ^ The Replicants",
SLY_OFF,
PATTERNS_LIST(
&pattern1_sly,
&pattern2_sly
),
decode_sly,
NULL
);
/*****************************************************************************
* Cooper v0.5 by Cameo ^ The Replicants
* https://demozoo.org/productions/96052/
*****************************************************************************/
#define COOPER5_OFF 0x6d0
static int calc_rand_cooper5 (unsigned char* buf, uint16_t* rand)
{
uint32_t w32;
uint16_t rand16;
w32 = read32(buf - COOPER5_OFF + 0x3a6);
w32 ^= (uint32_t) 0x0b364000;
rand16 = (uint16_t) 0x1c86 + (uint16_t) (w32 & (uint32_t) 0x0000ffff);
*rand = rand16;
return 0;
}
static int decode_cooper5 (prog_t* prog, unsigned char* buf, size_t size)
{
uint32_t key32;
uint16_t rand16;
uint8_t w8;
size_t i;
(void) prog;
if (calc_rand_cooper5(buf, &rand16)) {
LOG_ERROR("Cannot determine random number\n");
return 1;
}
key32 = 0x616a6178;
for (i = 0; i < size; i += SIZE_8) {
w8 = read8(buf + i);
w8 = w8 ^ (uint8_t) (key32 & (uint32_t) 0x000000ff);
key32 = key32 + (uint32_t) rand16;
key32 = SWAP32(key32);
write8(w8, buf + i);
}
return 0;
}
#define PATTERN_TVD_COOPER \
0x20, 0x78, 0x00, 0x24, /* movea.l $24.w,a0 */ \
0xd0, 0xe8, 0x00, 0x02, /* adda.w 2(a0),a0 */ \
0x7c, 0x45, /* moveq #$45,d6 */ \
0x42, 0xb8, 0x00, 0x10, /* clr.l $10.w */ \
0x42, 0xb8, 0xfa, 0x06, /* clr.l $fffffa06.w */ \
0x49, 0xd0, /* lea (a0),a4 */ \
0xbb, 0x58, /* 1: eor.w d5,(a0)+ */ \
0x51, 0xce, 0xff, 0xfc, /* dbf d6,1b */ \
0x60, 0x08, /* bra.s 3f */ \
0x7c, 0x45, /* moveq #$45,d6 */ \
0xbb, 0x5c, /* 2: eor.w d5,(a4)+ */ \
0x51, 0xce, 0xff, 0xfc, /* dbf d6,2b */ \
0x4e, 0x73 /* 3: rte */
#define PATTERN_TRACE_COOPER \
0xdb, 0x97, /* add.l d5,(a7) */ \
0x22, 0x97, /* move.l (a7),(a1) */ \
0x23, 0x57, 0x00, 0x0c, /* move.l (a7),$c(a1) */ \
0x3e, 0x93, /* move.w (a3),(a7) */ \
0x06, 0x57, 0x0b, 0xe7, /* addi.w #$be7,(a7) */ \
0x46, 0xfc, 0xff, 0xff /* move #$ffff,sr */
DECLARE_PATTERN(pattern1_cooper5,
PATTERN_ANY,
0x620, 0, 38,
PATTERN_BUFFER(
PATTERN_TVD_COOPER
)
);
DECLARE_PATTERN(pattern2_cooper5,
PATTERN_ANY,
0x136, 0, 18,
PATTERN_BUFFER(
PATTERN_TRACE_COOPER
)
);
DECLARE_PROTECTION(prot_cooper5,
"Cooper v0.5 by Cameo ^ The Replicants",
COOPER5_OFF,
PATTERNS_LIST(
&pattern1_cooper5,
&pattern2_cooper5
),
decode_cooper5,
NULL
);
/*****************************************************************************
* Cooper v0.6 by Cameo ^ The Replicants
* https://demozoo.org/productions/127892/
*****************************************************************************/
#define COOPER6_OFF 0x782
static int calc_rand_cooper6 (unsigned char* buf, uint16_t* rand)
{
uint32_t w32;
uint16_t rand16;
w32 = read32(buf - COOPER6_OFF + 0x460);
w32 ^= (uint32_t) 0x48028910;
rand16 = (uint16_t) 0x1c86 + (uint16_t) (w32 & (uint32_t) 0x0000ffff);
*rand = rand16;
return 0;
}
static int decode_cooper6 (prog_t* prog, unsigned char* buf, size_t size)
{
uint32_t key32;
uint32_t rand32;
uint16_t rand16;
uint8_t w8;
size_t i;
(void) prog;
if (calc_rand_cooper6(buf, &rand16)) {
LOG_ERROR("Cannot determine random number\n");
return 1;
}
rand32 = (uint32_t) rand16;
key32 = 0x616a6178;
for (i = 0; i < size; i += SIZE_8) {
w8 = read8(buf + i);
w8 = w8 ^ (uint8_t) (key32 & (uint32_t) 0x000000ff);
key32 = key32 + rand32;
key32 = SWAP32(key32);
key32 = key32 ^ (uint32_t) 0x43616d2b;
rand32 = rand32 + (uint32_t) 0x12345678;
rand32 = ROL32(rand32, 8);
write8(w8, buf + i);
}
return 0;
}
DECLARE_PATTERN(pattern1_cooper6,
PATTERN_ANY,
0x6d2, 0, 38,
PATTERN_BUFFER(
PATTERN_TVD_COOPER
)
);
DECLARE_PATTERN(pattern2_cooper6,
PATTERN_ANY,
0xf4, 0, 18,
PATTERN_BUFFER(
PATTERN_TRACE_COOPER
)
);
DECLARE_PROTECTION(prot_cooper6,
"Cooper v0.6 by Cameo ^ The Replicants",
COOPER6_OFF,
PATTERNS_LIST(
&pattern1_cooper6,
&pattern2_cooper6
),
decode_cooper6,
NULL
);
/*****************************************************************************
* Generic Anti-bitos decrypting routines
*****************************************************************************/
static int calc_rand_abx (unsigned char* buf, uint16_t sub_count,
uint16_t* rand)
{
uint16_t w16;
uint16_t rand16;
rand16 = read16(buf);
w16 = ((((uint16_t) 0x004f) - sub_count) << 1) ^ (uint16_t) 0x1234;
w16 = (uint16_t) ROL8((uint8_t)(w16 & (uint16_t) 0x00ff), 1);
w16 |= (uint16_t) 0x4f00;
rand16 ^= (((uint16_t) 0x601a) ^ w16);
*rand = rand16;
return 0;
}
static int decode_abx (prog_t* prog, unsigned char* buf, uint16_t sub_count,
size_t size, size_t size_orig, uint16_t reloc)
{
uint16_t key16;
uint8_t key8;
uint16_t rand16;
uint16_t w16;
uint8_t w8;
uint32_t i;
(void) prog;
if ((size > size_orig) || (size_orig - size > 8)) {
LOG_ERROR("Invalid file size=0x%x (should be close to 0x%x)\n",
(unsigned int) size, (unsigned int) size_orig);
return 1;
}
if (!reloc) {
LOG_ERROR("Original program is not a GEMDOS program\n");
return 1;
}
if (calc_rand_abx(buf, sub_count, &rand16)) {
LOG_ERROR("Cannot determine random number\n");
return 1;
}
key16 = 0x004f;
for (i = 0; i < DBF_SIZE8(size); i += (uint32_t) SIZE_8) {
w8 = read8(buf + i);
w8 ^= (uint8_t) (key16 & (uint16_t) 0x00ff);
key16 -= sub_count;
key16 = key16 << 1;
key16 ^= (uint16_t) 0x1234;
key8 = (uint8_t) (key16 & (uint16_t) 0x00ff);
key8 = ROL8(key8, 1);
key16 = (key16 & (uint16_t) 0xff00) | (uint16_t) key8;
write8(w8, buf + i);
}
for (i = 0; i < DBF_SIZE16(size); i += (uint32_t) SIZE_16) {
w16 = read16(buf + i);
w16 ^= rand16;
rand16 += 1;
write16(w16, buf + i);
}
return 0;
}
/*****************************************************************************
* Anti-bitos v1.0 by Illegal ^ The Replicants
*****************************************************************************/
#define AB100_OFF 0x432
static int decode_ab100 (prog_t* prog, unsigned char* buf, size_t size)
{
return decode_abx(prog,
buf,
2,
(size_t) (read16(buf - AB100_OFF + 0x14) << 1),
size,
read16(buf - AB100_OFF + 0x16));
}
#define PATTERN_INIT_AB \
0x41, 0xfa, 0x00, 0xa6, /* lea pc+$a8,a0 */ \
0x43, 0xfa, 0x00, 0xce, /* lea pc+$d0,a1 */ \
0x45, 0xfa, 0x00, 0x90, /* lea pc+$92,a2 */ \
0x21, 0xc8, 0x00, 0x10, /* move.l a0,$10.w */ \
0x21, 0xc9, 0x00, 0x80, /* move.l a1,$80.w */ \
0x21, 0xca, 0x00, 0x24 /* move.l a2,$24.w */
#define PATTERN_TVD_AB \
0x48, 0x50, /* pea (a0) */ \
0x20, 0x6f, 0x00, 0x06, /* movea.l 6(a7),a0 */ \
0x4e, 0x40, /* trap #0 */ \
0x4a, 0xfc, /* illegal */ \
0x20, 0x5f, /* movea.l (a7)+,a0 */ \
0x4e, 0x73, /* rte */ \
0x48, 0xe7, 0xc0, 0xc0, /* movem.l d0-d1/a0-a1,-(a7) */ \
0x22, 0x48, /* movea.l a0,a1 */ \
0x20, 0x28, 0xff, 0xf4, /* move.l -$c(a0),d0 */ \
0x22, 0x28, 0xff, 0xf0, /* move.l -$10(a0),d1 */ \
0xb1, 0x81, /* eor.l d0,d1 */ \
0x46, 0x81 /* not.l d1 */
DECLARE_PATTERN(pattern1_ab100,
PATTERN_ANY,
0x84, 0, 20,
PATTERN_BUFFER(
0x41, 0xfa, 0xff, 0x92, /* lea pc-$6c,a0 */
0x30, 0xb8, 0x82, 0x40, /* move.w $ffff8240.w,(a0) */
0x11, 0xf8, 0xfa, 0x07, 0x00, 0xf4, /* move.b $fffffa07.w,$f4.w */
0x11, 0xf8, 0xfa, 0x09, 0x00, 0xf8 /* move.b $fffffa09.w,$f8.w */
)
);
DECLARE_PATTERN(pattern2_ab100,
PATTERN_ANY,
0x9c, 0, 36,
PATTERN_BUFFER(
PATTERN_INIT_AB,
0x21, 0xfc, 0x00, 0x0f,
0x80, 0x00, 0x00, 0x30, /* move.l #$f8000,$30.w */
0x46, 0xfc, 0xa3, 0x00 /* move #$a300,sr */
)
);
DECLARE_PATTERN(pattern3_ab100,
PATTERN_ANY,
0x136, 0, 38,
PATTERN_BUFFER(
PATTERN_TVD_AB,
0x0a, 0x81, 0x12, 0x34, 0x56, 0x78 /* eori.l #$12345678,d1 */
)
);
DECLARE_PATTERN(pattern4_ab100,
PATTERN_ANY,
0x0, 0, 2,
PATTERN_BUFFER(
0x60, 0x30 /* bra.s pc+$32 */
)
);
DECLARE_PROTECTION(prot_ab100,
"Anti-bitos v1.0 by Illegal ^ The Replicants",
AB100_OFF,
PATTERNS_LIST(
&pattern1_ab100,
&pattern2_ab100,
&pattern3_ab100,
&pattern4_ab100
),
decode_ab100,
NULL
);
/*****************************************************************************
* Anti-bitos v1.4 (a & b) by Illegal ^ The Replicants
* https://demozoo.org/productions/123960/
*****************************************************************************/
#define AB140A_OFF 0x676
#define AB140B_OFF 0x670
static int decode_ab140a (prog_t* prog, unsigned char* buf, size_t size)
{
return decode_abx(prog,
buf,
2,
(size_t) (read16(buf - AB140A_OFF + 0x1a) << 1),
size,
read16(buf - AB140A_OFF + 0x1c));
}
DECLARE_PATTERN(pattern1_ab140a,
PATTERN_ANY,
0x8a, 0, 20,
PATTERN_BUFFER(
0x11, 0xfc, 0x00, 0x12, 0xfc, 0x02, /* move.b #$12,$fffffc02.w */
0x41, 0xfa, 0xff, 0x8c, /* lea pc-$72,a0 */
0x30, 0xb8, 0x82, 0x40, /* move.w $ffff8240.w,(a0) */
0x11, 0xf8, 0xfa, 0x07, 0x00, 0xf4 /* move.b $fffffa07.w,$f4.w */
)
);
DECLARE_PATTERN(pattern2_ab140a,
PATTERN_ANY,
0xa8, 0, 36,
PATTERN_BUFFER(
PATTERN_INIT_AB,
0x21, 0xfc, 0x00, 0x0f,
0x00, 0x00, 0x00, 0x30, /* move.l #$f0000,$30.w */
0x46, 0xfc, 0xa3, 0x00 /* move #$a300,sr */
)
);
DECLARE_PATTERN(pattern3_ab140a,
PATTERN_ANY,
0x142, 0, 38,
PATTERN_BUFFER(
PATTERN_TVD_AB,
0x0a, 0x81, 0x12, 0x34, 0x56, 0x78 /* eori.l #$12345678,d1 */
)
);
DECLARE_PATTERN(pattern4_ab140a,
PATTERN_ANY,
0x0, 0, 2,
PATTERN_BUFFER(
0x60, 0x36 /* bra.s pc+$38 */
)
);
DECLARE_PROTECTION_PARENT(prot_ab140a,
"Anti-bitos v1.4 by Illegal ^ The Replicants",
'a',
AB140A_OFF,
PATTERNS_LIST(
&pattern1_ab140a,
&pattern2_ab140a,
&pattern3_ab140a,
&pattern4_ab140a
),
decode_ab140a,
NULL
);
static int decode_ab140b (prog_t* prog, unsigned char* buf, size_t size)
{
return decode_abx(prog,
buf,
2,
(size_t) (read16(buf - AB140B_OFF + 0x1a) << 1),
size,
read16(buf - AB140B_OFF + 0x1c));
}
DECLARE_PATTERN(pattern1_ab140b,
PATTERN_ANY,
0x8a, 0, 20,
PATTERN_BUFFER(
0x41, 0xfa, 0xff, 0x92, /* lea pc-$6c,a0 */
0x30, 0xb8, 0x82, 0x40, /* move.w $ffff8240.w,(a0) */
0x11, 0xf8, 0xfa, 0x07, 0x00, 0xf4, /* move.b $fffffa07.w,$f4.w */
0x11, 0xf8, 0xfa, 0x09, 0x00, 0xf8 /* move.b $fffffa09.w,$f8.w */
)
);
DECLARE_PATTERN(pattern2_ab140b,
PATTERN_ANY,
0xa2, 0, 36,
PATTERN_BUFFER(
PATTERN_INIT_AB,
0x21, 0xfc, 0x00, 0x0f,
0x00, 0x00, 0x00, 0x30, /* move.l #$f0000,$30.w */
0x46, 0xfc, 0xa3, 0x00 /* move #$a300,sr */
)
);
DECLARE_PATTERN(pattern3_ab140b,
PATTERN_ANY,
0x13c, 0, 38,
PATTERN_BUFFER(
PATTERN_TVD_AB,
0x0a, 0x81, 0x12, 0x34, 0x56, 0x78 /* eori.l #$12345678,d1 */
)
);
DECLARE_PATTERN(pattern4_ab140b,
PATTERN_ANY,
0x0, 0, 2,
PATTERN_BUFFER(
0x60, 0x36 /* bra.s pc+$38 */
)
);
DECLARE_PROTECTION_VARIANT(prot_ab140b,
&prot_ab140a,
'b',
AB140B_OFF,
PATTERNS_LIST(
&pattern1_ab140b,
&pattern2_ab140b,
&pattern3_ab140b,
&pattern4_ab140b
),
decode_ab140b,
NULL
);
/*****************************************************************************
* Anti-bitos v1.6 by Illegal ^ The Replicants
* https://demozoo.org/productions/127893/
*****************************************************************************/
#define AB160_OFF 0x5fc
static int decode_ab160 (prog_t* prog, unsigned char* buf, size_t size)
{
return decode_abx(prog,
buf,
3,
(size_t) (read32(buf - AB160_OFF + 0x2e) << 1),
size,
read16(buf - AB160_OFF + 0x32));
}
DECLARE_PATTERN(pattern1_ab160,
PATTERN_ANY,
0x7e, 0, 36,
PATTERN_BUFFER(
PATTERN_INIT_AB,
0x21, 0xfc, 0x00, 0x0f,
0x00, 0x00, 0x00, 0x30, /* move.l #$f0000,$30.w */
0x46, 0xfc, 0xa3, 0x00 /* move #$a300,sr */
)
);
DECLARE_PATTERN(pattern2_ab160,
PATTERN_ANY,
0x118, 0, 38,
PATTERN_BUFFER(
PATTERN_TVD_AB,
0x0a, 0x81, 0x52, 0x45, 0x50, 0x53 /* eori.l #'REPS',d1 */
)
);
DECLARE_PATTERN(pattern3_ab160,
PATTERN_ANY,
0x0, 0, 2,
PATTERN_BUFFER(
0x60, 0x38 /* bra.s pc+$3a */
)
);
DECLARE_PROTECTION(prot_ab160,
"Anti-bitos v1.6 by Illegal ^ The Replicants",
AB160_OFF,
PATTERNS_LIST(
&pattern1_ab160,
&pattern2_ab160,
&pattern3_ab160
),
decode_ab160,
NULL
);
/*****************************************************************************
* Anti-bitos v1.61 by Illegal ^ The Replicants
*****************************************************************************/
#define AB161_OFF 0x646
static int decode_ab161 (prog_t* prog, unsigned char* buf, size_t size)
{
return decode_abx(prog,
buf,
3,
(size_t) (read32(buf - AB161_OFF + 0x32) << 1),
size,
read16(buf - AB161_OFF + 0x36));
}
DECLARE_PATTERN(pattern1_ab161,
PATTERN_ANY,
0x82, 0, 36,
PATTERN_BUFFER(
PATTERN_INIT_AB,
0x21, 0xfc, 0x00, 0x0f,
0x00, 0x00, 0x00, 0x30, /* move.l #$f0000,$30.w */
0x46, 0xfc, 0xa3, 0x00 /* move #$a300,sr */
)
);
DECLARE_PATTERN(pattern2_ab161,
PATTERN_ANY,
0x11c, 0, 38,
PATTERN_BUFFER(
PATTERN_TVD_AB,
0x0a, 0x81, 0x52, 0x45, 0x50, 0x53 /* eori.l #'REPS',d1 */
)
);
DECLARE_PATTERN(pattern3_ab161,
PATTERN_ANY,
0x0, 0, 2,
PATTERN_BUFFER(
0x60, 0x3c /* bra.s pc+$3e */
)
);
DECLARE_PROTECTION(prot_ab161,
"Anti-bitos v1.61 by Illegal ^ The Replicants",
AB161_OFF,
PATTERNS_LIST(
&pattern1_ab161,
&pattern2_ab161,
&pattern3_ab161
),
decode_ab161,
NULL
);
/*****************************************************************************
* Generic Zippy's Little Protection decrypting routines
*****************************************************************************/
static int calc_rand_zippy20x (unsigned char* buf, uint32_t* rand)
{
uint32_t rand32;
rand32 = read32(buf - 4);
rand32 = ~rand32;
rand32 ^= (uint32_t) 0x34e1fa87;
*rand = rand32;
return 0;
}
static int decode_zippy20x (prog_t* prog, unsigned char* buf, size_t size)
{
uint32_t key32;
uint32_t rand32;
uint8_t w8;
size_t i;
(void) prog;
if (calc_rand_zippy20x(buf, &rand32)) {
LOG_ERROR("Cannot determine random number\n");
return 1;
}
if (rand32 & (uint32_t) BIT(0)) {
LOG_WARN("Warning: original program runs only in supervisor mode\n");
}
key32 = 0x4c414e47;
for (i = 0; i < size; i += SIZE_8) {
w8 = read8(buf + i);
key32 = key32 ^ rand32;
rand32 = ROL32(rand32, 1);
rand32 = ~rand32;
key32 = ROR32(key32, 3);
key32 = NEG32(key32);
w8 = w8 ^ (uint8_t) (key32 & (uint32_t) 0x000000ff);
write8(w8, buf + i);
}
return 0;
}
/*****************************************************************************
* Little Protection v2.05 by Zippy ^ The Medway Boys
*****************************************************************************/
#define ZIPPY205_OFF 0x652
#define PATTERN_TVD_ZIPPY \
0x90, 0x10, /* sub.b (a0),d0 */ \
0x02, 0x40, 0x00, 0xff, /* andi.w #$ff,d0 */ \
0x51, 0xc8, 0xff, 0xfe, /* 1: dbf d0,1b */ \
0xbf, 0x95, /* eor.l d7,(a5) */ \
0xee, 0x9f, /* ror.l #7,d7 */ \
0x2c, 0x6f, 0x00, 0x02, /* movea.l 2(a7),a6 */ \
0xde, 0x10, /* add.b (a0),d7 */ \
0x40, 0xc0, /* move sr,d0 */ \
0xb1, 0x07, /* eor.b d0,d7 */ \
0xbf, 0x96, /* eor.l d7,(a6) */ \
0x2a, 0x4e, /* movea.l a6,a5 */ \
0x4e, 0x73 /* rte */
#define PATTERN_TRACE_ZIPPY \
0x21, 0xfc, 0x00, 0x07, 0x70, 0x00, \
0x00, 0x24, /* move.l #$77000,$24.w */ \
0x21, 0xfc, 0x12, 0x34, 0x56, 0x78, \
0x00, 0x10, /* move.l #$12345678,$10.w */ \
0x4c, 0xfa, 0x7f, 0xff, 0x00, 0x20, /* movem.l pc+$22,d0-a6*/ \
0x4e, 0x72, 0x23, 0x00, /* stop #$2300 */ \
0x4e, 0x72, 0x23, 0x00, /* stop #$2300 */ \
0x46, 0xfc, 0x27, 0x00, /* move #$2700,sr */ \
0x12, 0x10, /* 1: move.b (a0),d1 */ \
0x67, 0xfc, /* beq.s 1b */ \
0x90, 0x01, /* sub.b d1,d0 */ \
0xe1, 0x28, /* lsl.b d0,d0 */ \
0x4b, 0xfa, 0xff, 0xca, /* lea pc-$34,a5 */ \
0x46, 0xfc, 0xa7, 0x00 /* move #$a700,sr */
DECLARE_PATTERN(pattern1_zippy205,
PATTERN_ANY,
0xe4, 0, 30,
PATTERN_BUFFER(
PATTERN_TVD_ZIPPY
)
);
DECLARE_PATTERN(pattern2_zippy205,
PATTERN_ANY,
0x10c, 0, 50,
PATTERN_BUFFER(
PATTERN_TRACE_ZIPPY
)
);
DECLARE_PATTERN(pattern3_zippy205,
PATTERN_ANY,
0x2c, 0, 20,
PATTERN_BUFFER(
0x4d, 0xfa, 0xfe, 0xd2, /* lea pc-$12c,a6 */
0x23, 0xcf, 0x00, 0x00, 0x01, 0x04, /* move.l a7,start+$104 */
0x40, 0xc0, /* move sr,d0 */
0x08, 0x00, 0x00, 0x0d, /* btst #$d,d0 */
0x66, 0x00, 0x00, 0xc4 /* bne pc+$c6 */
)
);
DECLARE_PROTECTION(prot_zippy205,
"Little Protection v2.05 by Zippy ^ The Medway Boys",
ZIPPY205_OFF,
PATTERNS_LIST(
&pattern1_zippy205,
&pattern2_zippy205,
&pattern3_zippy205
),
decode_zippy20x,
NULL
);
/*****************************************************************************
* Little Protection v2.06 by Zippy ^ The Medway Boys
*****************************************************************************/
#define ZIPPY206_OFF 0x64e
DECLARE_PATTERN(pattern1_zippy206,
PATTERN_ANY,
0xe0, 0, 30,
PATTERN_BUFFER(
PATTERN_TVD_ZIPPY
)
);
DECLARE_PATTERN(pattern2_zippy206,
PATTERN_ANY,
0x108, 0, 50,
PATTERN_BUFFER(
PATTERN_TRACE_ZIPPY
)
);
DECLARE_PATTERN(pattern3_zippy206,
PATTERN_ANY,
0x2c, 0, 20,
PATTERN_BUFFER(
0x4d, 0xfa, 0xfe, 0xd2, /* lea pc-$12c,a6 */
0x4b, 0xfa, 0x00, 0xce, /* lea pc+$d0,a5 */
0x2a, 0x8f, /* move.l a7,(a5) */
0x40, 0xc0, /* move sr,d0 */
0x08, 0x00, 0x00, 0x0d, /* btst #$d,d0 */
0x66, 0x00, 0x00, 0xc0 /* bne pc+$c2 */
)
);
DECLARE_PROTECTION(prot_zippy206,
"Little Protection v2.06 by Zippy ^ The Medway Boys",
ZIPPY206_OFF,
PATTERNS_LIST(
&pattern1_zippy206,
&pattern2_zippy206,
&pattern3_zippy206
),
decode_zippy20x,
NULL
);
/*****************************************************************************
* Lock-o-matic v1.3 by Yoda ^ The Marvellous V8
*****************************************************************************/
#define LOCKOMATIC_OFF 0x3fc
static void trace_lockomatic (unsigned char* tr_start, uint32_t pc_ret,
uint32_t* d0, uint32_t* d7, uint32_t* a4)
{
uint32_t tmp_d0 = *d0;
uint32_t tmp_d7 = *d7;
uint32_t tmp_a4 = *a4;
unsigned int i;
for (i = 0; i < 76; i += (unsigned int) SIZE_32) {
tmp_d7 = read32(tr_start + i);
tmp_d0 ^= tmp_d7;
tmp_d0 += 3;
}
tmp_a4 += 2;
tmp_d7 = tmp_a4;
tmp_d0 ^= tmp_d7;
tmp_d7 = pc_ret;
tmp_d0 ^= tmp_d7;
*d0 = tmp_d0;
*d7 = tmp_d7;
*a4 = tmp_a4;
}
static int calc_rand_lockomatic (unsigned char* buf, uint32_t* rand)
{
unsigned char* tr_start = buf - LOCKOMATIC_OFF + 0xfa;
uint32_t d0;
uint32_t d2;
uint32_t d7;
uint32_t a4;
unsigned int i;
write16(0x0851, tr_start + 4);
write16(0x4e73, tr_start + 56);
d0 = 0x49fafffe;
d7 = 0x0;
a4 = 0x8;
for (i = 0; i <= 0x23; i++) {
trace_lockomatic(tr_start, 0x0e, &d0, &d7, &a4);
d2 = 0x226f0002;
trace_lockomatic(tr_start, 0x14, &d0, &d7, &a4);
d2 = (d2 & (uint32_t) 0xffff0000) | (d7 & (uint32_t) 0x0000ffff);
trace_lockomatic(tr_start, 0x16, &d0, &d7, &a4);
d0 = SWAP32(d0);
trace_lockomatic(tr_start, 0x18, &d0, &d7, &a4);
d0 = d0 ^ (d2 & (uint32_t) 0x000000ff);
trace_lockomatic(tr_start, 0x1a, &d0, &d7, &a4);
}
trace_lockomatic(tr_start, 0x1e, &d0, &d7, &a4);
d0 ^= d7;
d0 ^= (uint32_t) 0x4ed61234;
d0 ^= (uint32_t) 0xfff2777f;
d0 ^= (uint32_t) 0xb50051cb;
d0 ^= (uint32_t) 0x0000007f;
d0 ^= d2;
d0 ^= (uint32_t) 0x77232439;
*rand = d0;
return 0;
}
static uint32_t decode_routs_lockomatic (unsigned char* buf, unsigned int size,
uint32_t rand32)
{
uint32_t w32;
unsigned int i;
for (i = 0; i < size; i += (unsigned int) SIZE_32) {
w32 = read32(buf + i);
w32 ^= rand32;
rand32 += 3;
write32(w32, buf + i);
}
return rand32;
}
static int decode_lockomatic (prog_t* prog, unsigned char* buf, size_t size)
{
prog_hdr_t* hdr = (prog_hdr_t*) buf;
uint32_t key32;
uint32_t rand32;
uint32_t szt32;
uint32_t szd32;
uint32_t szb32;
uint32_t w32;
size_t i;
(void) prog;
key32 = read32(buf - LOCKOMATIC_OFF + 0xfa + 0x3a);
if (calc_rand_lockomatic(buf, &rand32)) {
LOG_ERROR("Cannot determine random number\n");
return 1;
}
key32 ^= rand32;
rand32 = decode_routs_lockomatic(buf - LOCKOMATIC_OFF + 0x16c, 0x284,
rand32);
rand32 = decode_routs_lockomatic(buf - LOCKOMATIC_OFF + 0x202, 0x1ee,
0x88dd6a16);
key32 ^= rand32;
key32 ^= (uint32_t) 0x00030000;
(void) decode_routs_lockomatic(buf - LOCKOMATIC_OFF + 0x2c4, 0x12c, key32);
key32 = key32 >> 16;
key32 ^= (uint32_t) 0x1bcc8462;
for (i = 0; i < size; i += SIZE_32) {
w32 = read32(buf + i);
w32 ^= key32;
key32 += 3;
key32 = ROL32(key32, 5);
write32(w32, buf + i);
}
szt32 = read32(buf - LOCKOMATIC_OFF + 0x320);
write32(szt32, (unsigned char*)&hdr->ph_tlen);
szd32 = read32(buf - LOCKOMATIC_OFF + 0x324);
write32(szd32, (unsigned char*)&hdr->ph_dlen);
szb32 = read32(buf - LOCKOMATIC_OFF + 0x328);
write32(szb32, (unsigned char*)&hdr->ph_blen);
write32(0x0, (unsigned char*)&hdr->ph_slen);
write32(0x0, (unsigned char*)&hdr->ph_res1);
write32(0x0, (unsigned char*)&hdr->ph_prgflags);
write16(0x0, (unsigned char*)&hdr->ph_absflag);
return 0;
}
DECLARE_PATTERN(pattern1_lockomatic,
PATTERN_ANY,
0xda, 0, 90,
PATTERN_BUFFER(
0x49, 0xfa, 0xff, 0xfe, /* lea pc,a4 */
0x77, 0x23, /* dc.w $7723 */
0x24, 0x39, 0x00, 0x00, 0x03, 0xee, /* 1: move.l $3ee,d2 */
0x34, 0x07, /* move.w d7,d2 */
0x48, 0x40, /* swap d0 */
0xb5, 0x00, /* eor.b d2,d0 */
0x51, 0xcb, 0xff, 0xf2, /* dbf d3,1b */
0x77, 0x7f, /* dc.w $777f*/
0x4e, 0xd6, /* jmp (a6) */
0x12, 0x34, 0x00, 0x00, 0x03, 0xb0, /* data */
0x43, 0xf8, 0x00, 0x08, /* lea $8.w,a1 */
0x08, 0x50, 0x36, 0x00, /* bchg #0,(a0) */
0x41, 0xfa, 0xff, 0xf6, /* lea pc-$8,a0 */
0x43, 0xfa, 0x00, 0x3e, /* lea pc+$40,a1 */
0x2e, 0x18, /* 2: move.l (a0)+,d7 */
0xbf, 0x80, /* eor.l d7,d0 */
0x56, 0x80, /* addq.l #3,d0 */
0xb1, 0xc9, /* cmpa.l a1,a0 */
0x65, 0x00, 0xff, 0xf6, /* bcs 2b */
0x54, 0x8c, /* addq.l #2,a4 */
0x2e, 0x0c, /* move.l a4,d7 */
0xbf, 0x80, /* eor.l d7,d0 */
0x2e, 0x2f, 0x00, 0x02, /* move.l 2(a7),d7 */
0xbf, 0x80, /* eor.l d7,d0 */
0x21, 0xfc, 0x00, 0x00, 0x03, 0xee,
0x00, 0x10, /* move.l #$3ee,$10.w */
0x21, 0xfc, 0x00, 0x00, 0x03, 0xb0,
0x00, 0x24, /* move.l #$3b0,$24.w */
0x4e, 0x75 /* rts */
)
);
DECLARE_PATTERN(pattern2_lockomatic,
PATTERN_ANY,
LOCKOMATIC_OFF, 0, 28,
PATTERN_BUFFER(
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00
)
);
DECLARE_PROTECTION(prot_lockomatic,
"Lock-o-matic v1.3 by Yoda ^ The Marvellous V8",
LOCKOMATIC_OFF,
PATTERNS_LIST(
&pattern1_lockomatic,
&pattern2_lockomatic
),
decode_lockomatic,
NULL
);
/*****************************************************************************
* CID Encrypter v1.0bp by Mad + RAM ^ Criminals In Disguise (CID)
*****************************************************************************/
#define CID10_OFF 0x680
static int decode_cid10 (prog_t* prog, unsigned char* buf, size_t size)
{
uint16_t key16_1;
uint16_t key16_2;
uint16_t w16;
size_t i;
(void) prog;
size = (size_t) read32(buf - CID10_OFF + 0x6);
key16_1 = read16(buf - CID10_OFF + 0x216);
key16_2 = read16(buf - CID10_OFF + 0x218);
for (i = 0; i < size; i += SIZE_16) {
w16 = read16(buf + i);
w16 ^= key16_1;
w16 ^= key16_2;
key16_2 += key16_1;
key16_1 += key16_2;
write16(w16, buf + i);
}
return 0;
}
DECLARE_PATTERN(pattern1_cid10,
PATTERN_ANY,
0xa6, 0, 34,
PATTERN_BUFFER(
0x13, 0xfc, 0x00, 0x0a,
0xff, 0xff, 0xfa, 0x21, /* move.b #$a,$fffffa21 */
0x13, 0xfc, 0x00, 0x03,
0xff, 0xff, 0xfa, 0x1b, /* move.b #3,$fffffa1b */
0x46, 0xfc, 0x25, 0x00, /* move #$2500,sr */
0x48, 0x79, 0x00, 0x00, 0x00, 0xf2, /* pea start+$f2 */
0x23, 0xdf, 0x00, 0x00, 0x00, 0x10, /* move.l (a7)+,$10 */
0x4a, 0xfc /* illegal */
)
);
DECLARE_PATTERN(pattern2_cid10,
PATTERN_ANY,
0x4c4, 0, 54,
PATTERN_BUFFER(
0x41, 0xf9, 0x00, 0x00, 0x06, 0x80, /* lea start+$680,a0 */
0x20, 0x39, 0x00, 0x00, 0x00, 0x06, /* move.l start+$6,d0 */
0xe2, 0x88, /* lsr.l #1,d0 */
0x32, 0x39, 0x00, 0x00, 0x00, 0x0a, /* move.w pc+$a,d1 */
0x34, 0x39, 0x00, 0x00, 0x02, 0x16, /* move.w pc+$216,d2 */
0x36, 0x39, 0x00, 0x00, 0x02, 0x18, /* move.w pc+$218,d3 */
0x23, 0xfc, 0x00, 0x00, 0x04, 0xf6,
0x00, 0x00, 0x00, 0x10, /* move.l #start+$4f6,$10 */
0x22, 0x7c, 0x00, 0x00, 0x00, 0x00, /* movea.l #0,a1 */
0x60, 0x76, /* bra.s pc+$78 */
0x30, 0xc7, /* move.w d7,(a0)+ */
0xce, 0x41 /* and.w d1,d7 */
)
);
DECLARE_PATTERN(pattern3_cid10,
PATTERN_ANY,
0x560, 0, 28,
PATTERN_BUFFER(
0x53, 0x80, /* subq.l #1,d0 */
0x2f, 0x7c, 0x00, 0x00, 0x05, 0x78,
0x00, 0x02, /* move.l #start+$578,2(a7) */
0x4e, 0x73, /* rte */
0x3e, 0x10, /* 1: move.w (a0),d7 */
0xb5, 0x47, /* eor.w d2,d7 */
0xb7, 0x47, /* eor.w d3,d7 */
0xd6, 0x42, /* add.w d2,d3 */
0xd4, 0x43, /* add.w d3,d2 */
0x4a, 0xfc, /* illegal */
0x4a, 0x80, /* tst.l d0 */
0x66, 0xf0 /* bne.s 1b */
)
);
DECLARE_PROTECTION(prot_cid10,
"CID Encrypter v1.0bp by Mad + RAM ^ Criminals In Disguise",
CID10_OFF,
PATTERNS_LIST(
&pattern1_cid10,
&pattern2_cid10,
&pattern3_cid10
),
decode_cid10,
NULL
);
/*****************************************************************************
*
* Copylock Protection System by Rob Northen - Generic helper routines
*
* https://en.wikipedia.org/wiki/Rob_Northen_copylock
*
* Copylock systems can be divided into 2 series:
* - Copylock systems series 1, created in 1988.
* - Copylock systems series 2, created in 1989.
*
* Each series can be subdivided into 2 types:
* - The wrapper type: self-decrypting program.
* - The internal type: self-decrypting routine inside a host program.
*
* Both series use the "Trace Vector Decoder" (TVD) technique to obfuscate
* the protection code. Every instruction is decrypted, run and then encrypted
* again before moving on to the next instruction:
* https://en.wikipedia.org/wiki/Trace_vector_decoder
*
* - Series 1 uses a single and static (in place) TVD routine.
* Each instruction is decrypted by XOR-ing it with the preceding encrypted
* instruction.
* http://www.atari-wiki.com/index.php/Rob_Northern_Decrypted1
*
* - Series 2 uses two different TVD routines, which are dynamically installed
* (pushed onto the stack).
* The first TVD routine decrypts each instruction by XOR-ing it with a key
* dynamically computed from registers sr, d1 and d2.
* Therefore the decoding of a new instruction depends on the result of the
* execution of the previous instructions.
* This TVD routine is only used for sequential instructions. It cannot be
* used for loops.
* The second TVD routine decrypts each instruction by XOR-ing it with a key
* computed from a magic value and the preceding encrypted instruction.
* This TVD routine is used for complex code (with loops), such as the
* key disk reading.
*
* Both series check if the exception vectors have been modified to prevent
* the execution under a debugger.
*
* Both series read a key disk to compute a serial key in order to:
* - decrypt the original unprotected program (wrapper type).
* - return that serial key to the caller of the protected routine
* (internal type), so it can be checked on return or later.
*
* The serial key may also be used for extra tricks: stored in memory for
* deferred checking, used to compute an extra magic key (also stored in
* memory), used to decrypt portions of memory...
*
* In both series:
* - The encrypted code of the internal type is in charge of reading the
* key disk and optionally of performing some extra tricks (vectors checking,
* special serial key usage as described above).
* - The encrypted code of the wrapper type is similar to that of the internal
* type, but in addition:
* + The serial key is used to decrypt the original (wrapped) program,
* which is installed to its final destination and then executed.
* That program may be a GEMDOS program (it is then relocated by the
* protection code) or a raw binary program.
* + Some extra encrypted code is executed at the beginning of the
* protection, before reading the key disk.
* In series 1, it consists in nested decryption loops (each loop decrypts
* the rest of the protection).
* In series 2, it consists in a large number of sequential encrypted
* instructions which perform checks on the TDV routine, the SR value...
* Such extra encrypted code is of no use other than making the protection
* more difficult to trace under a debugger.
*
* Dec0de handles Rob Northen Copylock Systems as follows:
* - When a wrapper type is provided, dec0de extracts the original unprotected
* program and provides useful details about the Copylock protection: the
* serial number and the memory address it is saved to, the use of extra
* tricks in the protection (extra magic value, special serial key usage).
* Such details may be needed to properly crack the protected software.
* - When an internal type is provided, dec0de only provides the details needed
* to crack the protection (such as the serial number and how it is used).
*
* To this end, dec0de works as follows:
* - It first performs static analysis of the protection in order to determine
* the location of the different parts of the protection and its behavior.
* - It then performs dynamic (run-time) analysis of the protection in order
* to get the serial key and, in case of a wrapper type, to decrypt the
* protected program and to determine the destination where it will be
* executed.
*
* The dynamic analysis can only be performed on an Atari ST (protection code
* must be partially executed). Therefore, Copylock protections can be removed
* only if dec0de is run on a real or emulated Atari ST.
*
* When run on Linux, Mac OS or Windows, dec0de provides as much information
* as possible, but the decryption process is skipped.
*
*****************************************************************************/
#define SERIAL_USAGE_NONE_ROBN 0x00
#define SERIAL_USAGE_DECODE_PROG_ROBN 0x01
#define SERIAL_USAGE_RETURN_ROBN 0x02
#define SERIAL_USAGE_SAVE_MEM_ROBN 0x04
#define SERIAL_USAGE_MAGIC_MEM_ROBN 0x08
#define SERIAL_USAGE_EOR_MEM_ROBN 0x10
#define SERIAL_USAGE_OTHER_MEM_ROBN 0x20
#define SERIAL_USAGE_UNKNOWN_ROBN 0x40
/*
* Static and dynamic/run-time information about a Rob Northen Protection
* system.
*/
typedef struct info_robn_t {
uint32_t magic32;
/*
* Static info: location of the different parts of the protection.
*/
ssize_t prog_off;
ssize_t start_off;
ssize_t pushtramp_off;
ssize_t decode_off;
ssize_t reloc_off;
ssize_t vecs_off;
ssize_t keydisk_off;
ssize_t serial_off;
size_t subrout_sz;
int serial_usage;
/*
* Dynamic (run-time) info: serial key value, final program destination...
*/
int prot_run;
int keydisk_hit;
int serial_valid;
int magic_valid;
int dstexec_valid;
uint32_t serial;
uint32_t* serial_dst_addr;
uint32_t magic;
uint32_t* magic_dst_addr;
void* dst_addr;
size_t entry_off;
size_t prog_len;
size_t zeroes_len;
} info_robn_t;
/*
* Serial key usage.
*/
static struct {
int flag;
const char* str;
} serial_usage_flag2str[] = {
{ SERIAL_USAGE_DECODE_PROG_ROBN, "Program dec0ding", },
{ SERIAL_USAGE_RETURN_ROBN, "Returned to the caller", },
{ SERIAL_USAGE_SAVE_MEM_ROBN, "Saved in memory", },
{ SERIAL_USAGE_MAGIC_MEM_ROBN, "Turned into a magic", },
{ SERIAL_USAGE_EOR_MEM_ROBN, "Xor-ed in memory", },
{ SERIAL_USAGE_OTHER_MEM_ROBN, "External memory dec0ding", },
{ SERIAL_USAGE_UNKNOWN_ROBN, "Unknown", },
{ 0, NULL, },
};
/*
* Initialize the static/run-time info.
*/
static void init_info_robn (info_robn_t* info)
{
memset(info, 0, sizeof(info_robn_t));
info->prog_off = -1;
info->start_off = -1;
info->pushtramp_off = -1;
info->decode_off = -1;
info->reloc_off = -1;
info->vecs_off = -1;
info->keydisk_off = -1;
info->serial_off = -1;
info->serial_usage = SERIAL_USAGE_NONE_ROBN;
}
/*
* Dump the static/run-time info.
* Works for both series and both types.
*/
static int print_info_robn (info_robn_t* info, const unsigned char* buf)
{
unsigned int i;
if (info) {
PP_NEWLINE();
LOG_INFO("Protection information:\n");
LOG_INFO("Vectors anti-hijacking ... %s\n",
(info->vecs_off >= 0) ? "Yes" : "No");
LOG_INFO("Key disk usage ........... %s\n",
(info->keydisk_off >= 0) ? "Yes" : "No");
if (info->keydisk_off >= 0) {
const char* m = "Serial usage ............. %s\n";
const char* n = " %s\n";
for (i = 0; (serial_usage_flag2str[i].str != NULL); i++) {
if (info->serial_usage & serial_usage_flag2str[i].flag) {
LOG_INFO(m, serial_usage_flag2str[i].str);
m = n;
}
}
if (info->serial_valid) {
if (info->serial != 0) {
LOG_INFO("Serial number ............ $%08x\n",
info->serial);
} else {
LOG_INFO("Serial number ............ Invalid\n");
}
} else {
LOG_INFO("Serial number ............ %s\n",
info->keydisk_hit ? "Undefined" : "Unread");
}
if (info->serial_dst_addr) {
LOG_INFO("Serial dest. address ..... $%zx\n",
(size_t) info->serial_dst_addr);
}
if (info->magic_valid) {
LOG_INFO("Magic number ............. $%08x\n",
info->magic);
if (info->magic_dst_addr) {
LOG_INFO("Magic dest. address ...... $%zx\n",
(size_t) info->magic_dst_addr);
}
}
}
LOG_INFO("Enc0ded program type ..... %s\n",
(info->decode_off < 0) ? "None" :
((info->prog_off < 0) ? "Unknown" :
((info->reloc_off >= 0) ? "GEMDOS" : "Binary")));
if (info->decode_off < 0) {
LOG_INFO("Protected subroutine ..... %s\n",
(info->subrout_sz != 0) ? "Yes" : "No");
LOG_INFO("Resume code offset ....... 0x%zx\n",
(size_t) info->prog_off);
}
if (info->dstexec_valid) {
if (info->dst_addr) {
LOG_INFO("Dest. address ............ $%zx\n",
(size_t) info->dst_addr);
} else {
LOG_INFO("Dest. address ............ Load address\n");
}
LOG_INFO("Entry offset ............. $%zx\n",
info->entry_off);
LOG_INFO("Program length ........... $%zx\n",
info->prog_len);
LOG_INFO("Zeroes length ............ $%zx\n",
info->zeroes_len);
}
#ifdef DEBUG
LOG_INFO("Magic32 .................. $%08x\n", info->magic32);
#endif
if (info->decode_off < 0) {
PP_NEWLINE();
LOG_WARN("This Copylock Protection System contains "
"no enc0ded program\n");
if (info->serial_off < 0) {
PP_NEWLINE();
LOG_WARN("This Copylock Protection System uses "
"the serial number %s\n"
"Further (manual) investigation is needed\n",
info->serial_usage & SERIAL_USAGE_OTHER_MEM_ROBN ?
"to decrypt external data" : "in an unknown way");
return 1;
}
}
}
#if defined (TARGET_ST)
ASSERT(info && info->prot_run);
#else
if (!info || !info->prot_run) {
PP_NEWLINE();
LOG_WARN(
"%s, "
"the native protection code has to be partially executed\n"
"You must therefore run the " DEC0DE_NAME " tool on Atari ST\n",
(!info || (info->decode_off >= 0)) ?
"To dec0de this Copylock Protection System" :
"To determine the serial number");
return 1;
}
#endif
if (info->decode_off < 0) {
if (info->serial_valid && (info->serial == 0)) {
PP_NEWLINE();
LOG_ERROR("Serial reading failed, "
"original key disk is required!\n");
}
return 1;
}
if (/*
* Unknown/binary prog & wrong keydisk (serial is valid,
* but equal to zero).
*/
(((info->prog_off < 0) || (info->reloc_off < 0)) &&
info->serial_valid && (info->serial == 0))
||
/*
* GEMDOS prog & wrong keydisk (keydisk was used, but prog header
* was not correctly decrypted).
*/
((info->reloc_off >= 0) && info->keydisk_hit &&
buf && (read16(buf) != (uint16_t) 0x601a))
) {
PP_NEWLINE();
LOG_ERROR("Program dec0ding failed, "
"original key disk is required!\n");
return 1;
}
PP_NEWLINE();
return 0;
}
/*
* Check the size of a Rob Northen protection.
*/
static int check_size_robn (prog_t* prog, info_robn_t* info)
{
ssize_t sz = (ssize_t) prog->size;
ASSERT(info->prog_off);
if (/* Internal protection */
(info->decode_off < 0) && (info->prog_off > sz)) {
LOG_ERROR("Truncated protection code\n");
return 1;
}
if (/* Wrapped binary program */
((info->decode_off >= 0) && (info->reloc_off < 0) &&
(info->prog_off >= sz)) ||
/* Wrapped GEMDOS program */
((info->reloc_off >= 0) &&
(info->prog_off + (ssize_t) sizeof(prog_hdr_t) >= sz))) {
LOG_ERROR("Truncated protected program\n");
return 1;
}
return 0;
}
/*****************************************************************************
*
* Copylock Protection System series 1 (1988) by Rob Northen
*
* Static analysis of the protection.
*
* Some well-known code patterns are searched in the protection.
* It can be done for the internal type only, for which the decryption
* scheme is simple.
* It cannot be done for the wrapper type which uses nested decryption loops.
* Therefore the wrapper type requires dynamic (run-time) analysis (available
* on Atari ST only).
*
*****************************************************************************/
#define ROBN88_OFF 0x0
#define PROT_FLAGS_ROBN88(_p) ((int)(size_t)((_p)->private))
#define PROT_PRIV_ROBN88(_f) ((void*)(size_t)(_f))
#define PROT_TVD_FSHARK_ROBN88 (1 << 0)
#define PROT_TVD_COMMON_ROBN88 (1 << 1)
#define PROT_TVD_MASK_ROBN88 (PROT_TVD_FSHARK_ROBN88 | \
PROT_TVD_COMMON_ROBN88)
#define PROT_FORCE_SUP_ROBN88 (1 << 2)
#if defined (TARGET_ST)
static int decode_native_robn88 (prog_t* prog, info_robn_t* info);
#endif
/*
* Simple decryption scheme of the internal type: each instruction is
* encrypted/decrypted by XOR-ing it with the preceding instruction.
*/
static inline uint32_t get_decoded_intr_robn88 (unsigned char* buf)
{
uint32_t key32;
uint32_t w32;
key32 = read32(buf - SIZE_32);
key32 = ~key32;
key32 = SWAP32(key32);
w32 = read32(buf);
w32 ^= key32;
return w32;
}
/*
* Search for a code pattern in a portion of the protection.
*/
static ssize_t get_pattern_offset_robn88 (unsigned char* buf,
size_t offset,
ssize_t size,
uint16_t* pattern,
unsigned int wcount)
{
uint32_t w32;
uint16_t w16;
unsigned int i;
size = (size + (ssize_t) (SIZE_16 - 1)) & (ssize_t) ~(SIZE_16 - 1);
size -= (ssize_t) (SIZE_16 * wcount);
for (; size >= 0; offset += SIZE_16, size -= (ssize_t) SIZE_16) {
w32 = get_decoded_intr_robn88(buf + offset);
w16 = (uint16_t) (w32 >> 16);
if (pattern[0] && (pattern[0] != w16)) {
continue;
}
if (wcount == 1) {
return (ssize_t) offset;
}
w16 = (uint16_t) (w32 & (uint32_t) 0x0000ffff);
if (pattern[1] != w16) {
continue;
}
for (i = 2; i < wcount; i++) {
if (pattern[i] != read16(buf + offset + (SIZE_16 * i))) {
break;
}
}
if (i == wcount) {
return (ssize_t) offset;
}
}
return (ssize_t) -1;
}
/*
* First perform static analysis (internal type only), and then call
* decode_native_robn88() to perform dynamic (run-time) analysis.
* If run on a non-ST platform, the function stops after the static analysis
* and dumps the collected information (if available).
*/
static int decode_robn88 (prog_t* prog, unsigned char* buf, size_t size)
{
/*
* Keydisk usage, specific pattern.
* st $43e.l
*/
static uint16_t keydisk_pattern[] = { 0x50f9, 0x0000, 0x043e, };
/*
* Return from an internal encrypted routine, specific pattern.
* move.l a0,2(sp)
*/
static uint16_t resume_pattern[] = { 0x2f48, 0x0002, };
/*
* Exception vectors checking, specific pattern.
* instr #$fc0000,operand
*/
static uint16_t vecs_pattern[] = { 0x0000, 0x00fc, 0x0000, };
/*
* Serial key saving in memory, specific pattern.
* move.l d0,$1c(a0)
*/
static uint16_t serial_pattern[] = { 0x2140, 0x001c, };
info_robn_t info;
ssize_t sz;
ssize_t offset;
ssize_t resume_off;
uint32_t w32;
int16_t s16;
ASSERT(buf == prog->text);
init_info_robn(&info);
offset = (ssize_t) (prog->prot->patterns[4]->eoffset +
prog->prot->patterns[4]->ecount);
buf += offset;
size -= (size_t) offset;
if ((ssize_t) size <= (ssize_t) (SIZE_16 * 8)) {
LOG_ERROR("Truncated protection code\n");
return 1;
}
sz = (ssize_t) ((size > 4096) ? 4096 : size);
info.keydisk_off = get_pattern_offset_robn88(buf,
0,
sz,
keydisk_pattern,
3);
if (info.keydisk_off >= 0) {
/*
* Internal type detected. Static analysis is possible.
*/
/*
* Locate the end of the protection code.
*/
resume_off = get_pattern_offset_robn88(buf,
(size_t) info.keydisk_off,
sz - info.keydisk_off,
resume_pattern,
2);
if (resume_off >= 0 ) {
w32 = get_decoded_intr_robn88(buf + resume_off - SIZE_32);
/* lea resume_address(pc),a0 */
s16 = (int16_t) (w32 >> 16);
if (s16 == 0x41fa) {
s16 = (int16_t) (w32 & (uint32_t) 0x0000ffff);
info.prog_off = (ssize_t) s16 + resume_off - (ssize_t) SIZE_16;
}
}
if (info.prog_off < 0) {
LOG_ERROR("Cannot locate the end of the protection code\n");
goto unsupp;
}
/*
* Search for vectors checking.
*/
info.vecs_off = get_pattern_offset_robn88(buf,
0,
resume_off,
vecs_pattern,
3);
/*
* Determine how the serial number is used.
*/
info.serial_off = get_pattern_offset_robn88(buf,
0,
resume_off,
serial_pattern,
2);
if (info.serial_off >= 0) {
/*
* Serial number is saved into memory (usually at address $24)
* and it is returned to the caller.
*/
info.serial_usage = SERIAL_USAGE_RETURN_ROBN;
info.serial_usage |= SERIAL_USAGE_SAVE_MEM_ROBN;
info.serial_dst_addr = (void*) (size_t) (8 + serial_pattern[1]);
} else {
/*
* Unknown serial number usage.
*/
info.serial_usage = SERIAL_USAGE_UNKNOWN_ROBN;
}
info.keydisk_off += offset;
info.prog_off += offset;
if (info.vecs_off >= 0) {
info.vecs_off += offset;
}
if (info.serial_off >= 0) {
info.serial_off += offset;
}
if (check_size_robn(prog, &info)) {
return 1;
}
} else {
info.decode_off = 0;
}
#if defined (TARGET_ST)
if ((info.decode_off >= 0) || (info.serial_off >= 0)) {
/*
* Continue with dynamic analysis.
*/
return decode_native_robn88(prog, &info);
}
#endif
return print_info_robn(info.decode_off < 0 ? &info : NULL, NULL);
unsupp:
LOG_ERROR("This variant of the Copylock Protection System "
"is not supported\n");
return 1;
}
/*
* Rob Northen protection code has evolved slightly over time. In particular
* the protection prolog (non-encrypted code) which is parsed by dec0de to
* automatically recognize the protection has changed a bit multiple times.
* Here are the known protection prolog variants of the series 1.
*/
#define PATTERN_SWITCHSUPILL_ROBN88 /* 22 bytes */ \
0x48, 0x7a, 0x00, 0x0e, /* pea 1f(pc) */ \
0x2f, 0x3c, 0x00, 0x05, 0x00, 0x04, /* move.l #$50004,-(a7) */ \
0x4e, 0x4d, /* trap #$d */ \
0x50, 0x8f, /* addq.l #8,a7 */ \
0x4a, 0xfc, /* illegal */ \
0x23, 0xc0, 0x00, 0x00, 0x00, 0x10 /* 1: move.l d0,$10 */
#define PATTERN_SWITCHSUPPRIV1_ROBN88 /* 30 bytes */ \
0x48, 0x7a, 0x00, 0x14, /* pea 1f(pc) */ \
0x2f, 0x3c, 0x00, 0x05, 0x00, 0x08, /* move.l #$50008,-(a7) */ \
0x4e, 0x4d, /* trap #$d */ \
0x50, 0x8f, /* addq.l #8,a7 */ \
0x40, 0xc1, /* move sr,d1 */ \
0x00, 0x7c, 0x20, 0x00, /* ori.w #$2000,sr */ \
0x5d, 0x8f, /* subq.l #6,a7 */ \
0x5c, 0x8f, /* 1: addq.l #6,a7 */ \
0x23, 0xc0, 0x00, 0x00, 0x00, 0x20 /* move.l d0,$20 */
#define PATTERN_SWITCHSUPPRIV2_ROBN88 /* 28 bytes */ \
0x48, 0x7a, 0x00, 0x12, /* pea 1f(pc) */ \
0x2f, 0x3c, 0x00, 0x05, 0x00, 0x08, /* move.l #$50008,-(a7) */ \
0x4e, 0x4d, /* trap #$d */ \
0x50, 0x8f, /* addq.l #8,a7 */ \
0x00, 0x7c, 0x20, 0x00, /* ori.w #$2000,sr */ \
0x5d, 0x8f, /* subq.l #6,a7 */ \
0x5c, 0x8f, /* 1: addq.l #6,a7 */ \
0x23, 0xc0, 0x00, 0x00, 0x00, 0x20 /* move.l d0,$20 */
#define PATTERN_TRIGILL_ROBN88(_o1, _o2)/* 10 bytes */ \
0x41, 0xfa, _o1, _o2, /* lea pc+2+_o1_o2,a0 */ \
0x23, 0xc8, 0x00, 0x00, 0x00, 0x10 /* move.l a0,$10 */
#define PATTERN_MASK_TRIGILL_ROBN88(_o1, _o2) \
0xff, 0xff, _o1, _o2, \
0xff, 0xff, 0xff, 0xff, 0xff, 0xff
#define PATTERN_ILLVEC1_ROBN88(_o1, _o2, _o3, _o4) /* 58 bytes */ \
0x48, 0xe7, 0x80, 0xc0, /* movem.l d0/a0-a1,-(a7) */ \
0x41, 0xfa, 0x00, 0x34, /* lea 1f(pc),a0 */ \
0x23, 0xc8, 0x00, 0x00, 0x00, 0x24, /* move.l a0,$24 */ \
0x41, 0xfa, _o1, _o2, /* lea pc+2+_o1_o2,a0 */ \
0x23, 0xc8, 0x00, 0x00, 0x00, 0x20, /* move.l a0,$20 */ \
0x06, 0xaf, 0x00, 0x00, 0x00, 0x02, \
0x00, 0x0e, /* addi.l #2,$e(a7) */ \
0x00, 0x2f, 0x00, 0x07, 0x00, 0x0c, /* ori.b #7,$c(a7) */ \
0x08, 0x6f, 0x00, 0x07, 0x00, 0x0c, /* bchg #7,$c(a7) */ \
0x43, 0xfa, _o3, _o4, /* lea pc+2+_o3_o4,a1 */ \
0x67, 0x1a, /* beq.s 3f */ \
0x20, 0x51, /* movea.l (a1),a0 */ \
0x20, 0xa9, 0x00, 0x04, /* move.l 4(a1),(a0) */ \
0x60, 0x26 /* bra.s 4f */
#define PATTERN_MASK_ILLVEC1_ROBN88(_o1, _o2, _o3, _o4) \
0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, _o1, _o2, \
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, \
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, _o3, _o4, \
0xff, 0xff, \
0xff, 0xff, \
0xff, 0xff, 0xff, 0xff, \
0xff, 0xff
#define PATTERN_ILLVEC2_ROBN88(_o1, _o2) /* 46 bytes */ \
0x48, 0xe7, 0x80, 0xc0, /* movem.l d0/a0-a1,-(a7) */ \
0x41, 0xfa, 0x00, 0x28, /* lea 1f(pc),a0 */ \
0x23, 0xc8, 0x00, 0x00, 0x00, 0x24, /* move.l a0,$24 */ \
0x41, 0xfa, _o1, _o2, /* lea pc+2+_o1_o2,a0 */ \
0x23, 0xc8, 0x00, 0x00, 0x00, 0x20, /* move.l a0,$20 */ \
0x00, 0x2f, 0x00, 0x07, 0x00, 0x0c, /* ori.b #7,$c(a7) */ \
0x08, 0x6f, 0x00, 0x07, 0x00, 0x0c, /* bchg #7,$c(a7) */ \
0x06, 0xaf, 0x00, 0x00, 0x00, 0x02, \
0x00, 0x0e, /* addi.l #2,$e(a7) */ \
0x60, 0x08 /* bra.s 2f */
#define PATTERN_MASK_ILLVEC2_ROBN88(_o1, _o2) \
0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, _o1, _o2, \
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, \
0xff, 0xff
#define PATTERN_TVD1_ROBN88(_o1, _o2) /* 44 bytes */ \
0x02, 0x7c, 0xf8, 0xff, /* 1: andi.w #$f8ff,sr */ \
0x48, 0xe7, 0x80, 0xc0, /* movem.l d0/a0-a1,-(a7) */ \
0x43, 0xfa, _o1, _o2, /* 2: lea pc+2+_o1_o2,a1 */ \
0x20, 0x51, /* movea.l (a1),a0 */ \
0x20, 0xa9, 0x00, 0x04, /* move.l 4(a1),(a0) */ \
0x20, 0x6f, 0x00, 0x0e, /* 3: movea.l $e(a7),a0 */ \
0x22, 0x88, /* move.l a0,(a1) */ \
0x23, 0x50, 0x00, 0x04, /* move.l (a0),4(a1) */ \
0x20, 0x28, 0xff, 0xfc, /* move.l -4(a0),d0 */ \
0x46, 0x80, /* not.l d0 */ \
0x48, 0x40, /* swap d0 */ \
0xb1, 0x90, /* eor.l d0,(a0) */ \
0x4c, 0xdf, 0x03, 0x01, /* 4: movem.l (a7)+,d0/a0-a1 */ \
0x4e, 0x73 /* rte */
#define PATTERN_MASK_TVD1_ROBN88(_o1, _o2) \
0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, _o1, _o2, \
0xff, 0xff, \
0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, \
0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, \
0xff, 0xff, \
0xff, 0xff, \
0xff, 0xff, 0xff, 0xff, \
0xff, 0xff
#define PATTERN_TVD2_ROBN88(_o1, _o2) /* 50 bytes */ \
0x02, 0x7c, 0xf8, 0xff, /* 1: andi.w #$f8ff,sr */ \
0x48, 0xe7, 0x80, 0xc0, /* movem.l d0/a0-a1,-(a7) */ \
0x43, 0xfa, _o1, _o2, /* 2: lea pc+2+_o1_o2,a1 */ \
0x20, 0x51, /* movea.l (a1),a0 */ \
0x20, 0x28, 0xff, 0xfc, /* move.l -4(a0),d0 */ \
0x90, 0x83, /* sub.l d3,d0 */ \
0x46, 0x80, /* not.l d0 */ \
0x48, 0x40, /* swap d0 */ \
0xb1, 0x90, /* eor.l d0,(a0) */ \
0x20, 0x6f, 0x00, 0x0e, /* 3: movea.l $e(a7),a0 */ \
0x20, 0x28, 0xff, 0xfc, /* move.l -4(a0),d0 */ \
0x90, 0x83, /* sub.l d3,d0 */ \
0x46, 0x80, /* not.l d0 */ \
0x48, 0x40, /* swap d0 */ \
0xb1, 0x90, /* eor.l d0,(a0) */ \
0x22, 0x88, /* move.l a0,(a1) */ \
0x4c, 0xdf, 0x03, 0x01, /* 4: movem.l (a7)+,d0/a0-a1 */ \
0x4e, 0x73 /* rte */
#define PATTERN_MASK_TVD2_ROBN88(_o1, _o2) \
0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, _o1, _o2, \
0xff, 0xff, \
0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, \
0xff, 0xff, \
0xff, 0xff, \
0xff, 0xff, \
0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, \
0xff, 0xff, \
0xff, 0xff, \
0xff, 0xff, \
0xff, 0xff, \
0xff, 0xff, 0xff, 0xff, \
0xff, 0xff
DECLARE_PATTERN_WITH_MASK(pattern_bra_robn88,
PATTERN_ANY,
0x0, 0x0, 2,
PATTERN_BUFFER(
0x60, 0x72
),
PATTERN_BUFFER(
0xff, 0x00
)
);
DECLARE_PATTERN(pattern_switchsupill_robn88,
PATTERN_ANY,
0x80, 0x40, 22,
PATTERN_BUFFER(
PATTERN_SWITCHSUPILL_ROBN88
)
);
DECLARE_PATTERN(pattern_switchsuppriv1_robn88,
PATTERN_ANY,
0x40, 0x40, 30,
PATTERN_BUFFER(
PATTERN_SWITCHSUPPRIV1_ROBN88
)
);
DECLARE_PATTERN(pattern_switchsuppriv2_robn88,
PATTERN_ANY,
0x80, 0x40, 28,
PATTERN_BUFFER(
PATTERN_SWITCHSUPPRIV2_ROBN88
)
);
DECLARE_PATTERN_WITH_MASK(pattern_trigill_robn88,
PATTERN_ANY,
PATTERN_NEXT, 0x40, 10,
PATTERN_BUFFER(
PATTERN_TRIGILL_ROBN88(0x00, 0x8a)
),
PATTERN_BUFFER(
PATTERN_MASK_TRIGILL_ROBN88(0x00, 0x00)
)
);
DECLARE_PATTERN_WITH_MASK(pattern_trigillbin_robn88,
PATTERN_ANY,
0x90, 0x60, 10,
PATTERN_BUFFER(
PATTERN_TRIGILL_ROBN88(0x00, 0x8a)
),
PATTERN_BUFFER(
PATTERN_MASK_TRIGILL_ROBN88(0x00, 0x00)
)
);
DECLARE_PATTERN_WITH_MASK(pattern_illvec1_robn88,
PATTERN_ANY,
PATTERN_NEXT, 0xa0, 58,
PATTERN_BUFFER(
PATTERN_ILLVEC1_ROBN88(0x01, 0xf4, 0xfe, 0xe0)
),
PATTERN_BUFFER(
PATTERN_MASK_ILLVEC1_ROBN88(0x00, 0x00, 0x00, 0x00)
)
);
DECLARE_PATTERN_WITH_MASK(pattern_illvec2_robn88,
PATTERN_ANY,
PATTERN_NEXT, 0x80, 46,
PATTERN_BUFFER(
PATTERN_ILLVEC2_ROBN88(0x01, 0xa2)
),
PATTERN_BUFFER(
PATTERN_MASK_ILLVEC2_ROBN88(0x00, 0x00)
)
);
DECLARE_PATTERN_WITH_MASK(pattern_tvd1_robn88,
PATTERN_ANY,
PATTERN_NEXT, 0x0, 44,
PATTERN_BUFFER(
PATTERN_TVD1_ROBN88(0xfe, 0xca)
),
PATTERN_BUFFER(
PATTERN_MASK_TVD1_ROBN88(0x00, 0x00)
)
);
DECLARE_PATTERN_WITH_MASK(pattern_tvd2_robn88,
PATTERN_ANY,
PATTERN_NEXT, 0x0, 50,
PATTERN_BUFFER(
PATTERN_TVD2_ROBN88(0xff, 0x02)
),
PATTERN_BUFFER(
PATTERN_MASK_TVD2_ROBN88(0x00, 0x00)
)
);
DECLARE_PROTECTION_PARENT(prot_robn88a,
"Copylock Protection System series 1 (1988) by Rob Northen",
'a',
ROBN88_OFF,
PATTERNS_LIST(
&pattern_bra_robn88,
&pattern_switchsupill_robn88,
&pattern_trigill_robn88,
&pattern_illvec1_robn88,
&pattern_tvd1_robn88
),
decode_robn88,
PROT_PRIV_ROBN88(PROT_TVD_COMMON_ROBN88)
);
DECLARE_PROTECTION_VARIANT(prot_robn88b,
&prot_robn88a,
'b',
ROBN88_OFF,
PATTERNS_LIST(
&pattern_bra_robn88,
&pattern_switchsuppriv2_robn88,
&pattern_trigill_robn88,
&pattern_illvec1_robn88,
&pattern_tvd1_robn88
),
NULL,
PROT_PRIV_ROBN88(PROT_TVD_COMMON_ROBN88)
);
DECLARE_PROTECTION_VARIANT(prot_robn88c,
&prot_robn88a,
'c',
ROBN88_OFF,
PATTERNS_LIST(
&pattern_bra_robn88,
&pattern_switchsuppriv1_robn88,
&pattern_trigill_robn88,
&pattern_illvec2_robn88,
&pattern_tvd1_robn88
),
NULL,
PROT_PRIV_ROBN88(PROT_TVD_COMMON_ROBN88)
);
DECLARE_PROTECTION_VARIANT(prot_robn88d,
&prot_robn88a,
'd',
ROBN88_OFF,
PATTERNS_LIST(
&pattern_bra_robn88,
&pattern_switchsuppriv1_robn88,
&pattern_trigill_robn88,
&pattern_illvec2_robn88,
&pattern_tvd2_robn88
),
NULL,
PROT_PRIV_ROBN88(PROT_TVD_FSHARK_ROBN88)
);
DECLARE_PROTECTION_VARIANT(prot_robn88e,
&prot_robn88a,
'e',
ROBN88_OFF,
PATTERNS_LIST(
&pattern_bra_robn88,
&pattern_none,
&pattern_trigillbin_robn88,
&pattern_illvec1_robn88,
&pattern_tvd1_robn88
),
NULL,
PROT_PRIV_ROBN88(PROT_TVD_COMMON_ROBN88 | PROT_FORCE_SUP_ROBN88)
);
/*****************************************************************************
*
* Copylock Protection System series 2 (1989) by Rob Northen
*
* Static analysis of the protection.
* Some well-known code patterns are searched in the protection.
* It can be done for both the wrapper and the internal types.
*
* The series 2 uses two different TDV routines.
* - The first TDV routine uses a complex decryption scheme. It runs in the
* first part of protection where encrypted instructions are aimed at
* preventing the rest of the protection to be reached under a debugger.
* - The second TDV routine uses a simple decryption scheme. It runs in the
* heart of the protection where the key disk is read and the decryption
* of the wrapped program is performed.
* Therefore, mainly the code encrypted with the second TDV method needs to be
* parsed by dec0de for the static analysis.
* Fortunately, the decryption scheme for that part is simple.
*
*****************************************************************************/
#define ROBN89_OFF 0x0
#define PROT_FLAGS_ROBN89(_p) ((int)(size_t)((_p)->private))
#define PROT_PRIV_ROBN89(_f) ((void*)(size_t)(_f))
#define PROT_FORCE_SUP_ROBN89 (1 << 0)
#if defined (TARGET_ST)
static int decode_native_robn89 (prog_t* prog, info_robn_t* info);
#endif
/*
* Get the 32-bit key used to decrypt the current instruction.
* Such key is computed by adding a magic value to the preceding encrypted
* instruction.
*/
static inline uint32_t get_decode_key32_robn89 (unsigned char* buf,
uint32_t magic32)
{
uint32_t key32;
key32 = read32(buf - SIZE_32);
key32 += magic32;
return key32;
}
/*
* Search for the code which is used at the end of the protection to stop
* the TVD mode and resume the normal execution.
*
* The beginning of this code (4 instructions) is encrypted with the second
* TVD method, while the rest of it is encrypted with the first TVD method.
* Indeed, the first TVD routine is reenabled on purpose at the end of the
* protection, so that the latest instructions are executed using this more
* hostile method (which is also used at the beginning of the protection).
*
* The code in question installs a "trampoline" routine which will run
* in the normal execution mode of the CPU (TVD disabled).
* In the case of the wrapper type, the "trampoline" routine is in charge of
* copying the decrypted program to its final destination and starting
* its execution.
* In the case of the internal type, it is in charge of returning to the
* caller.
*
* In order to find that code, only the pattern which corresponds to the
* first three instructions of the code is searched.
*
* As seen above, this pattern is encrypted with the second TVD method.
* The corresponding decryption scheme works as follows: each instruction
* is decrypted by XOR-ing it with a key computed from a magic value and
* the preceding encrypted instruction.
* The magic value is the same for all encrypted instructions. Therefore,
* it can be easily deduced during the search of the code pattern.
*
* The offset of the code pattern and the magic value are returned.
*
* In addition, the offset of the end of the protection (which corresponds to
* the offset of the embedded program for the wrapper type) is also determined
* and returned (see comments below for details).
*/
static ssize_t get_start_offset_robn89 (unsigned char* buf,
size_t size,
uint32_t* pmagic32,
ssize_t* prog_offset)
{
uint32_t magic32;
uint32_t key32;
uint32_t w32;
uint16_t w16;
size_t limit;
size_t i;
size_t j;
for (i = 0;
(ssize_t) i <= (ssize_t) (size - (SIZE_16 * 10));
i += SIZE_16) {
j = i;
w32 = read32(buf + j);
w32 ^= (uint32_t) 0x4dfa0010; /* lea pc+$12,a6 */
magic32 = w32 - read32(buf + j - SIZE_32);
j += SIZE_32;
w32 = read32(buf + j);
key32 = get_decode_key32_robn89(buf + j, magic32);
w32 ^= key32;
if (w32 != (uint32_t) 0x2c2efffc) { /* move.l -4(a6),d6 */
continue;
}
j += SIZE_32;
w32 = read32(buf + j);
key32 = get_decode_key32_robn89(buf + j, magic32);
w32 ^= key32;
if (w32 != (uint32_t) 0xdcb90000) { /* add.l $8.l,d6 */
continue;
}
/*
* The pattern has been found, the magic value have been discovered.
*/
limit = i + (SIZE_32 * 64);
if (limit > size - (SIZE_16 * 3)) {
limit = size - (SIZE_16 * 3);
}
/*
* Determine the offset of the end of the protection.
*
* The last instructions of the protection are always executed
* using the first TVD routine (which is reactivated on purpose).
* The very last instruction of the protection is 'move.l a7,$24.l'.
* With the first TVD method, each instruction is decrypted using a
* different 32-bit key whose value depends on the execution of the
* previous instructions.
* But, for a given instruction, the same 32-bit key is used to
* decrypt each 32-bit part of that instruction.
* Because the 'move.l a7,$24.l' instruction is 6 bytes long, the
* corresponding 32-bit key is used to decrypt both the first 4 bytes
* and the last 2 bytes of the instruction.
* It is enough to guess the magic value and find the instruction.
*/
for (j = i + (SIZE_32 * 4); j <= limit; j += SIZE_16) {
w32 = read32(buf + j);
key32 = w32 ^ (uint32_t) 0x23cf0000; /* move.l a7,<addr>.l */
w16 = read16(buf + j + SIZE_32);
w16 ^= (uint16_t) (key32 >> 16);
if (w16 == (uint16_t) 0x0024) { /* <addr> == $24 */
*pmagic32 = magic32;
*prog_offset = (ssize_t) (j + (SIZE_16 * 3));
return (ssize_t) i;
}
}
}
*prog_offset = (ssize_t) -1;
return (ssize_t) -1;
}
/*
* Search for the instruction which pushes the beginning of the "trampoline"
* routine onto the stack.
*
* This code is encrypted using the first TVD method (see above function
* for details).
*/
static ssize_t get_pushtramp_offset_robn90 (unsigned char* buf,
size_t prog_offset,
size_t size)
{
uint32_t key32;
uint32_t w32;
uint16_t w16;
size_t i;
for (buf += prog_offset, i = SIZE_16 * 3; i <= size; i += SIZE_16) {
/*
* Search for the 'move.l #$bd96bdae,-(a7)' instruction.
*
* Trampoline start (stack bottom):
* #$bd96: eor.l d6,(a6)
* #$bdae: eor.l d6,<offset>(a6)
* [...]
* andi.w #$7fff,(a7)
* rte
*/
w32 = read32(buf - i);
key32 = w32 ^ (uint32_t) 0x2f3cbd96;
w32 = read32(buf - i + SIZE_32);
w16 = (uint16_t) ((w32 ^ key32) >> 16);
if (w16 == (uint16_t) 0xbdae) {
return (ssize_t) (prog_offset - i);
}
}
return (ssize_t) -1;
}
/*
* Get the size of the protected subroutine, if any.
*
* In the case of the internal type, a specific subroutine provided by the
* vendor of the protected software can be encrypted, linked to the
* protection and called from it.
* Such subroutine can interact with the host program to perform specific
* tricks.
*
* The size of the protected subroutine is encoded in the before-last
* instruction of the protection and encrypted with the first TVD method.
* The instruction is 'adda.l #<size>,a4'.
*
* As explained in 'get_start_offset_robn89()', the first TVD method uses
* a different 32-bit key to encrypt each instruction.
* But the same 32-bit key is used to encrypt each 32-bit part of a long
* instruction.
* In the present case, it is supposed that the size of the subroutine is
* less than 64K so that it can be encoded in the low 16-bit word of the
* instruction opcode, as follows: #$d9fc0000xxxx, where <xxxx> is the size
* of the subroutine.
* Knowing the first 32-bit part of the instruction, in both the encrypted and
* decrypted forms, enables to determine the 32-bit key which is used to
* encrypt/decrypt the whole instruction.
*/
static size_t get_subrout_size_robn90 (unsigned char* buf,
size_t prog_offset)
{
uint32_t w32;
uint16_t w16;
w32 = read32(buf + prog_offset - (SIZE_16 * 6));
w32 ^= 0xd9fc0000; /* adda.l #0,a4 */
w16 = read16(buf + prog_offset - (SIZE_16 * 6) + SIZE_32);
w16 ^= (uint16_t) (w32 >> 16);
return (size_t) w16;
}
/*
* Locate a code pattern in the heart of the protection which is encrypted
* with the second TVD method.
*
* An array of code patterns is passed to the function.
* The idea is to be able to locate a particular code logic that may have
* been implemented differently over time.
*
* The magic value which is used by the second TVD method must be passed to
* the function. It is discovered by 'get_start_offset_robn89()'.
*
* The size parameter indicates the amount of protected code to be parsed
* as well as the direction of the parsing: if the size is negative,
* the parsing should be done by descending address order.
* If the size is positive, it the parsing should be done by ascending address
* order.
*/
static ssize_t get_pattern_offset_robn89 (unsigned char* buf,
ssize_t offset,
ssize_t size,
uint32_t magic32,
instr_match_t** patterns)
{
uint32_t key32;
uint32_t w32_1;
uint32_t w32_2;
ssize_t sz_left;
ssize_t sz_next;
ssize_t limit;
ssize_t i;
ssize_t c;
ssize_t l;
unsigned int j;
unsigned int k;
instr_match_t* p;
if (size < 0) {
size = -size;
sz_next = (ssize_t) -SIZE_16;
} else {
sz_next = SIZE_16;
}
size = (size + (ssize_t) (SIZE_16 - 1)) & (ssize_t) ~(SIZE_16 - 1);
size -= (ssize_t) (SIZE_32 * 2);
offset = (sz_next < 0) ? offset - (ssize_t) (SIZE_32 * 2) : offset;
if ((size < 0) || (offset < 0)) {
return (ssize_t) -1;
}
sz_left = size;
i = offset;
limit = (sz_next < 0) ? offset : offset + size;
do {
key32 = get_decode_key32_robn89(buf + i, magic32);
w32_1 = read32(buf + i);
w32_2 = read32(buf + i + SIZE_32);
w32_1 ^= key32;
w32_2 ^= key32;
j = 0;
p = patterns[0];
do {
if (cmp_instr(w32_1, w32_2, &p[0])) {
break;
}
} while ((p = patterns[++j]) != 0);
if (!p) {
continue;
}
j = 0;
p = patterns[0];
do {
k = 0;
c = i;
do {
key32 = get_decode_key32_robn89(buf + c, magic32);
w32_1 = read32(buf + c);
w32_2 = read32(buf + c + SIZE_32);
w32_1 ^= key32;
w32_2 ^= key32;
if (!cmp_instr(w32_1, w32_2, &p[k])) {
break;
}
l = p[k++].stride;
if (l == 0) {
return (ssize_t) i;
}
c += l;
} while (c <= limit); /* 8 bytes are available above limit */
} while ((p = patterns[++j]) != 0);
} while (((sz_left -= (ssize_t) SIZE_16) >= 0) &&
((i += sz_next) >= 0));
return (ssize_t) -1;
}
/*
* Instructions pattern for program decoding.
*/
static instr_match_t decode_pattern1_robn89[] = {
/* lea here(pc),a6 */
{ { 0x4dfafffe, 0x00000000 }, { 0xffffffff, 0x00000000 }, 4, },
/* adda.l #offset,a6 */
{ { 0xddfc0000, 0x00000000 }, { 0xffff0000, 0x00000000 }, 6, },
/* move.l #size,d6 */
{ { 0x2c3c0000, 0x00000000 }, { 0xffff0000, 0x00000000 }, 0, },
};
static instr_match_t* decode_patterns_robn89[] = {
decode_pattern1_robn89,
NULL,
};
/*
* Instructions pattern for program relocation.
*/
static instr_match_t reloc_pattern1_robn89[] = {
/* lea here(pc),a6 */
{ { 0x4dfafffe, 0x00000000 }, { 0xffffffff, 0x00000000 }, 4, },
/* move.l a6,d6 */
{ { 0x2c0e0000, 0x00000000 }, { 0xffff0000, 0x00000000 }, 0, },
};
static instr_match_t* reloc_patterns_robn89[] = {
reloc_pattern1_robn89,
NULL,
};
/*
* Instructions pattern for vectors checking.
*/
static instr_match_t vecs_pattern1_robn89[] = {
/* move.l (a0)+,d0 */
{ { 0x20180000, 0x00000000 }, { 0xffff0000, 0x00000000 }, 4, },
/* andi.l #$ffffff,d0 */
{ { 0x028000ff, 0xffff0000 }, { 0xffffffff, 0xffff0000 }, 6, },
/* cmp.l #$400000,d0 */
{ { 0xb0bc0040, 0x00000000 }, { 0xffffffff, 0xffff0000 }, 0, },
};
static instr_match_t* vecs_patterns_robn89[] = {
vecs_pattern1_robn89,
NULL,
};
/*
* Instructions patterns for keydisk reading.
*/
static instr_match_t keydisk_pattern1_robn89[] = {
/* move.w $43e.l,-(a7) */
{ { 0x3f390000, 0x043e0000 }, { 0xffffffff, 0xffff0000 }, 6, },
/* st $43e.l */
{ { 0x50f90000, 0x043e0000 }, { 0xffffffff, 0xffff0000 }, 0, },
};
static instr_match_t keydisk_pattern2_robn89[] = {
/* move.w $43e.l,-offset(ax) */
{ { 0x30790000, 0x043e0000 }, { 0xf0ffffff, 0xffff0000 }, 8, },
/* st $43e.l */
{ { 0x50f90000, 0x043e0000 }, { 0xffffffff, 0xffff0000 }, 0, },
};
static instr_match_t* keydisk_patterns_robn89[] = {
keydisk_pattern1_robn89,
keydisk_pattern2_robn89,
NULL,
};
/*
* Instructions pattern for serial usage.
* External protection type: serial is saved at a given memory address.
*/
static instr_match_t serial_dst_pattern1_robn89[] = {
/* move.l d0,$address */
{ { 0x23c00000, 0x00000000 }, { 0xffff0000, 0x00000000 }, 6, },
/* moveq #0,d[0|1] */
{ { 0x70000000, 0x00000000 }, { 0xfdff0000, 0x00000000 }, 0, },
};
static instr_match_t* serial_dst_patterns_robn89[] = {
serial_dst_pattern1_robn89,
NULL,
};
/*
* Instructions pattern for serial usage.
* Internal protection type: end of serial usage, d0 and d1 are cleared.
*
*/
static instr_match_t serial_end_pattern1_robn89[] = {
/* moveq #0,d[0|1] */
{ { 0x70000000, 0x00000000 }, { 0xfdff0000, 0x00000000 }, 2, },
/* moveq #0,d[0|1] */
{ { 0x70000000, 0x00000000 }, { 0xfdff0000, 0x00000000 }, 2, },
/* lea pc+$12,a6 */
{ { 0x4dfa0010, 0x00000000 }, { 0xffffffff, 0x00000000 }, 0, },
};
static instr_match_t* serial_end_patterns_robn89[] = {
serial_end_pattern1_robn89,
NULL,
};
/*
* Instructions pattern for serial usage.
* Internal protection type: serial is saved into the stack
* in order to be returned to the caller.
*/
static instr_match_t serial_stack_pattern1_robn89[] = {
/* move.l d0,offset0(a7) */
{ { 0x2f400000, 0x00000000 }, { 0xffffff00, 0x00000000 }, 4, },
/* move.l d1,offset1(a7) */
{ { 0x2f410000, 0x00000000 }, { 0xffffff00, 0x00000000 }, 0, },
};
static instr_match_t* serial_stack_patterns_robn89[] = {
serial_stack_pattern1_robn89,
NULL,
};
/*
* Instructions pattern for serial usage.
* Internal protection type: serial is xor'ed into memory whose address
* is read from the stack.
*/
static instr_match_t serial_eor_pattern1_robn89[] = {
/* move.l offset0(a7),a6 */
{ { 0x2c6f0000, 0x00000000 }, { 0xffff0000, 0x00000000 }, 4, },
/* eor.l d0,(a6) */
{ { 0x01960000, 0x00000000 }, { 0x0fff0000, 0x00000000 }, 2, },
/* move.l d1,offset1(a7) */
{ { 0x2f410000, 0x00000000 }, { 0xffffff00, 0x00000000 }, 0, },
};
static instr_match_t* serial_eor_patterns_robn89[] = {
serial_eor_pattern1_robn89,
NULL,
};
/*
* First perform static analysis, and then call decode_native_robn89()
* to perform dynamic (run-time) analysis.
* If run on a non-ST platform, the function stops after the static analysis
* and dumps the collected information.
*/
static int decode_robn89 (prog_t* prog, unsigned char* buf, size_t size)
{
info_robn_t info;
ssize_t offset;
ssize_t limit_off;
ssize_t serial_end_off = -1;
ssize_t serial_sav_off;
ssize_t search_sz;
uint32_t key32;
uint32_t w32;
uint32_t addr32;
ASSERT(buf == prog->text);
init_info_robn(&info);
offset = (ssize_t) (prog->prot->patterns[1]->eoffset +
prog->prot->patterns[1]->ecount);
buf += offset;
size -= (size_t) offset;
if ((ssize_t) size <= (ssize_t) (SIZE_16 * 8)) {
LOG_ERROR("Truncated protection code\n");
return 1;
}
/*
* Locate the end of the protection and discover the magic value
* used by the second TVD method.
*/
info.start_off = get_start_offset_robn89(buf,
size,
&info.magic32,
&info.prog_off);
if (info.start_off < 0) {
LOG_ERROR("Cannot locate the end of the protection code\n");
goto unsupp;
}
/*
* Locate the trampoline code installer.
*/
info.pushtramp_off = get_pushtramp_offset_robn90(
buf,
(size_t) info.prog_off,
(size_t) (info.prog_off - info.start_off));
if (info.pushtramp_off < 0) {
LOG_ERROR("Cannot locate the trampoline code\n");
goto unsupp;
}
/*
* Locate the code snippet that decrypts the wrapped program.
* If found, the protection is a wrapper type otherwise it is an
* internal type.
*/
info.decode_off = get_pattern_offset_robn89(buf,
info.start_off,
-info.start_off,
info.magic32,
decode_patterns_robn89);
if (info.decode_off >= 0) {
/*
* Wrapper type: locate the relocation code pattern.
* If found, the wrapped program is a GEMDOS program otherwise it is
* a binary program.
*/
limit_off = info.decode_off;
info.reloc_off = get_pattern_offset_robn89(buf,
info.decode_off,
info.start_off - info.decode_off,
info.magic32,
reloc_patterns_robn89);
} else {
/*
* Internal type: locate the protected subroutine, if any.
*/
limit_off = info.start_off;
info.subrout_sz = get_subrout_size_robn90(buf,
(size_t) info.prog_off);
}
limit_off += (ssize_t) (SIZE_32 * 2);
/*
* Search for vectors checking.
*/
info.vecs_off = get_pattern_offset_robn89(buf,
limit_off,
-limit_off,
info.magic32,
vecs_patterns_robn89);
/*
* Search for keydisk reading.
*/
info.keydisk_off = get_pattern_offset_robn89(buf,
limit_off,
-limit_off,
info.magic32,
keydisk_patterns_robn89);
if (info.keydisk_off >= 0) {
search_sz = limit_off - info.keydisk_off;
if (info.decode_off >= 0) {
/*
* Keydisk is used by a wrapper type protection.
* Determine if the serial is saved into memory.
*/
info.serial_off = info.decode_off;
info.serial_usage = SERIAL_USAGE_DECODE_PROG_ROBN;
serial_sav_off = get_pattern_offset_robn89(buf,
limit_off,
-search_sz,
info.magic32,
serial_dst_patterns_robn89);
if (serial_sav_off >= 0) {
/*
* Serial is saved into memory, determine the destination
* address.
*/
info.serial_usage |= SERIAL_USAGE_SAVE_MEM_ROBN;
addr32 = 0;
key32 = get_decode_key32_robn89(buf + serial_sav_off,
info.magic32);
w32 = read32(buf + serial_sav_off) ^ key32;
addr32 |= (w32 & (uint32_t) 0x0000ffff) << 16;
w32 = read32(buf + serial_sav_off + SIZE_32) ^ key32;
addr32 |= (w32 & (uint32_t) 0xffff0000) >> 16;
info.serial_dst_addr = (void*) (size_t) addr32;
}
} else {
/*
* Keydisk is used by an internal type protection.
* Determine how the serial is used.
*/
serial_end_off = get_pattern_offset_robn89(buf,
limit_off,
-search_sz,
info.magic32,
serial_end_patterns_robn89);
if (serial_end_off >= 0) {
/*
* Serial is used for some extra tricks.
* Determine which one.
*/
if (search_sz > (ssize_t) (SIZE_32 * 8)) {
search_sz = (ssize_t) (SIZE_32 * 8);
}
info.serial_off = get_pattern_offset_robn89(buf,
limit_off,
-search_sz,
info.magic32,
serial_stack_patterns_robn89);
if (info.serial_off >= 0) {
/*
* Serial is merely returned to the caller.
*/
info.serial_usage = SERIAL_USAGE_RETURN_ROBN;
} else {
/*
* Otherwise, serial is used for some memory decoding.
* Determine which one.
*/
info.serial_off = get_pattern_offset_robn89(buf,
limit_off,
-search_sz,
info.magic32,
serial_eor_patterns_robn89);
if (info.serial_off >= 0) {
/*
* Serial is used to XOR a 32-bit word in memory.
*/
info.serial_usage = SERIAL_USAGE_EOR_MEM_ROBN;
} else {
/*
* Serial is used to perform complex memory decoding.
*/
info.serial_usage = SERIAL_USAGE_OTHER_MEM_ROBN;
}
}
} else {
/*
* Serial seems not to be used or is used in an unknown manner.
*/
info.serial_usage = SERIAL_USAGE_UNKNOWN_ROBN;
}
}
}
info.prog_off += offset;
info.start_off += offset;
info.pushtramp_off += offset;
if (info.decode_off >= 0) {
info.decode_off += offset;
}
if (info.reloc_off >= 0) {
info.reloc_off += offset;
}
if (info.vecs_off >= 0) {
info.vecs_off += offset;
}
if (info.keydisk_off >= 0) {
info.keydisk_off += offset;
}
if (info.serial_off >= 0) {
info.serial_off += offset;
}
if (check_size_robn(prog, &info)) {
return 1;
}
#if defined (TARGET_ST)
if ((info.decode_off >= 0) || (info.serial_off >= 0)) {
/*
* Continue with dynamic analysis.
*/
return decode_native_robn89(prog, &info);
}
#endif
return print_info_robn(&info, NULL);
unsupp:
LOG_ERROR("This variant of the Copylock Protection System "
"is not supported\n");
return 1;
}
/*
* Rob Northen protection code has evolved slightly over time. In particular
* the protection prolog (non-encrypted code) which is parsed by dec0de to
* automatically recognize the protection has changed a bit multiple times.
* Here are the known protection prolog variants of the series 2.
*/
#define PATTERN_SWITCHSUPILL_ROBN89 /* 24 bytes */ \
0x48, 0xe7, 0xe0, 0xe0, /* movem.l d0-d2/a0-a2,-(a7) */ \
0x48, 0x7a, 0x00, 0x12, /* pea pc+$14 */ \
0x2f, 0x3c, 0x00, 0x05, 0x00, 0x04, /* move.l #$50004,-(a7) */ \
0x4e, 0x4d, /* trap #$d */ \
0x50, 0x4f, /* addq.[w|l] #8,a7 */ \
0x4c, 0xdf, 0x07, 0x07, /* movem.l (a7)+,d0-a2/a0-a2 */ \
0x4a, 0xfc /* illegal */
#define PATTERN_MASK_SWITCHSUPILL_ROBN89 \
0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, \
0xff, 0x0f, /* 0x504f | 0x508f */ \
0xff, 0xff, 0xff, 0xff, \
0xff, 0xff
#define PATTERN_SWITCHSUP_ROBN89 /* 8 bytes */ \
0x42, 0xa7, /* clr.l,-(a7) */ \
0x3f, 0x3c, 0x00, 0x20, /* move.w #32,-(a7) */ \
0x4e, 0x41 /* trap #1 */
#define PATTERN_CACHE_ROBN89(_o1, _o2) /* 20 bytes */ \
0x20, 0x4f, /* movea.l a7,a0 */ \
0x4e, 0x7a, 0x00, 0x02, /* MOVEC CACR,d0 */ \
0x2f, 0x40, _o1, _o2, /* move.l d0,_o1_o2(a7) */ \
0x08, 0x80, 0x00, 0x00, /* bclr #0,d0 */ \
0x4e, 0x7b, 0x00, 0x02, /* MOVEC d0,CACR */ \
0x2e, 0x48 /* movea.l a0,a7 */
#define PATTERN_MASK_CACHE_ROBN89(_o1, _o2) \
0xff, 0xff, \
0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, _o1, _o2, \
0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, 0xff, 0xff, \
0xff, 0xff
#define PATTERN_TVD_ROBN89 /* 66 bytes */ \
0x4c, 0xfa, 0x7f, 0xff, 0x00, 0x02, /* movem.l pc+$4,d0-a6 */ \
0x2f, 0x3c, 0x4e, 0x73, 0x00, 0x00, /* move.l #$4e730000,-(a7) */ \
0x2f, 0x3c, 0x00, 0x00, 0x00, 0x10, /* move.l #$10,-(a7) */ \
0x2f, 0x3c, 0x00, 0x04, 0xdd, 0xb9, /* move.l #$4ddb9,-(a7) */ \
0x2f, 0x3c, 0xbd, 0x96, 0xbd, 0xae, /* move.l #$bd96bdae,-(a7) */ \
0x2f, 0x3c, 0xb3, 0x86, 0xb5, 0x86, /* move.l #$b386b586,-(a7) */ \
0x2f, 0x3c, 0xd0, 0x46, 0xd2, 0x46, /* move.l #$d046d246,-(a7) */ \
0x2f, 0x3c, 0x02, 0x46, 0xa7, 0x1f, /* move.l #$246a71f,-(a7) */ \
0x2f, 0x3c, 0x00, 0x02, 0x3c, 0x17, /* move.l #$23c17,-(a7) */ \
0x2f, 0x3c, 0x00, 0x04, 0x2c, 0x6f, /* move.l #$42c6f,-(a7) */ \
0x2f, 0x3c, 0xbd, 0x96, 0xbd, 0xae /* move.l #$bd96bdae,-(a7) */
#define PATTERN_MASK_TVD_ROBN89 \
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
0xff, 0xff, 0xff, 0xff, 0xff, 0xff
DECLARE_PATTERN_WITH_MASK(pattern_switchsupill_robn89,
PATTERN_ANY,
0x0, 0x10, 24,
PATTERN_BUFFER(
PATTERN_SWITCHSUPILL_ROBN89
),
PATTERN_BUFFER(
PATTERN_MASK_SWITCHSUPILL_ROBN89
)
);
DECLARE_PATTERN(pattern_switchsup_robn89,
PATTERN_ANY,
0x0, 0x10, 8,
PATTERN_BUFFER(
PATTERN_SWITCHSUP_ROBN89
)
);
DECLARE_PATTERN_WITH_MASK(pattern_init1_robn89,
PATTERN_ANY,
PATTERN_NEXT, 0x20, 116,
PATTERN_BUFFER(
0x48, 0xe7, 0xff, 0xff, /* movem.l d0-a7,-(a7) */
0x48, 0x7a, 0x00, 0x1a, /* pea pc+$1c */
0x23, 0xdf, 0x00, 0x00, 0x00, 0x10, /* move.l (a7)+,$10 */
PATTERN_CACHE_ROBN89(0x00, 0x3c),
PATTERN_TVD_ROBN89,
0x23, 0xcf, 0x00, 0x00, 0x00, 0x24, /* move.l a7,$24 */
0x00, 0x7c, 0xa7, 0x1f, /* ori.w #$a71f,sr */
0x5c, 0xb9, 0x00, 0x00, 0x00, 0x24 /* addq.l #6,$24 */
),
PATTERN_BUFFER(
0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
PATTERN_MASK_CACHE_ROBN89(0xff, 0x00),
PATTERN_MASK_TVD_ROBN89,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff
)
);
DECLARE_PATTERN_WITH_MASK(pattern_init2_robn89,
PATTERN_ANY,
PATTERN_NEXT, 0x20, 110,
PATTERN_BUFFER(
0x48, 0xe7, 0xff, 0xff, /* movem.l d0-a7,-(a7) */
0x48, 0x7a, 0x00, 0x18, /* pea pc+$1a [!] */
0x21, 0xdf, 0x00, 0x10, /* move.l (a7)+,$10.w [!] */
PATTERN_CACHE_ROBN89(0x00, 0x3c),
PATTERN_TVD_ROBN89,
0x21, 0xcf, 0x00, 0x24, /* move.l a7,$24.w [!] */
0x00, 0x7c, 0xa7, 0x1f, /* ori.w #$a71f,sr */
0x5c, 0xb8, 0x00, 0x24 /* addq.l #6,$24.w [!] */
),
PATTERN_BUFFER(
0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff,
PATTERN_MASK_CACHE_ROBN89(0xff, 0x00),
PATTERN_MASK_TVD_ROBN89,
0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff
)
);
DECLARE_PROTECTION_PARENT(prot_robn89a,
"Copylock Protection System series 2 (1989) by Rob Northen",
'a',
ROBN89_OFF,
PATTERNS_LIST(
&pattern_switchsupill_robn89,
&pattern_init1_robn89
),
decode_robn89,
NULL
);
DECLARE_PROTECTION_VARIANT(prot_robn89b,
&prot_robn89a,
'b',
ROBN89_OFF,
PATTERNS_LIST(
&pattern_switchsupill_robn89,
&pattern_init2_robn89
),
NULL,
NULL
);
DECLARE_PROTECTION_VARIANT(prot_robn89c,
&prot_robn89a,
'c',
ROBN89_OFF,
PATTERNS_LIST(
&pattern_switchsup_robn89,
&pattern_init1_robn89
),
NULL,
NULL
);
DECLARE_PROTECTION_VARIANT(prot_robn89d,
&prot_robn89a,
'd',
ROBN89_OFF,
PATTERNS_LIST(
&pattern_switchsup_robn89,
&pattern_init2_robn89
),
NULL,
NULL
);
DECLARE_PROTECTION_VARIANT(prot_robn89e,
&prot_robn89a,
'e',
ROBN89_OFF,
PATTERNS_LIST(
&pattern_none,
&pattern_init1_robn89
),
NULL,
PROT_PRIV_ROBN89(PROT_FORCE_SUP_ROBN89)
);
DECLARE_PROTECTION_VARIANT(prot_robn89f,
&prot_robn89a,
'f',
ROBN89_OFF,
PATTERNS_LIST(
&pattern_none,
&pattern_init2_robn89
),
NULL,
PROT_PRIV_ROBN89(PROT_FORCE_SUP_ROBN89)
);
/*****************************************************************************
* Decoder
*****************************************************************************/
static prot_t* prots[] = {
&prot_tp1,
&prot_ral_lp,
&prot_ral_mp,
&prot_sly,
&prot_cooper5,
&prot_cooper6,
&prot_ab100,
&prot_ab140a,
&prot_ab140b,
&prot_ab160,
&prot_ab161,
&prot_zippy205,
&prot_zippy206,
&prot_lockomatic,
&prot_cid10,
&prot_robn88a,
&prot_robn88b,
&prot_robn88c,
&prot_robn88d,
&prot_robn88e,
&prot_robn89a,
&prot_robn89b,
&prot_robn89c,
&prot_robn89d,
&prot_robn89e,
&prot_robn89f,
NULL,
};
/*
* Pattern matching routines.
*/
static int pattern_cmp (const unsigned char* buf1,
const unsigned char* buf2,
size_t sz)
{
const uint16_t* buf16_1 = (const uint16_t*) buf1;
const uint16_t* buf16_2 = (const uint16_t*) buf2;
do {
if (*buf16_1++ != *buf16_2++) {
return 1;
}
sz -= SIZE_16;
} while (sz);
return 0;
}
static int pattern_cmp_mask (const unsigned char* buf1,
const unsigned char* buf2,
const unsigned char* mask,
size_t sz)
{
const uint16_t* buf16_1 = (const uint16_t*) buf1;
const uint16_t* buf16_2 = (const uint16_t*) buf2;
const uint16_t* msk16 = (const uint16_t*) mask;
uint16_t w16_1;
uint16_t w16_2;
uint16_t m16;
do {
w16_1 = *buf16_1++;
w16_2 = *buf16_2++;
if (w16_1 != w16_2) {
m16 = *msk16;
w16_1 &= m16;
w16_2 &= m16;
if (w16_1 != w16_2) {
return 1;
}
}
msk16++;
sz -= SIZE_16;
} while (sz);
return 0;
}
static int pattern_match_fixed (prog_t* prog, pattern_t* pattern,
size_t eoffset)
{
unsigned char* buf;
int diag;
if (prog->size < eoffset + pattern->count) {
return 1;
}
buf = prog->text + eoffset;
if (pattern->mask == NULL) {
diag = pattern_cmp(buf, pattern->buf, pattern->count);
} else {
diag = pattern_cmp_mask(buf, pattern->buf, pattern->mask,
pattern->count);
}
if (diag == 0) {
pattern->eoffset = eoffset;
pattern->ecount = pattern->count;
}
return diag;
}
static int pattern_match_delta (prog_t* prog, pattern_t* pattern,
size_t eoffset)
{
size_t size;
size_t count;
size_t limit;
const uint16_t* buf16;
uint16_t p16;
ASSERT((pattern->mask == NULL) || (read16(pattern->mask) == 0xffff));
size = prog->size;
count = pattern->count;
limit = eoffset + count;
if (limit > size) {
return 1;
}
limit += pattern->delta;
limit = limit < size ? limit : size;
limit -= count;
buf16 = (const uint16_t*) (prog->text + eoffset);
p16 = *((const uint16_t*) pattern->buf);
do {
if ((p16 == *buf16) &&
(pattern_match_fixed(prog, pattern, eoffset) == 0)) {
return 0;
}
buf16++;
eoffset += SIZE_16;
} while (limit >= eoffset);
return 1;
}
static int pattern_match (prog_t* prog, pattern_t* pattern,
pattern_t* pattern_prev)
{
size_t offset;
ASSERT(!((pattern->offset | pattern->count) & 0x1) &&
(pattern->count || (pattern == &pattern_none)));
pattern->eoffset = 0;
pattern->ecount = 0;
if (!(pattern->type & (prog->hsize ? PATTERN_PROG : PATTERN_BIN))) {
if (pattern_prev) {
pattern->eoffset = pattern_prev->eoffset + pattern_prev->ecount;
}
return 0;
}
offset = pattern->offset;
if (offset == PATTERN_NEXT) {
if (pattern_prev) {
offset = pattern_prev->eoffset + pattern_prev->ecount;
} else {
offset = 0;
}
}
if (pattern->delta == 0) {
return pattern_match_fixed(prog, pattern, offset);
}
return pattern_match_delta(prog, pattern, offset);
}
/*
* Find the protection used by a given program.
*/
#define ENCODED_MSG "Program '%s' is enc0ded with " PP_LINEBRK "%s"
static prot_t* get_prot (prog_t* prog)
{
prot_t* prot;
pattern_t* pattern;
pattern_t* pattern_prev;
unsigned int i;
unsigned int j;
for (i = 0; (prot = prots[i]) != NULL; i++) {
ASSERT(!(prot->doffset & 0x1));
if (prot->doffset &&
(prog->size < prot->doffset + sizeof(prog_hdr_t))) {
continue;
}
for (pattern_prev = NULL, j = 0;
(pattern = prot->patterns[j]) != NULL;
pattern_prev = pattern, j++) {
if (pattern_match(prog, pattern, pattern_prev) != 0) {
break;
}
}
if (pattern == NULL) {
break;
}
}
if (prot) {
if (!prot->varnum) {
ASSERT(!prot->parent);
LOG_INFO(ENCODED_MSG "\n", prog->name, prot->name);
} else {
ASSERT(prot->parent);
LOG_INFO(ENCODED_MSG " (variant %c)\n",
prog->name, prot->parent->name, prot->varnum);
}
} else {
LOG_ERROR("Unrecognized protection for program '%s'\n", prog->name);
}
return prot;
}
/*
* Load a program, find the corresponding protection, print its name
* and release allocated resources.
*/
static void print_prot (const char* sname)
{
prog_t* prog;
prog = load_prog(sname);
if (prog) {
(void) get_prot(prog);
release_prog(prog);
}
}
/*
* Decode a loaded program (without saving it).
*/
static int decode_prog (prog_t* prog)
{
prot_t* prot;
decode_func_t prot_decode;
int diag = 1;
prot = get_prot(prog);
if (prot) {
PP_NEWLINE();
prog->prot = prot;
prot_decode = PROT_DECODE(prot);
ASSERT(prot_decode);
diag = prot_decode(prog, prog->text + prot->doffset,
prog->size - prot->doffset);
if (diag == 0) {
diag = fixup_prog(prog);
}
}
return diag;
}
/*
* Load, decode and save a program.
*/
static int decode (const char* sname, const char* dname)
{
prog_t* prog;
int diag = 1;
prog = load_prog(sname);
if (prog) {
diag = decode_prog(prog);
if ((diag == 0) && dname) {
LOG_INFO("Saving dec0ded program as '%s'\n", dname);
diag = save_prog(prog, dname);
}
release_prog(prog);
}
return diag;
}
/*
* List supported protections.
*/
static void list_prots (void)
{
prot_t* prot;
unsigned int i;
LOG_INFO("Supported protections are:\n");
PP_NEWLINE();
for (i = 0; (prot = prots[i]) != NULL; i++) {
if (!prot->parent || (prot->parent == prot)) {
LOG_INFO(" %s\n", prot->name);
}
}
}
/*****************************************************************************
* Help & information
*****************************************************************************/
#define DEC0DE_INFO \
DEC0DE_NAME " sources are available at " DEC0DE_REPO "\n" \
"Report bugs or unsupported protections to " DEC0DE_EMAIL "\n"
static void usage (char** argv)
{
LOG_INFO(
"Usage: %s <command> [<source_file>] [<destination_file>]\n"
"Remove encryption systems used to protect Atari ST programs.\n"
"\n"
"Possible commands are:\n"
" -d ... dec0de <source_file> into <destination_file>\n"
" -t ... test dec0ding of <source_file>\n"
" -p ... display protection name of <source_file>\n"
" -l ... list supported protections\n"
" -h ... display this help\n"
" -i ... provide detailed information\n"
" -v ... output version information\n"
" -c ... credits\n"
"\n"
"This tool has been developed by " DEC0DE_AUTHOR ".\n"
DEC0DE_INFO,
PROG_NAME(argv)
);
}
static void info (void)
{
LOG_INFO_MORE(
DEC0DE_VERSION_FULL "\nBy " DEC0DE_TEAM ".\n"
"\n"
"Remove encryption systems used to protect Atari ST programs.\n"
"\n"
"On Atari ST, encryption systems were often used to protect programs\n"
"against hacking, reverse-engineering or ripping: the original program\n"
"was encrypted and transformed into a self-decrypting program.\n"
"\n"
"These protections were developed by the game industry or by the sceners\n"
"themselves. Most popular protections are Copylock by Rob Northen,\n"
"Anti-bitos by Illegal, Cooper by Cameo...\n"
"\n"
DEC0DE_NAME " merely removes such protections, thus enabling to restore\n"
"the original unprotected programs.\n"
"\n"
"If a protected program crashes under your emulator or on your machine,\n"
"if it contains a music, a picture or a scrolltext you want to rip,\n"
"or if it is a software you want to hack, then " DEC0DE_NAME
" is made for you.\n"
);
LOG_INFO_MORE(
DEC0DE_NAME " expects the protected program to be provided as a regular\n"
"file. Therefore it is up to you to extract the program from the disk if\n"
"there is no filesystem on it.\n"
"\n"
"A protected program can be provided to " DEC0DE_NAME " as a GEMDOS or a\n"
"raw binary program file. " DEC0DE_NAME " will automatically recognize\n"
"the protection, will extract the original unprotected program and will\n"
"save it in its original format (GEMDOS or raw binary program file).\n"
"\n"
"If the resulting unprotected program is packed, then you can use the\n"
"well known depackers (New Depack, Naughty Unpacker...) to obtain the\n"
"original uncompressed file.\n"
"\n"
"Depackers links:\n"
"- New Depack https://demozoo.org/productions/96097/\n"
"- The Naughty Unpacker https://demozoo.org/productions/75456/\n"
"- The UPX packer/unpacker https://upx.github.io/\n"
);
LOG_INFO_MORE(
"Note about the Rob Northen Copylock Systems:\n"
"\n"
#if !defined (TARGET_ST)
"To determine the serial number and to extract the original unprotected\n"
"program, " DEC0DE_NAME " must be run on a real or emulated Atari ST.\n"
"\n"
#endif
"Besides decrypting the program, " DEC0DE_NAME " also provides useful\n"
"details about the Copylock protection: the serial number and the\n"
"memory address it is saved to, the use of extra tricks in the\n"
"protection (extra magic value, special serial key usage).\n"
"Such details may be needed to properly crack the protected software.\n"
"\n"
#if !defined (TARGET_ST)
"When run on Linux, Mac OS or Windows, " DEC0DE_NAME " provides these\n"
"details as much as possible, while skipping the decryption process.\n"
"\n"
#endif
"In addition to the Copylock 'wrapper' type (self-decrypting program)\n"
DEC0DE_NAME" also supports the Copylock 'internal' type (self-decrypting\n"
"routine inside a host program).\n"
"You just need to extract the encrypted routine from the host program\n"
"and to provide it as a file to " DEC0DE_NAME ".\n"
DEC0DE_NAME " will analyze the encrypted routine and give the details\n"
"needed to crack the protection (such as the serial number and how\n"
"it is used).\n"
"\n"
"Original copy-locked floppy disks are available as image files that can\n"
"be used on most Atari ST emulators. Such images can be found at:\n"
"- Atari Mania http://www.atarimania.com\n"
"- Atari Legend http://www.atarilegend.com\n"
);
LOG_INFO(
"Greetings to all Atari ST sceners, past and present.\n"
"\n"
"Thanks to all Atari ST enthusiasts who contribute to keep the Atari ST\n"
"scene and spirit alive.\n"
"\n"
"Special thanks to the following people:\n"
"- Mr Nours ^ MJJ Prod for his essential Fuzion Shrine website\n"
" http://fuzionshrine.omiquel.lautre.net\n"
"- Jace ^ ST Knights for his support to The Replicants\n"
" http://replicants.free.fr/index.php\n"
"- Brume ^ Atari Legend for his amazing archiving effort\n"
" http://www.atarilegend.com & http://www.stonish.net/Fuzion-61\n"
"- Lotek Style ^ tSCc for his great work on Demozoo\n"
" https://demozoo.org\n"
"\n"
"A big hi to Marcer ^ Elite, Mug UK ^ AL, Zorro2 ^ NoExtra, St Cooper,\n"
"Mara ^ Flush, Marco Breddin.\n"
"\n"
"A warm hello to all Replicants and Fuzion members, especially Ellfire,\n"
"Cameo, Kasar, Squat, JackTBS, Docno, Illegal, Snake, Excalibur, Fury...\n"
"\n"
DEC0DE_INFO
);
}
static void version (void)
{
LOG_INFO(DEC0DE_VERSION_FULL "\n");
}
static void credits (void)
{
LOG_INFO("Credits:\n");
PP_NEWLINE();
LOG_INFO(
" Code & reverse engineering ... Orion ^ The Replicants ^ Fuzion\n"
" Reverse engineering .......... Maartau ^ Atari Legend ^ Elite\n"
#if defined (TARGET_ST)
" ASCII logo ................... Senser ^ Effect ^ Vectronix\n"
#endif
"\n"
DEC0DE_INFO
);
}
static void try_help (char** argv)
{
LOG_ERROR("Try '%s -h' for more information.\n", argv[0]);
}
/*****************************************************************************
* Atari ST specific code
*****************************************************************************/
#if defined (TARGET_ST)
/*
* Atari Application Environment Services.
*
* See GEM Programmer's Guide - Volume 2 - AES,
* http://dev-docs.atariforge.org/files/GEM_AES_v1_Jan-1989.pdf
*/
static struct {
int init_done;
uint16_t global[16];
/*
* opcode
* int_in size in words
* int_out size in words
* addr_in size in longs
* addr_out size in longs
*/
uint16_t ctrl[5];
uint16_t int_in[16];
uint16_t int_out[16];
void* addr_in[16];
void* addr_out[16];
void* params_block[6];
} aes;
/*
* Atari Line-A Emulator.
*
* See http://toshyp.atari.org/en/006.html
*
* For negative offsets, see S.A.L.A.D. - Still Another Line A Document
* by Mark Jansen - Atari Corporation,
* https://mikro.naprvyraz.sk/docs/GEM/SALAD.TXT
*/
static void* linea_param_blk;
static uint16_t* cell_x_max_p;
static uint16_t* mouse_hid_count_p;
static int mouse_is_hidden;
/*
* Saved color palette.
*
* See http://toshyp.atari.org/en/Screen_functions.html#Setcolor
*/
static int16_t colors[16];
/*
* Using interactive mode?
*/
static int ia_mode_usage;
/*
* GEMDOS functions.
*
* See http://toshyp.atari.org/en/005013.html
* or
* http://info-coach.fr/atari/documents/_mydoc/Hitchhikers-Guide-V1.1.pdf
*/
/*
* Print (Cconws).
*/
static void print (const char* txt)
{
__asm__ __volatile__
(
"movem.l %%d2-%%d7/%%a2-%%a5,%%sp@- \n\t"
" \n\t"
"move.l %0,%%sp@- \n\t"
"move.w #9,%%sp@- \n\t"
"trap #1 \n\t"
"addq.l #6,%%sp \n\t"
" \n\t"
"movem.l %%sp@+,%%d2-%%d7/%%a2-%%a5 \n\t"
:
: "g" (txt)
: "cc", "%%d0", "%%d1", "%%a0", "%%a1", "memory"
);
}
#define PRINT(_t) \
do { \
print(_t); \
log_count++; \
} while (0)
/*
* Key wait (Crawcin).
*/
static int key_wait (void)
{
register uint32_t key;
__asm__ __volatile__
(
"movem.l %%d2-%%d7/%%a2-%%a5,%%sp@- \n\t"
" \n\t"
"move.w #7,%%sp@- \n\t"
"trap #1 \n\t"
"addq.l #2,%%sp \n\t"
" \n\t"
"movem.l %%sp@+,%%d2-%%d7/%%a2-%%a5 \n\t"
" \n\t"
"move.l %%d0, %0 \n\t"
: "=d" (key)
:
: "cc", "%%d0", "%%d1", "%%a0", "%%a1", "memory"
);
return (int) (key & ((uint32_t) 0xff));
}
/*
* Get current drive (Dgetdrv).
*/
static unsigned int cur_drv_get (void)
{
register uint16_t drv;
__asm__ __volatile__
(
"movem.l %%d2-%%d7/%%a2-%%a5,%%sp@- \n\t"
" \n\t"
"move.w #25,%%sp@- \n\t"
"trap #1 \n\t"
"addq.l #2,%%sp \n\t"
" \n\t"
"movem.l %%sp@+,%%d2-%%d7/%%a2-%%a5 \n\t"
" \n\t"
"move.w %%d0, %0 \n\t"
: "=d" (drv)
:
: "cc", "%%d0", "%%d1", "%%a0", "%%a1", "memory"
);
if (drv > 25) {
drv = 0;
}
return ((unsigned int) drv) + 1;
}
/*
* Get current directory (Dgetpath).
*/
static int cur_dir_get (unsigned int drv, char* dir)
{
register int32_t diag;
__asm__ __volatile__
(
"movem.l %%d2-%%d7/%%a2-%%a5,%%sp@- \n\t"
" \n\t"
"move.w %1,%%sp@- \n\t"
"move.l %2,%%sp@- \n\t"
"move.w #71,%%sp@- \n\t"
"trap #1 \n\t"
"addq.l #8,%%sp \n\t"
" \n\t"
"movem.l %%sp@+,%%d2-%%d7/%%a2-%%a5 \n\t"
" \n\t"
"move.l %%d0, %0 \n\t"
: "=d" (diag)
: "g" ((uint16_t) drv), "g" (dir)
: "cc", "%%d0", "%%d1", "%%a0", "%%a1", "memory"
);
return (int) diag;
}
/*
* Get current path.
*/
static void cur_path_get (char* path)
{
unsigned int drv;
unsigned int len;
int diag;
drv = cur_drv_get();
path[0] = (char) (drv - 1 + 'A');
path[1] = ':';
path[2] = '\0';
diag = cur_dir_get(drv, path + 2);
if (diag != 0) {
path[2] = '\0';
}
len = strlen(path);
if (path[len - 1] != '\\') {
path[len] = '\\';
path[len + 1] = '\0';
}
}
/*
* XBIOS functions.
*
* See http://toshyp.atari.org/en/004014.html
*/
/*
* Supexec.
*/
static int32_t supexec (int32_t (*func) (void))
{
register int32_t diag;
__asm__ __volatile__
(
"movem.l %%d2-%%d7/%%a2-%%a5,%%sp@- \n\t"
" \n\t"
"move.l %1,%%sp@- \n\t"
"move.w #38,%%sp@- \n\t"
"trap #14 \n\t"
"addq.l #6,%%sp \n\t"
" \n\t"
"movem.l %%sp@+,%%d2-%%d7/%%a2-%%a5 \n\t"
" \n\t"
"move.l %%d0, %0 \n\t"
: "=d" (diag)
: "g" (func)
: "cc", "%%d0", "%%d1", "%%a0", "%%a1", "memory"
);
return diag;
}
/*
* Getrez.
*/
static unsigned int getrez (void)
{
register uint16_t rez;
__asm__ __volatile__
(
"movem.l %%d2-%%d7/%%a2-%%a5,%%sp@- \n\t"
" \n\t"
"move.w #4,%%sp@- \n\t"
"trap #14 \n\t"
"addq.l #2,%%sp \n\t"
" \n\t"
"movem.l %%sp@+,%%d2-%%d7/%%a2-%%a5 \n\t"
" \n\t"
"move.w %%d0, %0 \n\t"
: "=d" (rez)
:
: "cc", "%%d0", "%%d1", "%%a0", "%%a1", "memory"
);
return (unsigned int) rez;
}
#if 0 /* Unused */
/*
* Setrez.
*/
static void setrez (unsigned int rez)
{
__asm__ __volatile__
(
"movem.l %%d2-%%d7/%%a2-%%a5,%%sp@- \n\t"
" \n\t"
"move.w %0,%%sp@- \n\t"
"move.l #-1,%%sp@- \n\t"
"move.l #-1,%%sp@- \n\t"
"move.w #5,%%sp@- \n\t"
"trap #14 \n\t"
"add.l #12,%%sp \n\t"
" \n\t"
"movem.l %%sp@+,%%d2-%%d7/%%a2-%%a5 \n\t"
:
: "g" ((uint16_t) (rez))
: "cc", "%%d0", "%%d1", "%%a0", "%%a1", "memory"
);
}
#endif
/*
* Setcolor.
*/
static int16_t setcolor (unsigned int colornum, int16_t color)
{
register int16_t oldcolor;
__asm__ __volatile__
(
"movem.l %%d2-%%d7/%%a2-%%a5,%%sp@- \n\t"
" \n\t"
"move.w %1,%%sp@- \n\t"
"move.w %2,%%sp@- \n\t"
"move.w #7,%%sp@- \n\t"
"trap #14 \n\t"
"addq.l #6,%%sp \n\t"
" \n\t"
"movem.l %%sp@+,%%d2-%%d7/%%a2-%%a5 \n\t"
" \n\t"
"move.w %%d0, %0 \n\t"
: "=d" (oldcolor)
: "g" (color), "g" ((uint16_t) (colornum))
: "cc", "%%d0", "%%d1", "%%a0", "%%a1", "memory"
);
return oldcolor;
}
/*
* System variables.
*/
static int32_t conterm_setup (void)
{
__asm__ __volatile__
(
"move.b #6,0x484.w \n\t"
:
:
: "cc", "memory"
);
return 0;
}
static int32_t conterm_restore (void)
{
__asm__ __volatile__
(
"move.b #7,0x484.w \n\t"
:
:
: "cc", "memory"
);
return 0;
}
/*
* Line-A functions.
*/
static int linea_init (void)
{
register void* linea_addr;
__asm__ __volatile__
(
"movem.l %%d2-%%d7/%%a2-%%a5,%%sp@- \n\t"
" \n\t"
"move.l #0, %%a0 \n\t"
"dc.w 0xa000 \n\t"
" \n\t"
"movem.l %%sp@+,%%d2-%%d7/%%a2-%%a5 \n\t"
" \n\t"
"movea.l %%a0, %0 \n\t"
: "=a" (linea_addr)
:
: "cc", "%%d0", "%%d1", "%%a0", "%%a1", "memory"
);
if (!linea_addr || !(*(void**)((uint8_t*)linea_addr + 8))) {
PRINT("Line-A initialization failed\n\r");
return 1;
}
linea_param_blk = linea_addr;
cell_x_max_p = (uint16_t*)((uint8_t*)linea_param_blk - 0x02c);
mouse_hid_count_p = (uint16_t*)((uint8_t*)linea_param_blk - 0x256);
mouse_is_hidden = (*mouse_hid_count_p != 0);
return 0;
}
static void linea_showm (void)
{
if (!linea_param_blk) {
return;
}
__asm__ __volatile__
(
"movem.l %%d2-%%d7/%%a2-%%a5,%%sp@- \n\t"
" \n\t"
"move.l %0,%%a0 \n\t"
"move.l %%a0@(8),%%a1 \n\t"
"move.w #0,%%a1@ \n\t"
"dc.w 0xa009 \n\t"
" \n\t"
"movem.l %%sp@+,%%d2-%%d7/%%a2-%%a5 \n\t"
:
: "g" (linea_param_blk)
: "cc", "%%d0", "%%d1", "%%a0", "%%a1", "memory"
);
}
static void linea_hidem (void)
{
if (!linea_param_blk) {
return;
}
__asm__ __volatile__
(
"movem.l %%d2-%%d7/%%a2-%%a5,%%sp@- \n\t"
" \n\t"
"move.l %0,%%a0 \n\t"
"move.l %%a0@(8),%%a1 \n\t"
"move.w #0,%%a1@ \n\t"
"dc.w 0xa00a \n\t"
" \n\t"
"movem.l %%sp@+,%%d2-%%d7/%%a2-%%a5 \n\t"
:
: "g" (linea_param_blk)
: "cc", "%%d0", "%%d1", "%%a0", "%%a1", "memory"
);
}
/*
* AES functions.
*/
static int aes_call (void)
{
register int32_t diag;
__asm__ __volatile__
(
"movem.l %%d2-%%d7/%%a2-%%a5,%%sp@- \n\t"
" \n\t"
"move.l #200,%%d0 \n\t"
"move.l %1,%%d1 \n\t"
"trap #2 \n\t"
" \n\t"
"movem.l %%sp@+,%%d2-%%d7/%%a2-%%a5 \n\t"
" \n\t"
"move.l %%d0, %0 \n\t"
: "=d" (diag)
: "g" (aes.params_block)
: "cc", "%%d0", "%%d1", "%%a0", "%%a1", "memory"
);
return (int) diag;
}
static void aes_reset (void)
{
unsigned int i;
for (i = 0; i < 5; i++) {
aes.ctrl[i] = 0;
}
for (i = 0; i < 16; i++) {
aes.int_in[i] = 0;
}
for (i = 0; i < 16; i++) {
aes.int_out[i] = 0;
}
for (i = 0; i < 16; i++) {
aes.addr_in[i] = 0;
}
for (i = 0; i < 16; i++) {
aes.addr_out[i] = 0;
}
}
static int aes_appl_init (void)
{
aes.params_block[0] = aes.ctrl;
aes.params_block[1] = aes.global;
aes.params_block[2] = aes.int_in;
aes.params_block[3] = aes.int_out;
aes.params_block[4] = aes.addr_in;
aes.params_block[5] = aes.addr_out;
aes_reset();
aes.ctrl[0] = 10; /* opcode - appl_init */
aes.ctrl[2] = 1; /* int_out size in words */
aes.int_out[0] = 0xffff;
(void) aes_call();
if (((int16_t)aes.int_out[0]) < 0) {
PRINT("AES initialization (aes_appl_init) failed\n\r");
return 1;
}
aes.init_done = 1;
return 0;
}
static void aes_appl_exit (void)
{
if (!aes.init_done) {
return;
}
aes_reset();
aes.ctrl[0] = 19; /* opcode - appl_exit */
aes.ctrl[2] = 1; /* int_out size in words */
(void) aes_call();
if (aes.int_out[0] == 0) {
PRINT("AES cleanup (aes_appl_exit) failed\n\r");
}
}
static int aes_file_selector (unsigned int name_reset, char* path)
{
static char dir[256];
static char name[16];
char* p;
ASSERT(aes.init_done);
aes_reset();
aes.ctrl[0] = 90; /* opcode - fsel_input */
aes.ctrl[2] = 2; /* int_out size in words */
/* (fs_ireturn & fs_iexbutton) */
aes.ctrl[3] = 2; /* addr_in size in longs */
aes.addr_in[0] = dir; /* fs_iinpath */
aes.addr_in[1] = name; /* fs_iinsel */
if (dir[0] == '\0') {
cur_path_get(dir);
strcat(dir, "*.*");
}
if (name_reset) {
memset(name, '\0', 16);
}
(void) aes_call();
path[0] = '\0';
if (aes.int_out[0] == 0) {
PRINT("AES file selector (fsel_input) failed\n\r");
/* Error */
return 1;
}
if ((aes.int_out[1] == 0) || (name[0] == '\0')) {
/* No file selected */
return 1;
}
strcpy(path, dir);
p = strrchr(path, '\\');
p = p ? p + 1 : path;
strcpy(p, name);
return 0;
}
/*
* Prints a new line only if the last printed line is not empty.
*/
static void pp_newline (void)
{
static int log_count_nl;
if (log_count_nl != log_count) {
print("\n\r");
log_count_nl = log_count;
}
}
/*
* Interactive (IA) mode services.
*/
static int ia_mode_avail (void)
{
ASSERT(mouse_hid_count_p);
return !mouse_is_hidden;
}
#define DEC0DE_LOGO1 \
" _ _______ _ _______ _ _______ _ _______ _ _______ _ _______ \n\r" \
" ____\\\\__ / ___\\\\__ / ___\\\\__ / ___\\\\__ /____\\\\__ / ___\\\\__ / \n\r" \
" __/ __ /_/ __ /_/ _ /_/ _ / __ /_/ __ / \n\r" \
" \\ \\| /_\\ /___/_\\_ \\_____/_\\_ \\ /___ \\| /_\\ /___/___ s \n\r" \
" \\ \\ _\\_ __/ _/ \\ _/ \\ _/ \\ _\\_ __/ _/ n \n\r" \
" \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ s \n\r" \
" \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \n\r" \
" $ \\_______ D \\_______ E \\_______ C \\_______ 0 \\_______ D \\_______ E \\ \n\r" \
" \\_____\\ \\_____\\ \\_____\\ \\_____\\ \\_____\\ \\_____\\ \n\r"
#define DEC0DE_LOGO2 \
" _ _______ _ _______ _ _______ _ _______ _ _______ _ _______ \n\r" \
" ____\\\\__ /\\___\\\\__ /\\___\\\\__ /\\___\\\\__ /\\___\\\\__ /\\___\\\\__ /\\ \n\r" \
"__/ __ /_/ __ /_/ _ /_/ _ /_/ __ /_/ __ / / \n\r" \
"\\ \\| /_\\ /___/_\\_ \\_____/_\\_ \\ /___ \\| /_\\ /___/_/___ \n\r" \
" \\ \\ _\\_ __/ _/ \\ _/ \\ _/ \\ _\\_ __/ _/_/ \n\r" \
" \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \n\r" \
" \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \n\r" \
" $ \\_______ D \\_______ E \\_______ C \\_______ 0 \\_______ D \\_______ E \\ \\ \n\r" \
" sns \\_____\\/ \\_____\\/ \\_____\\/ \\_____\\/ \\_____\\/ \\_____\\/ \n\r"
#define DEC0DE_LOGO3 \
" ________ ________ ________ ________ ________ ________ \n\r" \
" ____\\\\__ / ___\\\\__ / ___\\\\__ / ___\\\\__ /____\\\\__ / ___\\\\__ / \n\r" \
" __/ /_/ /_/ /_/ / /_/ / \n\r" \
" \\ __ /_\\ _____/_\\_ ______/_\\_ ___ /___ __ /_\\ _____/___ s \n\r" \
" \\ \\ _\\__ __/ _/ \\ _/ \\ _/ \\ _\\__ __/ _/ n \n\r" \
" \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ s \n\r" \
" \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \n\r" \
" $ \\_______ D \\_______ E \\_______ C \\_______ 0 \\_______ D \\_______ E \\ \n\r" \
" \\_____\\ \\_____\\ \\_____\\ \\_____\\ \\_____\\ \\_____\\ \n\r"
#define DEC0DE_LOGO4 \
" _______ _______ _______ _______ _______ _______ \n\r" \
" ____\\\\__ / ___\\\\__ / ___\\\\__ / ___\\\\__ /____\\\\__ / ___\\\\__ / \n\r" \
" __/ /_/ /_/ /_/ / /_/ / \n\r" \
" \\ __ /_\\ _____/_\\_ ______/_\\_ ___ /___ __ /_\\ _____/___ s \n\r" \
" \\ \\| _\\__ __/ _/ \\| _/ \\| _/ \\| _\\__ __/ _/ n \n\r" \
" \\ \\ \\ \\| \\ \\ \\ \\ \\ \\ \\ \\| \\ s \n\r" \
" \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \n\r" \
" $ \\_______ D \\_______ E \\_______ C \\_______ 0 \\_______ D \\_______ E \\ \n\r" \
" \\_____\\ \\_____\\ \\_____\\ \\_____\\ \\_____\\ \\_____\\ \n\r"
#define DEC0DE_LOGO5 \
" _____ _____ \n\r" \
" _\\\\ \\ $ d e c 0 d e _\\\\ \\ \n\r" \
" ______/ _/\\_______ _/\\_______ _/\\_______ ______/ _/\\_______ \n\r" \
" \\\\\\_ __ \\\\\\_ __ \\\\\\_ __ \\\\\\_ __ \\\\\\_ __ \\\\\\_ __ \\\\ \n\r" \
" / / / / / / / / / / / / /\\ \n\r" \
" / / / / / / / / / / / / / / \n\r" \
" / / / / / /______/ / / / / / / / \n\r" \
" \\ / /\\ _______/\\ / /\\ / /\\ / /\\ _______/ / \n\r" \
" \\____ / /\\____ /\\/\\____ / /\\____ / /\\____ / /\\____ /\\/ \n\r" \
" \\\\__\\___/ / \\\\__\\___/ / \\\\__\\___/ / \\\\__\\___/ / \\\\__\\___/ / \\\\__\\___/ // \n\r" \
" \\__\\/ \\__\\/ \\__\\/ \\__\\/ \\__\\/ \\__\\/ sns \n\r"
#define DEC0DE_LOGO_FAVORITE 5
#define DEC0DE_LOGO_NR 5
#define LINE_FILL "\t\t\t\t\t\t\t\t\t\t"
static unsigned int rand_seed = 0;
static unsigned int logo_idx;
static int32_t rand_seed_set (void)
{
unsigned char cnt;
do {
cnt = *(volatile unsigned char*) 0xffff8207;
rand_seed = ((unsigned int) cnt) << 8;
cnt = *(volatile unsigned char*) 0xffff8209;
rand_seed |= ((unsigned int) cnt) << 0;
} while (rand_seed == 0);
return 0;
}
static inline const char* menu_text_get (void)
{
static char buf[82*25+1];
static const char* logos[DEC0DE_LOGO_NR] = {
DEC0DE_LOGO1,
DEC0DE_LOGO2,
DEC0DE_LOGO3,
DEC0DE_LOGO4,
DEC0DE_LOGO5,
};
unsigned int rand_nr;
if (rand_seed == 0) {
(void) supexec(rand_seed_set);
srand(rand_seed);
rand_nr = (unsigned int) rand();
/* Randomly choose a logo */
if (rand_nr & (1 << 8)) {
logo_idx = DEC0DE_LOGO_FAVORITE - 1;
} else {
logo_idx = rand_nr % DEC0DE_LOGO_NR;
}
} else {
logo_idx = (logo_idx + 1) % DEC0DE_LOGO_NR;
}
strcpy(buf,
CLEAR_HOME
WRAP_OFF
REV_ON
"\r" LINE_FILL "\n\r");
strcat(buf, logos[logo_idx]);
strcat(buf,
LINE_FILL "\n\r"
LINE_FILL "\r"
" " DEC0DE_VERSION_FULL " By " DEC0DE_TEAM ".\n\r"
LINE_FILL "\n\r"
REV_OFF
"\n\r"
REV_ON " 1 " REV_OFF " Dec0de a protected program\n\r"
REV_ON " 2 " REV_OFF " List supported protections\n\r"
REV_ON " 3 " REV_OFF " Detailed Information\n\r"
REV_ON " 4 " REV_OFF " Credits\n\r"
REV_ON " 5 " REV_OFF " Exit\n\r"
WRAP_ON);
return buf;
}
static int ia_mode_enter (void)
{
char path[256];
prog_t* prog;
int key;
int wait_return;
int diag;
ia_mode_usage = 1;
prog = NULL;
wait_return = 0;
do {
print(menu_text_get());
key = key_wait();
if ((key >= 'a') && (key <= 'z')) {
key = key + 'A' - 'a';
}
print(CLEAR_HOME);
switch(key)
{
case '1':
{
print("Select a program file");
linea_showm();
diag = aes_file_selector(1, path);
linea_hidem();
if (diag) {
break;
}
print(CLEAR_HOME);
prog = load_prog(path);
if (!prog) {
wait_return = 1;
break;
}
print(CLEAR_HOME);
diag = decode_prog(prog);
if (diag) {
wait_return = 1;
break;
}
PP_NEWLINE();
print("Save dec0ded program? " REV_ON " (Y/N) " REV_OFF);
do {
key = key_wait();
if ((key >= 'a') && (key <= 'z')) {
key = key + 'A' - 'a';
}
} while ((key != 'Y') && (key != 'N'));
if (key == 'N') {
break;
}
print(CLEAR_HOME "Choose a non-existing destination file name");
linea_showm();
diag = aes_file_selector(0, path);
linea_hidem();
if (diag) {
break;
}
print(CLEAR_HOME);
diag = save_prog(prog, path);
if (diag) {
wait_return = 1;
}
}
break;
case '2':
list_prots();
wait_return = 1;
break;
case '3':
info();
wait_return = 1;
break;
case '4':
credits();
wait_return = 1;
break;
default:
break;
}
if (prog) {
release_prog(prog);
prog = NULL;
}
if (wait_return) {
PP_NEWLINE();
print(REV_ON "Press any key to return to the menu" REV_OFF);
key_wait();
wait_return = 0;
}
} while (key != '5');
return 0;
}
/*
* Program start/exit hooks.
*/
static int prog_atstart (void)
{
int16_t color;
unsigned int rez;
unsigned int i;
if (linea_init()) {
return 1;
}
linea_hidem();
print(CLEAR_HOME CUR_OFF WRAP_ON "\r");
(void) supexec(conterm_setup);
rez = getrez();
for (i = 0; i < 16; i++) {
if ((rez == 0 && i == 15) ||
(rez == 1 && i == 3) ||
(rez == 2 && i == 1)) {
color = 0x0;
} else if (rez <= 2) {
color = 0xfff;
} else {
color = -1;
}
colors[i] = setcolor(i, color);
}
if ((1 + *cell_x_max_p) < 80) {
PRINT("Insufficient screen resolution\n\r"
"Try medium or higher resolution\n\r");
return 1;
}
return aes_appl_init();
}
static void prog_atexit (void)
{
unsigned int i;
if (!ia_mode_usage) {
PP_NEWLINE();
print(REV_ON "Press any key to quit" REV_OFF);
key_wait();
}
print(CLEAR_HOME);
for (i = 0; i < 16; i++) {
setcolor(i, colors[i]);
}
(void) supexec(conterm_restore);
linea_showm();
aes_appl_exit();
}
/*****************************************************************************
* Native (Atari ST) protection code execution helpers
*****************************************************************************/
/*
* Vectors and system variables are described at:
* http://dev-docs.atariforge.org/files/The_Atari_Compendium.pdf
*/
#define HW_VECTORS_COUNT (128 - 2)
#define VBL_QUEUE_MAX 32
#define READ16_VECTOR(_a) \
(*((uint16_t*) (_a)))
#define READ32_VECTOR(_a) \
(*((uint32_t*) (_a)))
#define SAVE_VECTOR(_d, _s) \
do { \
*(_d) = *(_s); \
} while (0)
#define SWAP_VECTOR(_d, _s) \
do { \
uint32_t _t = *(_s); \
*(_s) = *(_d); \
*(_d) = _t; \
} while (0)
/*
* For saving/restoring vectors before/after running a native protection code.
*/
static struct {
uint32_t hw[HW_VECTORS_COUNT]; /* $8-$200 */
uint32_t vlbq[VBL_QUEUE_MAX]; /* [$456] */
uint32_t prv_lst; /* $50a */
uint32_t prv_aux; /* $512 */
uint32_t resvalid; /* $426 */
uint32_t resvector; /* $42a */
} vectors;
/*
* Save Atari ST vectors.
*/
static int32_t save_vectors (void)
{
uint32_t* v;
unsigned int n;
unsigned int i;
v = (uint32_t*) 0x8; /* first vector, bus error */
for (i = 0; i < HW_VECTORS_COUNT; i++) {
SAVE_VECTOR(&vectors.hw[i], &v[i]);
}
n = (unsigned int) READ16_VECTOR(0x454); /* nvbls */
v = (uint32_t*) READ32_VECTOR(0x456); /* _vblqueue */
ASSERT(n <= VBL_QUEUE_MAX);
for (i = 0; i < n; i++) {
SAVE_VECTOR(&vectors.vlbq[i], &v[i]);
}
SAVE_VECTOR(&vectors.prv_lst, (uint32_t*) 0x50a);
SAVE_VECTOR(&vectors.prv_aux, (uint32_t*) 0x512);
SAVE_VECTOR(&vectors.resvalid, (uint32_t*) 0x426);
SAVE_VECTOR(&vectors.resvector, (uint32_t*) 0x42a);
return 0;
}
/*
* Restore Atari ST vectors.
*/
static int32_t restore_vectors (void)
{
uint32_t* v;
unsigned int n;
unsigned int i;
v = (uint32_t*) 0x8; /* first vector, bus error */
for (i = 0; i < HW_VECTORS_COUNT; i++) {
SWAP_VECTOR(&vectors.hw[i], &v[i]);
}
n = (unsigned int) READ16_VECTOR(0x454); /* nvbls */
v = (uint32_t*) READ32_VECTOR(0x456); /* _vblqueue */
for (i = 0; i < n; i++) {
SWAP_VECTOR(&vectors.vlbq[i], &v[i]);
}
SWAP_VECTOR(&vectors.prv_lst, (uint32_t*) 0x50a);
SWAP_VECTOR(&vectors.prv_aux, (uint32_t*) 0x512);
SWAP_VECTOR(&vectors.resvalid, (uint32_t*) 0x426);
SWAP_VECTOR(&vectors.resvector, (uint32_t*) 0x42a);
return 0;
}
/*
* For disabling/restoring cache before/after running a native protection code.
*/
static uint32_t cache_flag;
/*
* Disable cache, to allow self-modifying code.
*/
static int32_t disable_cache (void)
{
register uint32_t cf;
__asm__ __volatile__
(
"move.l 0x10.l,%%sp@- \n\t"
"movea.l %%sp,%%a0 \n\t"
"lea 1f(pc),%%a1 \n\t"
"move.l %%a1,0x10.l \n\t"
" \n\t"
"moveq.l #0,%0 \n\t"
"dc.w 0x4e7a,0x0002 ;# MOVEC CACR,%%d0 \n\t"
"move.l %%d0,%0 \n\t"
"bclr #0,%%d0 \n\t"
"dc.w 0x4e7b,0x0002 ;# MOVEC %%d0,CACR \n\t"
"1: \n\t"
"movea.l %%a0,%%sp \n\t"
"move.l %%sp@+,0x10.l \n\t"
: "=d" (cf)
:
: "cc", "%%d0", "%%a0", "%%a1", "memory"
);
cache_flag = cf;
return 0;
}
/*
* Restore cache.
*/
static int32_t restore_cache (void)
{
__asm__ __volatile__
(
"move.l 0x10.l,%%sp@- \n\t"
"movea.l %%sp,%%a0 \n\t"
"lea 1f(pc),%%a1 \n\t"
"move.l %%a1,0x10.l \n\t"
" \n\t"
"move.l %0,%%d0 \n\t"
"dc.w 0x4e7b,0x0002 ;# MOVEC %%d0,CACR \n\t"
"1: \n\t"
"movea.l %%a0,%%sp \n\t"
"move.l %%sp@+,0x10.l \n\t"
:
: "g" (cache_flag)
: "cc", "%%d0", "%%a0", "%%a1", "memory"
);
return 0;
}
#define IDX_D0_REG 0
#define IDX_D1_REG 1
#define IDX_D2_REG 2
#define IDX_D3_REG 3
#define IDX_D4_REG 4
#define IDX_D5_REG 5
#define IDX_D6_REG 6
#define IDX_D7_REG 7
#define IDX_A0_REG 8
#define IDX_A1_REG 9
#define IDX_A2_REG 10
#define IDX_A3_REG 11
#define IDX_A4_REG 12
#define IDX_A5_REG 13
#define IDX_A6_REG 14
#define IDX_A7_REG 15
static uint32_t registers[16];
#define IDX_PROT_ENTRY_RUNPROT 0
#define IDX_TRAMPOLINE_ADDR_RUNPROT 1
#define IDX_NEW_SSP_RUNPROT 2
#define IDX_SUP_MODE_RUNPROT 3
#define IDX_RESTORE_VECS_RUNPROT 4
#define IDX_REGS_RUNPROT 5
#define IDX_SR_RUNPROT 6
#define IDX_SSP_RUNPROT 7
#define IDX_A6_RUNPROT 8
#define IDX_A7_RUNPROT 9
#define IDX_RET_ADDR_RUNPROT 10
#define IDX_MAX_RUNPROT 11
#define ASM_IDX_RUNPROT(_n) __ASM_STR(4 * IDX_##_n##_RUNPROT)
#define SET_PARAM_RUNPROT(_n, _v) \
params.val[IDX_##_n##_RUNPROT] = (uint32_t) (_v)
/*
* Execute a protection code, natively on the Atari ST.
*
* The following parameters are passed:
* - The entry point address of the protection code.
* - The address where the "resuming trampoline" should be installed.
* The "resuming trampoline" is a routine that should be called from the
* native protection code to resume the normal execution of dec0de.
* - The address of the supervisor stack pointer (optional, NULL can be passed
* to use the default SSP).
* - A boolean to indicate if the protection code should be executed in the
* supervisor mode or not.
*
* Prior to jumping into the protection code, the vectors are saved, the
* cache is disabled and the registers are initialized with the content of
* the global 'registers' array.
*
* On return from the protection code, The "resuming trampoline" saves the
* registers (as left by the protection code) into the global 'registers'
* array and restores their initial values, it also restores the vectors and
* resumes the execution of the 'run_prot' function.
* That function restores the cache and returns to the caller.
*/
static void run_prot (void* prot_entry, void* trampoline_addr,
void* new_ssp, unsigned int sup_mode)
{
static struct {
uint32_t val[IDX_MAX_RUNPROT];
} params asm("runprot_params") USED;
SET_PARAM_RUNPROT(PROT_ENTRY, prot_entry);
SET_PARAM_RUNPROT(TRAMPOLINE_ADDR, trampoline_addr);
SET_PARAM_RUNPROT(NEW_SSP, new_ssp);
SET_PARAM_RUNPROT(SUP_MODE, sup_mode);
SET_PARAM_RUNPROT(RESTORE_VECS, restore_vectors);
SET_PARAM_RUNPROT(REGS, registers);
(void) supexec(save_vectors);
(void) supexec(disable_cache);
__asm__ __volatile__
(
"movem.l %%d2-%%d7/%%a2-%%a5,%%sp@- \n\t"
" \n\t"
"lea runprot_params,%%a2 \n\t"
" \n\t"
"move %%sr,%%d0 \n\t"
"move.w %%d0,%%a2@(" ASM_IDX_RUNPROT(SR) ") \n\t"
"move.l %%a6,%%a2@(" ASM_IDX_RUNPROT(A6) ") \n\t"
"move.l %%sp,%%a2@(" ASM_IDX_RUNPROT(A7) ") \n\t"
"lea 8f(pc),%%a0 \n\t"
"move.l %%a0,%%a2@(" ASM_IDX_RUNPROT(RET_ADDR) ") \n\t"
" \n\t"
"clr.l %%sp@- \n\t"
"move.w #32,%%sp@- \n\t"
"trap #1 \n\t"
" \n\t"
"move.l %%d0,%%a2@(" ASM_IDX_RUNPROT(SSP) ") \n\t"
"move.l %%a2@(" ASM_IDX_RUNPROT(NEW_SSP) "),%%d2 \n\t"
"beq.s 2f \n\t"
"move.l %%d2,%%d0 \n\t"
"2: movea.l %%d0,%%sp \n\t"
" \n\t"
"lea 5f(pc),%%a0 \n\t"
"movea.l %%a2@(" ASM_IDX_RUNPROT(TRAMPOLINE_ADDR) "),%%a1\n\t"
"moveq.l #(8f-5f+3)/4-1,%%d0 \n\t"
"3: move.l %%a0@+,%%a1@+ \n\t"
"dbf %%d0,3b \n\t"
" \n\t"
"move.w %%a2@(" ASM_IDX_RUNPROT(SR) "),%%d0 \n\t"
"tst.l %%a2@(" ASM_IDX_RUNPROT(SUP_MODE) ") \n\t"
"beq.s 4f \n\t"
"or.w #0x2000,%%d0 \n\t"
"4: move.l %%a2@(" ASM_IDX_RUNPROT(PROT_ENTRY) "),%%sp@- \n\t"
"move.w %%d0,%%sp@- \n\t"
" \n\t"
"movea.l %%a2@(" ASM_IDX_RUNPROT(REGS) "),%%a0 \n\t"
"movem.l %%a0@,%%d0-%%d7/%%a0-%%a5 \n\t"
" \n\t"
"rte \n\t"
" \n\t"
"5: \n\t"
"move.l %%a2,%%sp@- \n\t"
"lea runprot_params,%%a2 \n\t"
"movea.l %%a2@(" ASM_IDX_RUNPROT(REGS) "),%%a2 \n\t"
"movem.l %%d0-%%d7/%%a0-%%a6,%%a2@ \n\t"
"move.l %%sp@+,%%a2@(10*4) \n\t"
" \n\t"
"lea runprot_params,%%a2 \n\t"
"movea.l %%a2@(" ASM_IDX_RUNPROT(SSP) "),%%sp \n\t"
"move %%sr,%%d0 \n\t"
"and.w #0x3fff,%%d0 \n\t"
"or.w #0x0700,%%d0 \n\t"
"move %%d0,%%sr ;# IPL7, trace off \n\t"
" \n\t"
"movea.l %%a2@(" ASM_IDX_RUNPROT(RESTORE_VECS) "),%%a0 \n\t"
"jsr %%a0@ \n\t"
" \n\t"
"move.l %%a2@(" ASM_IDX_RUNPROT(RET_ADDR) "),%%sp@- \n\t"
"move.w %%a2@(" ASM_IDX_RUNPROT(SR) "),%%sp@- \n\t"
"rte \n\t"
" \n\t"
"8: ;# return address \n\t"
"movea.l %%a2@(" ASM_IDX_RUNPROT(A6) "),%%a6 \n\t"
"movea.l %%a2@(" ASM_IDX_RUNPROT(A7) "),%%sp \n\t"
" \n\t"
"movem.l %%sp@+,%%d2-%%d7/%%a2-%%a5 \n\t"
:
:
: "cc", "%%d0", "%%d1", "%%a0", "%%a1", "memory"
);
(void) supexec(restore_cache);
}
/*****************************************************************************
* Copylock Protection System by Rob Northen - Atari ST helper routines
*****************************************************************************/
/*
* Print a message and wait for the original disk to be inserted in the
* floppy drive.
*/
static int wait_prot (int keydisk)
{
int lc;
int key;
lc = log_count;
print(SAVE_POS);
PP_NEWLINE();
if (keydisk) {
print(REV_ON
"Insert original disk and press any key, or press 'C' to cancel"
REV_OFF);
key = key_wait();
if ((key == 'c') || (key == 'C')) {
print(CLEAR_SOL "\r"
"Dec0ding canceled!\n\r");
log_count++;
return 1;
}
}
print(CLEAR_SOL "\r"
"Please wait while running the native protection code...");
print(LOAD_POS);
log_count = lc;
return 0;
}
static void end_wait_prot (void)
{
print(CLEAR_DOWN);
}
/*****************************************************************************
*
* Copylock Protection System series 1 (1988) by Rob Northen
* Atari ST specific code
*
* Dynamic (run-time) analysis of the protection.
*
* Since the static analysis cannot be performed systematically (it is not
* possible for the wrapper type), a complex dynamic analysis is performed
* instead, in order to obtain all the required static and dynamic information:
* the location and behavior of the different parts of the protection,
* the value of the serial key, the decrypted program and its execution
* context.
* Such complex dynamic analysis is performed for both the internal and the
* wrapper type (although some information is already available for the
* internal type, as result of the static analysis).
*
* The run-time analysis works as follows: the series 1 uses a single and
* static (in place) TVD routine. Dec0de replaces this TVD routine with
* a new one which behaves in the same way but which performs additional
* on-the-fly checks.
* Each instruction of the protection (which triggers the TVD routine) is
* checked in order to:
* - avoid the trace vector to be modified.
* - avoid vectors to be checked.
* - avoid an invalid disk buffer to be used.
* - determine if a key disk is read.
* - determine the value of the serial key.
* - determine the memory location where the serial key is saved to.
* - determine if an extra magic value is computed from the serial key.
* - determine the memory location where the extra magic value is saved to.
* - decrypt the wrapped program if any.
* - determine if the wrapped program is a GEMDOS or a binary program.
* - determine the execution context of the program (destination address).
*
*****************************************************************************/
#define TRAMPOLINE_ADDR_ROBN88 0x200
#define FLAG_VECS_SETUP_ROBN88 0
#define FLAG_VECS_CHECK_ROBN88 1
#define FLAG_KEY_DISK_ROBN88 2
#define FLAG_SERIAL_ROBN88 3
#define FLAG_MAGIC_ROBN88 4
#define FLAG_PROG_RESUME_ROBN88 5
#define FLAG_NR_ROBN88 6
#define ASM_FLAG_ROBN88(_n) __ASM_STR(FLAG_##_n##_ROBN88)
#define IDX_ILLVEC_CONT_ROBN88 0
#define IDX_TVD_PINSTR_ROBN88 1
#define IDX_TVD_TYPE_ROBN88 2
#define IDX_TRAMPOLINE_ROBN88 3
#define IDX_DISK_BUFFER_ROBN88 4
#define IDX_PROG_START_ROBN88 5
#define IDX_SERIAL_PTR_ROBN88 6
#define IDX_SERIAL_DST_PTR_ROBN88 7
#define IDX_SERIAL_ONLY_ROBN88 8
#define IDX_MAGIC_PTR_ROBN88 9
#define IDX_MAGIC_DST_PTR_ROBN88 10
#define IDX_PROG_RESUME_ROBN88 11
#define IDX_FLAGS_ROBN88 12
#define IDX_MAX_ROBN88 16
#define ASM_IDX_ROBN88(_n) __ASM_STR(4 * IDX_##_n##_ROBN88)
#define SET_PARAM_ROBN88(_n, _v) \
params.val[IDX_##_n##_ROBN88] = (uint32_t) (_v)
static uint32_t serial_robn88;
static uint32_t* serial_dst_robn88;
static uint32_t magic_robn88;
static uint32_t* magic_dst_robn88;
static unsigned char* prog_resume_robn88;
static unsigned char* prog_start_robn88;
static uint8_t flags_robn88[FLAG_NR_ROBN88];
/*
* Provides the TVD routine used during dynamic analysis and returns
* the address of the code snippet which is in charge of installing
* dec0de's illegal handler (which, in turn, installs the TVD routine).
*
* Each instruction of the protection code triggers the following TVD routine
* (instead of the protection one) which performs on-the-fly checks.
*
* The protection code of the series 1 has evolved slightly over time.
* A particular code logic may have been implemented in different ways
* (typically the vectors checking). The following TVD routine takes
* all variants of the same code logic into account.
*
* In order to replace the TVD routine of the protection with dec0de's
* TVD routine, the protection code prolog is patched as follows:
* the instruction which installs the illegal handler of the protection is
* replaced with a 'Jump to SubRoutine/JSR' to 'label 1' (see below).
* When 'label 1' is called by the protection prolog, dec0de's illegal
* handler is installed (replacing that of the protection), the original
* protection code prolog is restored and the execution of the protection
* prolog is resumed.
* When dec0de's illegal handler is invoked, it mimics the behavior of the
* original illegal handler: it pushes the expected registers onto the stack,
* it installs the trace handler (and thus dec0de's TVD routine) and it ends
* with a jump to the original illegal handler to complete the handling of
* the illegal exception.
*
* When dec0de's trace handler is invoked, it mimics the behavior of the
* original TVD routine: it re-encodes the previously decrypted instruction
* and decodes the next one. Then it performs on-the-fly checks for each
* decoded instruction.
*
* illvec_cont: where to jump on exit from dec0de's illegal handler in order
* to complete the handling of the illegal exception.
*
* tvd_pinstr: address used by the protection code to save the address of
* the currently decoded instruction and its original encrypted
* value. This address is also used by dec0de's TVD routine for
* the same purpose.
*
* tvd_type: 2 different encryption schemes can be used by the series 1.
* This parameter indicates which one is used by the current
* protection code.
*
* disk_buf: buffer where the key disk sectors should be read to.
*
* serial_only: this flag is set if the current protection is an internal type.
*/
static uint32_t tvd_robn88 (void* illvec_cont, void* tvd_pinstr, int tvd_type,
void* disk_buf, int serial_only)
{
register uint32_t entry;
static struct {
uint32_t val[IDX_MAX_ROBN88];
} params asm("tvd_params_robn88") USED;
SET_PARAM_ROBN88(ILLVEC_CONT, illvec_cont);
SET_PARAM_ROBN88(TVD_PINSTR, tvd_pinstr);
SET_PARAM_ROBN88(TVD_TYPE, tvd_type);
SET_PARAM_ROBN88(TRAMPOLINE, TRAMPOLINE_ADDR_ROBN88);
SET_PARAM_ROBN88(DISK_BUFFER, disk_buf);
SET_PARAM_ROBN88(PROG_START, &prog_start_robn88);
SET_PARAM_ROBN88(SERIAL_PTR, &serial_robn88);
SET_PARAM_ROBN88(SERIAL_DST_PTR, &serial_dst_robn88);
SET_PARAM_ROBN88(SERIAL_ONLY, serial_only);
SET_PARAM_ROBN88(MAGIC_PTR, &magic_robn88);
SET_PARAM_ROBN88(MAGIC_DST_PTR, &magic_dst_robn88);
SET_PARAM_ROBN88(PROG_RESUME, &prog_resume_robn88);
SET_PARAM_ROBN88(FLAGS, flags_robn88);
__asm__ __volatile__
(
"lea 1f(pc),%0 \n\t"
"bra 2f \n\t"
"1: ;# Installs dec0de's illegal handler, restores the \n\t"
" ;# protection code prolog and returns to the caller \n\t"
"move.l %%a0,%%sp@- \n\t"
"lea 3f(pc),%%a0 \n\t"
"move.l %%a0,0x10.w \n\t"
"movea.l %%sp@(4),%%a0 \n\t"
"move.w #0x23c8,%%a0@(-6) \n\t"
"move.l #0x10,%%a0@(-4) \n\t"
"movea.l %%sp@+,%%a0 \n\t"
"rts \n\t"
" \n\t"
"3: ;# illegal handler - installs the TVD routine \n\t"
"movem.l %%d0/%%a0-%%a1,%%sp@- \n\t"
"lea 4f(pc),%%a0 \n\t"
"move.l %%a0,0x24.w \n\t"
"lea tvd_params_robn88,%%a0 \n\t"
"move.l %%a0@(" ASM_IDX_ROBN88(ILLVEC_CONT) "),%%sp@- \n\t"
"rts \n\t"
" \n\t"
"4: ;# trace handler (TVD routine) \n\t"
"andi.w #0xf8ff,%%sr \n\t"
"movem.l %%d0/%%a0-%%a1,%%sp@- \n\t"
"lea tvd_params_robn88,%%a0 \n\t"
"movea.l %%a0@(" ASM_IDX_ROBN88(TVD_PINSTR) "),%%a1 \n\t"
"move.l %%a0@(" ASM_IDX_ROBN88(TVD_TYPE) "),%%d0 \n\t"
"movea.l %%a1@,%%a0 \n\t"
"cmpi.w #"__ASM_STR(PROT_TVD_FSHARK_ROBN88)",%%d0 \n\t"
"bne 50f ;# tvd_common \n\t"
" \n\t"
";# tvd_fshark - 'Flying Shark'-like encryption logic \n\t"
"move.l %%a0@(-4),%%d0 \n\t"
"sub.l %%d3,%%d0 \n\t"
"not.l %%d0 \n\t"
"swap %%d0 \n\t"
"eor.l %%d0,%%a0@ \n\t"
"movea.l %%sp@(14),%%a0 \n\t"
"move.l %%a0@(-4),%%d0 \n\t"
"sub.l %%d3,%%d0 \n\t"
"not.l %%d0 \n\t"
"swap %%d0 \n\t"
"eor.l %%d0,%%a0@ \n\t"
"move.l %%a0,%%a1@ \n\t"
"bra 60f ;# intercept_instrs \n\t"
" \n\t"
"50: ;# tvd_common - Most commonly used encryption logic \n\t"
"move.l %%a1@(4),%%a0@ \n\t"
"movea.l %%sp@(14),%%a0 \n\t"
"move.l %%a0,%%a1@ \n\t"
"move.l %%a0@,%%a1@(4) \n\t"
"move.l %%a0@(-4),%%d0 \n\t"
"not.l %%d0 \n\t"
"swap %%d0 \n\t"
"eor.l %%d0,%%a0@ \n\t"
" \n\t"
"60: ;# intercept_instrs - Intercept decoded instructions \n\t"
"move.w %%a0@,%%d0 \n\t"
" \n\t"
";# Intercept prot vectors setup \n\t"
"cmpi.w #0x22c1,%%d0 ;# move.l d1,(a1)+ \n\t"
"bne 110f ;# chk_vecs \n\t"
"100: ;# chk_ill - Intercept illegal vector setup \n\t"
"cmpi.l #0x10,%%sp@(8) ;# (a1 = 8(sp)) == $10 ? \n\t"
"bne 105f ;# chk_trace \n\t"
"move.l 0x10.w,%%d1 ;# d1 = illegal handler \n\t"
"bra 9999f ;# tvd_cont \n\t"
"105: ;# chk_trace - Intercept trace vector setup \n\t"
"cmpi.l #0x24,%%sp@(8) ;# (a1 = 8(sp)) == $24 ? \n\t"
"bne 9999f ;# tvd_cont \n\t"
"move.l 0x24.w,%%d1 ;# d1 = trace handler \n\t"
"lea tvd_params_robn88,%%a1 \n\t"
"movea.l %%a1@(" ASM_IDX_ROBN88(FLAGS) "),%%a1 \n\t"
"st.b %%a1@(" ASM_FLAG_ROBN88(VECS_SETUP) ") \n\t"
"bra 9999f ;# tvd_cont \n\t"
" \n\t"
"110: ;# chk_vecs - Intercept vectors checking \n\t"
" ;# Two variants are supported: \n\t"
" ;# - cmpi.l <vec_base>,d[0|1] \n\t"
" ;# - cmpi.l <vec_base>,<off>(a[0|1]) \n\t"
"cmpi.l #0xfc0000,%%a0@(2) \n\t"
"bne 120f ;# chk_diskbuf \n\t"
"cmpi.w #0xb0bc,%%d0 ;# cmpi.l #$fc0000,d0 \n\t"
"bne 111f ;# chk_vecs_d1 \n\t"
"move.l #0xfc0000,%%sp@ ;# (sp) = d0 = #$fc0000 \n\t"
"bra 117f ;# chk_vecs_end \n\t"
"111: ;# chk_vecs_d1 \n\t"
"cmpi.w #0xb2bc,%%d0 ;# cmpi.l #$fc0000,d1 \n\t"
"bne 112f ;# chk_vecs_a1 \n\t"
"move.l #0xfc0000,%%d1 ;# d1 = #$fc0000 \n\t"
"bra 117f ;# chk_vecs_end \n\t"
"112: ;# chk_vecs_a1 \n\t"
"cmpi.w #0x0c91,%%d0 ;# cmpi.l #$fc0000,(a1) \n\t"
"bne 113f ;# chk_vecs_a0 \n\t"
"lea 500f(pc),%%a1 ;# vecs_fake \n\t"
"move.l %%a1,%%sp@(8) ;# 8(sp) = a1 = vecs_fake \n\t"
"bra 117f ;# chk_vecs_end \n\t"
"113: ;# chk_vecs_a0 \n\t"
"cmpi.w #0x0ca8,%%d0 ;# cmpi.l #$fc0000,-4(a0) \n\t"
"bne 120f ;# chk_diskbuf \n\t"
"lea 500f(pc),%%a1 ;# vecs_fake \n\t"
"move.l %%a1,%%sp@(4) ;# 4(sp) = a0 = vecs_fake \n\t"
"bra 117f ;# chk_vecs_end \n\t"
"nop \n\t"
"117: ;# chk_vecs_end \n\t"
"lea tvd_params_robn88,%%a1 \n\t"
"movea.l %%a1@(" ASM_IDX_ROBN88(FLAGS) "),%%a1 \n\t"
"st.b %%a1@(" ASM_FLAG_ROBN88(VECS_CHECK) ") \n\t"
"bra 9999f ;# tvd_cont \n\t"
" \n\t"
"120: ;# chk_diskbuf - Intercept disk buffer setup \n\t"
"cmpi.w #0x0880,%%d0 ;# bclr #0,d0 \n\t"
"bne 130f ;# chk_keydisk \n\t"
"movea.l %%sp@,%%a1 ;# d0 = (sp) = prot disk buffer \n\t"
"cmpa.l %%a0,%%a1 \n\t"
"blo 9999f ;# tvd_cont \n\t"
"suba.l %%a0,%%a1 \n\t"
"cmpa.l #0x100000,%%a1 \n\t"
"bhs 9999f ;# tvd_cont \n\t"
"lea tvd_params_robn88,%%a1 \n\t"
"movea.l %%a1@(" ASM_IDX_ROBN88(DISK_BUFFER) "),%%a1 \n\t"
"move.l %%a1,%%sp@ ;# (sp) = d0 = new disk buffer \n\t"
"bra 9999f ;# tvd_cont \n\t"
" \n\t"
"130: ;# chk_keydisk - Intercept key disk usage \n\t"
"cmpi.l #0x0000043e,%%a0@(2) \n\t"
"bne 140f ;# chk_serial \n\t"
"cmpi.w #0x50f9,%%d0 ;# st $43e \n\t"
"bne 140f ;# chk_serial \n\t"
"lea tvd_params_robn88,%%a1 \n\t"
"movea.l %%a1@(" ASM_IDX_ROBN88(FLAGS) "),%%a1 \n\t"
"st.b %%a1@(" ASM_FLAG_ROBN88(KEY_DISK) ") \n\t"
"bra 9999f ;# tvd_cont \n\t"
" \n\t"
"140: ;# chk_serial - Intercept serial saving \n\t"
"cmpi.w #0x2140,%%d0 \n\t"
"bne 150f ;# chk_badserial \n\t"
"cmpi.w #0x1c,%%a0@(2) ;# move.l d0,$1c(a0) \n\t"
"bne 9999f ;# tvd_cont \n\t"
"move.l %%sp@,%%d0 ;# d0 = (sp) = serial number \n\t"
"lea tvd_params_robn88,%%a0 \n\t"
"movea.l %%a0@(" ASM_IDX_ROBN88(FLAGS) "),%%a1 \n\t"
"st.b %%a1@(" ASM_FLAG_ROBN88(SERIAL) ") \n\t"
"movea.l %%a0@(" ASM_IDX_ROBN88(SERIAL_DST_PTR) "),%%a1 \n\t"
"move.l #0x1c+8,%%a1@ \n\t"
"movea.l %%a0@(" ASM_IDX_ROBN88(SERIAL_PTR) "),%%a1 \n\t"
"move.l %%d0,%%a1@ \n\t"
"tst.l %%a0@(" ASM_IDX_ROBN88(SERIAL_ONLY) ") \n\t"
"bne 8888f ;# tvd_stop \n\t"
"tst.l %%d0 \n\t"
"beq 8888f ;# tvd_stop \n\t"
"bra 9999f ;# tvd_cont \n\t"
" \n\t"
"150: ;# chk_badserial - Intercept bad serial \n\t"
"cmpi.w #0xd880,%%d0 ;# add.l d0,d4 \n\t"
"bne 160f ;# chk_magic \n\t"
"lea tvd_params_robn88,%%a0 \n\t"
"movea.l %%a0@(" ASM_IDX_ROBN88(FLAGS) "),%%a1 \n\t"
"tst.b %%a1@(" ASM_FLAG_ROBN88(KEY_DISK) ") \n\t"
"beq 9999f ;# tvd_cont \n\t"
"tst.b %%a1@(" ASM_FLAG_ROBN88(SERIAL) ") \n\t"
"bne 9999f ;# tvd_cont \n\t"
"move.l %%sp@,%%d0 ;# d0 = (sp) = serial number \n\t"
"tst.l %%d0 ;# bad serial if 0 \n\t"
"bne 9999f ;# tvd_cont \n\t"
"st.b %%a1@(" ASM_FLAG_ROBN88(SERIAL) ") \n\t"
"movea.l %%a0@(" ASM_IDX_ROBN88(SERIAL_PTR) "),%%a0 \n\t"
"move.l %%d0,%%a0@ \n\t"
"bra 8888f ;# tvd_stop \n\t"
" \n\t"
"160: ;# chk_magic - Intercept magic saving \n\t"
"cmpi.w #0x23c7,%%d0 ;# move.l d7,$addr \n\t"
"bne 200f ;# chk_decode \n\t"
"move.l %%a0@(2),%%d0 ;# d0 = magic dest. address \n\t"
"lea tvd_params_robn88,%%a0 \n\t"
"movea.l %%a0@(" ASM_IDX_ROBN88(FLAGS) "),%%a1 \n\t"
"st.b %%a1@(" ASM_FLAG_ROBN88(MAGIC) ") \n\t"
"movea.l %%a0@(" ASM_IDX_ROBN88(MAGIC_DST_PTR) "),%%a1 \n\t"
"move.l %%d0,%%a1@ \n\t"
"movea.l %%a0@(" ASM_IDX_ROBN88(MAGIC_PTR) "),%%a0 \n\t"
"move.l %%d7,%%a0@ ;# d7 = magic number \n\t"
"bra 9999f ;# tvd_cont \n\t"
" \n\t"
"200: ;# chk_decode - Intercept end of prog decoding \n\t"
"cmpi.w #0x601a,%%a0@(2) \n\t"
"bne 300f ;# chk_end \n\t"
"cmpi.w #0x0c50,%%d0 ;# cmpi.w #$601a,(a0) \n\t"
"bne 300f ;# chk_end \n\t"
"lea tvd_params_robn88,%%a0 \n\t"
"movea.l %%a0@(" ASM_IDX_ROBN88(PROG_START) "),%%a1 \n\t"
"cmpi.l #0,%%a1@ \n\t"
"beq 210f ;# chk_decode_hdr \n\t"
"movea.l %%a0@(" ASM_IDX_ROBN88(FLAGS) "),%%a1 \n\t"
"st.b %%a1@(" ASM_FLAG_ROBN88(PROG_RESUME) ") \n\t"
"bra 9999f ;# tvd_cont \n\t"
"210: ;# chk_decode_hdr \n\t"
"movea.l %%sp@(4),%%a0 ;# a0 = 4(sp) = start of prog \n\t"
"move.l %%a0,%%a1@ \n\t"
"cmpi.w #0x601a,%%a0@ \n\t"
"beq 8888f ;# tvd_stop \n\t"
"bra 9999f ;# tvd_cont \n\t"
" \n\t"
"300: ;# chk_end - Intercept end of protection \n\t"
" ;# Three variants of the end of the trampoline code \n\t"
" ;# (resume to normal code) are supported: \n\t"
" ;# - rte \n\t"
" ;# - rts (using usp or ssp) \n\t"
" ;# - jmp \n\t"
"cmpi.w #0x4afc,%%d0 ;# illegal \n\t"
"bne 400f ;# chk_end_internal \n\t"
"lea tvd_params_robn88,%%a0 \n\t"
"movea.l %%a0@(" ASM_IDX_ROBN88(FLAGS) "),%%a1 \n\t"
"cmpi.b #0,%%a1@(" ASM_FLAG_ROBN88(PROG_RESUME) ") \n\t"
"beq 9999f ;# tvd_cont \n\t"
"movea.l %%sp@(3*4+6),%%a1 ;# trampoline start addr \n\t"
"310: ;# chk_end_lp1 \n\t"
"cmpi.w #0x4e73,%%a1@ ;# rte \n\t"
"bne 320f ;# chk_end_lp2 \n\t"
"move.l %%sp@(3*4+6+4+4*15+2),%%d0 \n\t"
"bra 360f ;# chk_end_lp6 \n\t"
"320: ;# chk_end_lp2 \n\t"
"cmpi.w #0x4e75,%%a1@ ;# rts \n\t"
"bne 340f ;# chk_end_lp4 \n\t"
"lea %%sp@(3*4+6+4),%%a1 \n\t"
"move.w %%a1@+,%%d0 \n\t"
"btst #13,%%d0 \n\t"
"bne 330f ;# chk_end_lp3 \n\t"
"move.l %%usp,%%a1 \n\t"
"330: ;# chk_end_lp3 \n\t"
"move.l %%a1@(4*15),%%d0 \n\t"
"bra 360f ;# chk_end_lp6 \n\t"
"340: ;# chk_end_lp4 \n\t"
"cmpi.w #0x4ef9,%%a1@ ;# jmp \n\t"
"bne 350f ;# chk_end_lp5 \n\t"
"move.l %%a1@(2),%%d0 \n\t"
"bra 360f ;# chk_end_lp6 \n\t"
"350: ;# chk_end_lp5 \n\t"
"lea %%a1@(2),%%a1 \n\t"
"bra 310b ;# chk_end_lp1 \n\t"
"360: ;# chk_end_lp6 \n\t"
"movea.l %%a0@(" ASM_IDX_ROBN88(PROG_RESUME) "),%%a0 \n\t"
"move.l %%d0,%%a0@ ;# resume address \n\t"
"bra 8888f ;# tvd_stop \n\t"
" \n\t"
"400: ;# chk_end_internal - Intercept end of internal prot \n\t"
"cmpi.w #0x2f48,%%d0 \n\t"
"bne 9999f ;# tvd_cont \n\t"
"cmpi.w #2,%%a0@(2) ;# move.l a0,2(a7) \n\t"
"bne 9999f ;# tvd_cont \n\t"
"lea tvd_params_robn88,%%a0 \n\t"
"tst.l %%a0@(" ASM_IDX_ROBN88(SERIAL_ONLY) ") \n\t"
"beq 9999f ;# tvd_cont \n\t"
"movea.l %%a0@(" ASM_IDX_ROBN88(FLAGS) "),%%a1 \n\t"
"tst.b %%a1@(" ASM_FLAG_ROBN88(KEY_DISK) ") \n\t"
"beq 9999f ;# tvd_cont \n\t"
"st.b %%a1@(" ASM_FLAG_ROBN88(SERIAL) ") \n\t"
";# Fall through \n\t"
" \n\t"
"8888: ;# tvd_stop \n\t"
"lea tvd_params_robn88,%%a0 \n\t"
"move.l %%a0@(" ASM_IDX_ROBN88(TRAMPOLINE) "),%%sp@(14) \n\t"
"and.w #0x3fff,%%sp@(12) \n\t"
";# Fall through \n\t"
" \n\t"
"9999: ;# tvd_cont \n\t"
"movem.l %%sp@+,%%d0/%%a0-%%a1 \n\t"
"rte \n\t"
"nop \n\t"
"nop \n\t"
"nop \n\t"
"dc.l 0xfc0000 \n\t"
"500: #; vecs_fake \n\t"
"dc.l 0xfc0000 \n\t"
"nop \n\t"
"2: \n\t"
: "=a" (entry)
:
: "cc", "memory"
);
/*
* Returns the address of the code snippet which installs dec0de's
* illegal handler.
*/
return entry;
}
/*
* Dynamic analysis providing both the static and dynamic information
* about the protection.
*
* The dynamic analysis relies on the above TVD routine.
*/
static int decode_native_robn88 (prog_t* prog, info_robn_t* info)
{
prot_t* prot = prog->prot;
unsigned char* illtrig;
unsigned char* illvec_cont;
unsigned char* tvd_pinstr_off;
unsigned char* tvd_pinstr;
void* disk_buf;
uint32_t entry;
unsigned int i;
ASSERT((info->decode_off >= 0) || (info->serial_off >= 0));
/*
* Get the address of the protection code prolog which will be patched
* for the installation of dec0de's illegal handler.
*/
illtrig = prog->text + prot->patterns[2]->eoffset + (SIZE_16*2);
ASSERT(read32(illtrig + SIZE_16) == 0x10);
/*
* Get the address where to jump on exit from dec0de's illegal handler
* in order to complete the handling of the illegal exception.
*/
illvec_cont = prog->text + prot->patterns[3]->eoffset;
illvec_cont += (4 + 4 + 6);
ASSERT(read16(illvec_cont) == 0x41fa);
/*
* Get the address used by the protection code to save the information
* about the currently traced instruction (address and encrypted opcode).
*/
tvd_pinstr_off = prog->text + prot->patterns[4]->eoffset;
tvd_pinstr_off += (4 + 4 + 2);
ASSERT(read16(tvd_pinstr_off - SIZE_16) == 0x43fa);
tvd_pinstr = tvd_pinstr_off + (ssize_t) (int16_t) read16(tvd_pinstr_off);
/* Allocate a buffer for the key disk reading */
disk_buf = malloc(8192);
if (!disk_buf) {
LOG_ERROR("Cannot allocate a disk buffer of 8192 bytes\n");
return 1;
}
/*
* Get the address of the code snippet which installs dec0de's
* illegal handler.
*/
entry = tvd_robn88(illvec_cont,
tvd_pinstr,
PROT_FLAGS_ROBN88(prot) & PROT_TVD_MASK_ROBN88,
disk_buf,
(info->serial_off >= 0));
/*
* Patch the protection code prolog so that the above code snippet
* will be called during the execution of the protection code.
*/
write16(0x4eb9, illtrig);
write32(entry, illtrig + SIZE_16);
serial_robn88 = 0;
serial_dst_robn88 = NULL;
magic_robn88 = 0;
magic_dst_robn88 = NULL;
prog_resume_robn88 = NULL;
prog_start_robn88 = NULL;
for (i = 0; i < FLAG_NR_ROBN88; i++) {
flags_robn88[i] = 0;
}
/*
* Registers values at protection startup time.
* The address of the key disk buffer is passed in a0.
*/
memset(registers, 0, sizeof(uint32_t) * 16);
registers[IDX_A0_REG] = (uint32_t) (size_t) disk_buf;
/* Ask for the original disk to be inserted */
if (wait_prot(1)) {
free(disk_buf);
return 1;
}
/*
* Execute the protection code.
*
* As a consequence of the patch applied to the protection code prolog
* (described above), dec0de's illegal and trace handlers will replace
* those of the protection.
*/
run_prot(prog->text, (void*) TRAMPOLINE_ADDR_ROBN88, NULL,
(PROT_FLAGS_ROBN88(prot) & PROT_FORCE_SUP_ROBN88));
free(disk_buf);
end_wait_prot();
/*
* If an invalid serial is detected, the execution of the protection
* is aborted and prog_start_robn88 remains NULL.
*/
if (prog_start_robn88) {
ASSERT(!flags_robn88[FLAG_SERIAL_ROBN88] || serial_robn88);
/* Start of the wrapped program if any */
prog->doffset = (size_t) (prog_start_robn88 - prog->text);
if (prog_resume_robn88) {
/* Wrapped program is a binary type */
prog->binary = 1;
prog->dsize = (size_t) (registers[IDX_A2_REG] -
registers[IDX_A1_REG]);
}
}
/*
* Fill the info_robn_t structure with the information obtained
* from the native execution of the protection.
*
* The offsets fields of the info_robn_t structure are supposed to give
* the locations of the different parts/features of the protection
* (in bytes, relative to the beginning of the file).
* These offsets are actually used by the dump routine (print_info_robn)
* to only describe the behavior of the protection (if a feature is
* present or not). The actual offsets of the features are not dumped.
* Therefore, when a protection feature is found/localized by the TVD
* routine, the corresponding offset in the info_robn_t structure is
* set to zero on purpose (to indicate the feature is present).
* Otherwise the offset is left unchanged (initialized to -1 to indicate
* the feature is missing).
*/
/* Start of the wrapped program if any */
if (prog->doffset) {
info->prog_off = (ssize_t) prog->doffset;
}
/* Wrapped program type (GEMDOS/binary) */
if (prog->doffset && !prog->binary) {
info->reloc_off = 0;
}
/* Vectors checked by the protection? */
if (flags_robn88[FLAG_VECS_CHECK_ROBN88]) {
info->vecs_off = 0;
}
/* Key disk accessed by the protection? */
if (flags_robn88[FLAG_KEY_DISK_ROBN88]) {
info->keydisk_off = 0;
info->keydisk_hit = 1;
}
/* Serial usage */
if (flags_robn88[FLAG_SERIAL_ROBN88]) {
info->serial_off = 0;
if (info->decode_off >= 0) {
/* Keydisk is used by a wrapper type protection */
info->serial_usage = SERIAL_USAGE_DECODE_PROG_ROBN;
}
/* Serial is saved into memory */
info->serial_usage |= SERIAL_USAGE_SAVE_MEM_ROBN;
info->serial = serial_robn88;
if (serial_dst_robn88) {
info->serial_dst_addr = serial_dst_robn88;
}
info->serial_valid = 1;
}
/* Extra magic value computed from the serial key? */
if (flags_robn88[FLAG_MAGIC_ROBN88]) {
info->serial_usage |= SERIAL_USAGE_MAGIC_MEM_ROBN;
info->magic = magic_robn88;
/* Destination address where the magic value is saved to */
if (magic_dst_robn88) {
info->magic_dst_addr = magic_dst_robn88;
}
info->magic_valid = 1;
}
/* Execution context of the program (binary type only) */
if (prog->dsize) {
info->dst_addr = (void*) registers[IDX_A1_REG];
if (info->dst_addr == prog->text) {
info->dst_addr = NULL;
}
info->entry_off = ((size_t) prog_resume_robn88 -
(size_t) registers[IDX_A1_REG]);
info->prog_len = prog->dsize;
info->zeroes_len = (size_t) registers[IDX_A3_REG];
info->dstexec_valid = 1;
}
info->prot_run = 1;
if (check_size_robn(prog, info)) {
return 1;
}
/* Dump the collected information */
return print_info_robn(info, prog_start_robn88);
}
/*****************************************************************************
*
* Copylock Protection System series 2 (1989) by Rob Northen
* Atari ST specific code
*
* Dynamic (run-time) analysis of the protection.
*
* A rich static analysis can be performed for both types (wrapper and
* internal) of the series 2.
* Therefore, the dynamic analysis is only needed for the following:
* - to determine the value of the serial key
* - to decrypt the wrapped program if any
* - to determine the execution context of the wrapped program (if binary type)
*
* The run-time analysis works as follows: the encryption scheme of the
* series 2 enables to modify the encrypted protection code in order to
* replace original (decoded) instructions with new ones.
* Therefore, it is possible to patch the encrypted protection code in some
* special places in order to:
* - modify the behavior of the protection
* - temporarily interrupt the execution of the protection and call
* a subroutine aimed at performing some additional operations
* - terminate the execution of the protection prematurely
* Unlike the series 1, the series 2 does not require to replace the original
* TVD routine and to analyze each decoded instruction on-the-fly.
*
*****************************************************************************/
#define TRAMPOLINE_ADDR_ROBN89 0x200
#define SERIAL_HANDLER_ADDR_ROBN89 0x2a0
#define IDX_SERIAL_HDL_ROBN89 0
#define IDX_SERIAL_INSTRS_ROBN89 1
#define IDX_SERIAL_PTR_ROBN89 2
#define IDX_SERIAL_ONLY_ROBN89 3
#define IDX_SERIAL_TRAMP_ROBN89 4
#define IDX_MAX_ROBN89 5
#define ASM_IDX_ROBN89(_n) __ASM_STR(4 * IDX_##_n##_ROBN89)
#define SET_PARAM_ROBN89(_n, _v) \
params.val[IDX_##_n##_ROBN89] = (uint32_t) (_v)
static uint32_t serial_instrs_robn89[4];
static uint32_t serial_robn89;
static uint32_t serial_only_robn89;
/*
* Prepare the routine which will be called during the execution of the
* protection in order to catch the serial key value.
*
* The static analysis localizes, in the protection code, the instruction
* of which the register will contain the serial key value at run-time.
*
* Dec0de patches the protection code at this location so that the following
* routine will be called to catch the serial key value.
* Once the serial key value is catched and saved, the routine restores
* the original protection code and resumes its execution.
*
* When an invalid serial key is detected (value is null), the routine
* immediately terminates the execution of the protection and jumps to the
* trampoline routine in order to resume the normal execution of dec0de.
*
* The execution of the protection is also terminated right after the
* catching of the serial key value if the protection is an internal type
* (serial_only flag is set).
*/
static int32_t setup_serial_handler_robn89 (void)
{
static struct {
uint32_t val[IDX_MAX_ROBN89];
} params asm("serial_hdl_params_robn89") USED;
SET_PARAM_ROBN89(SERIAL_HDL, SERIAL_HANDLER_ADDR_ROBN89);
SET_PARAM_ROBN89(SERIAL_INSTRS, serial_instrs_robn89);
SET_PARAM_ROBN89(SERIAL_PTR, &serial_robn89);
SET_PARAM_ROBN89(SERIAL_ONLY, serial_only_robn89);
SET_PARAM_ROBN89(SERIAL_TRAMP, TRAMPOLINE_ADDR_ROBN89);
__asm__ __volatile__
(
";# installs the serial handler routine at the desired \n\t"
";# location in memory, and returns. \n\t"
"movem.l %%d2-%%d7/%%a2-%%a5,%%sp@- \n\t"
" \n\t"
"lea serial_hdl_params_robn89,%%a2 \n\t"
" \n\t"
"lea 2f(pc),%%a0 \n\t"
"movea.l %%a2@(" ASM_IDX_ROBN89(SERIAL_HDL) "),%%a1 \n\t"
"moveq.l #(7f-2f+3)/4-1,%%d0 \n\t"
"1: move.l %%a0@+,%%a1@+ \n\t"
"dbf %%d0,1b \n\t"
" \n\t"
"bra 7f \n\t"
" \n\t"
"2: \n\t"
";# serial handler routine: \n\t"
";# catches the serial key value (in d0) and saves it, \n\t"
";# then restores the original protection code and resumes \n\t"
";# its execution. \n\t"
"movem.l %%a0-%%a1/%%d0-%%d1,%%sp@- \n\t"
" \n\t"
"lea serial_hdl_params_robn89,%%a0 \n\t"
" \n\t"
"movea.l %%a0@(" ASM_IDX_ROBN89(SERIAL_PTR) "),%%a1 \n\t"
"move.l %%d0,%%a1@ ;# save serial \n\t"
"tst.l %%a0@(" ASM_IDX_ROBN89(SERIAL_ONLY) ") \n\t"
"bne.s 3f \n\t"
"tst.l %%d0 ;# invalid serial? \n\t"
"bne.s 4f \n\t"
"3: \n\t"
";# terminates the execution of the protection \n\t"
"move.l %%a0@(" ASM_IDX_ROBN89(SERIAL_TRAMP) "),%%sp@(18)\n\t"
"and.w #0x3fff,%%sp@(16) \n\t"
"bra 6f \n\t"
" \n\t"
"4: \n\t"
";# resumes the execution of the original protection code \n\t"
"movea.l %%a0@(" ASM_IDX_ROBN89(SERIAL_INSTRS) "),%%a0 \n\t"
"movea.l %%sp@(2+(4*4)),%%a1 \n\t"
"subq.l #8,%%a1 \n\t"
"move.l %%a1,%%sp@(2+(4*4)) \n\t"
"move.l %%a1,0xc.w \n\t"
"moveq.l #3,%%d0 \n\t"
"5: move.l %%a0@+,%%a1@+ \n\t"
"dbf %%d0,5b \n\t"
" \n\t"
"6: \n\t"
"movem.l %%sp@+,%%a0-%%a1/%%d0-%%d1 \n\t"
" \n\t"
"rte \n\t"
" \n\t"
"7: \n\t"
"movem.l %%sp@+,%%d2-%%d7/%%a2-%%a5 \n\t"
:
:
: "cc", "%%d0", "%%d1", "%%a0", "%%a1", "memory"
);
return 0;
}
/*
* Patch the encrypted protection code at a given location in order to
* replace the original decoded instruction at this location with a new
* 32-bit instruction.
*
* This helper routine encrypts a 32-bit instruction according to the
* second TVD method and patches the encrypted protection code with it.
* The 32-bit magic value which is used for the encryption (and passed
* as parameter) is obtained during the static analysis.
*
* See static analysis for details about the two TVD methods used by the
* series 2.
*/
static void encode_instr32_robn89 (unsigned char* buf,
uint32_t magic32,
uint32_t instr32)
{
uint32_t key32;
key32 = read32(buf - SIZE_32);
key32 += magic32;
instr32 ^= key32;
write32(instr32, buf);
}
/*
* Dynamic analysis of the protection.
*
* The encrypted protection code is patched at different places in order
* to replace the original decoded instructions at these locations
* with new ones.
* The purpose is to modify the behavior of the original protection code
* in order to obtain the desired information (serial key value,
* decrypted program...).
*/
static int decode_native_robn89 (prog_t* prog, info_robn_t* info)
{
unsigned char* buf;
uint32_t key32;
uint16_t w16;
ASSERT(((info->decode_off >= 0) || (info->serial_off >= 0)) &&
(info->pushtramp_off >= 0));
serial_robn89 = 0;
serial_only_robn89 = 0;
/*
* If vectors are checked, deactivates this check: modifies the original
* subroutine that checks a given vector. A 'rts' is written as the
* first instruction of this routine, so the routine will be ineffective.
* (see vecs_pattern1_robn89 for details about the code pattern of the
* vectors checking subroutine).
*/
if (info->vecs_off >= 0) {
buf = prog->text + info->vecs_off;
/* rts ; nop */
encode_instr32_robn89(buf + SIZE_32, info->magic32, 0x4e754e71);
}
/*
* If a serial key is used, patches the protection code, so a
* subroutine aimed at saving the serial key value will be called
* (see setup_serial_handler_robn89 for details).
*/
if (info->serial_off >= 0) {
buf = prog->text + info->serial_off;
/*
* Save the encrypted code snippet before patching it.
* It will be restored after the serial key value has been
* saved and prior to resuming the execution of the protection.
* When this code snippet will be reached, the two first instructions
* (which are the next to be executed) should be decoded by
* the second TVD routine.
* Save that code snippet in such a state, so it can be restored
* and its execution can be resumed properly.
*/
key32 = get_decode_key32_robn89(buf, info->magic32);
serial_instrs_robn89[0] = read32(buf + (SIZE_32*0)) ^ key32;
serial_instrs_robn89[1] = read32(buf + (SIZE_32*1)) ^ key32;
serial_instrs_robn89[2] = read32(buf + (SIZE_32*2));
serial_instrs_robn89[3] = read32(buf + (SIZE_32*3));
/*
* Encode and install the new instructions.
* These instructions will trigger an illegal exception whose
* handler is the routine aimed at saving the serial key value.
* That routine is installed (copied) into memory at a 16-bit address.
* Indeed, an instruction that loads a 16-bit address can be
* encoded in a 32-bit word.
*/
/* lea SERIAL_HANDLER_ADDR_ROBN89.w,a6 */
encode_instr32_robn89(buf + 0*SIZE_32, info->magic32,
0x4df80000 + SERIAL_HANDLER_ADDR_ROBN89);
/* move.l a6,$10.w (illegal vector) */
encode_instr32_robn89(buf + 1*SIZE_32, info->magic32, 0x21ce0010);
/* illegal ; nop */
encode_instr32_robn89(buf + 2*SIZE_32, info->magic32, 0x4afc4e71);
if (info->decode_off < 0) {
serial_only_robn89 = 1;
}
/*
* Install the routine aimed at saving the serial key value
* at the expected location in memory (at a 16-bit address).
*/
(void) supexec(setup_serial_handler_robn89);
}
if (info->reloc_off >= 0) {
/*
* If the wrapped program is a GEMDOS program, patches the
* protection code so the execution of the protection will be
* terminated right after the program has been decrypted (before
* it is relocated).
*/
buf = prog->text + info->reloc_off;
/* lea TRAMPOLINE_ADDR_ROBN89.w,a6 */
encode_instr32_robn89(buf + 0*SIZE_32, info->magic32,
0x4df80000 + TRAMPOLINE_ADDR_ROBN89);
/* move.l a6,$10.w (illegal vector) */
encode_instr32_robn89(buf + 1*SIZE_32, info->magic32, 0x21ce0010);
/* illegal ; nop */
encode_instr32_robn89(buf + 2*SIZE_32, info->magic32, 0x4afc4e71);
} else if (info->decode_off >= 0) {
/*
* Otherwise, patches the trampoline of the protection code,
* so the protection will be terminated right before the binary
* program is installed to its final location.
* The registers saved on exit from the protection provide the
* execution context of the binary program (destination address,
* program size, zeroes length...).
*/
buf = prog->text + info->pushtramp_off;
/*
* Caution: the protection code which is modified here is encrypted
* with the first TVD method (see static analysis for details).
*
* Modify protection code (push trampoline into the stack) so that
* it does not affect 'sr' when the "move.l #$value,-(a7)" instruction
* is executed. 'sr' is indeed used in the TVD handler for decoding.
*
* Here, 'eor.l d6,4(a6)' will be replaced with
* 'jmp TRAMPOLINE_ADDR_ROBN89.w'.
*/
/* Patch 'move.l #$bd96bdae,-(a7)' */
w16 = read16(buf + SIZE_16*2);
/* eor.l d6,4(a6) (1st part) */
w16 ^= (uint16_t) 0xbdae;
/* jmp TRAMPOLINE_ADDR_ROBN89.w (1st part) */
w16 ^= (uint16_t) 0x4ef8;
write16(w16, buf + SIZE_16*2);
/* Patch 'move.l #$0004487a,-(a7)' */
w16 = read16(buf - SIZE_16*2);
/* eor.l d6,4(a6) (2nd part) */
w16 ^= (uint16_t) 0x0004;
/* jmp TRAMPOLINE_ADDR_ROBN89.w (2nd part) */
w16 ^= (uint16_t) TRAMPOLINE_ADDR_ROBN89;
write16(w16, buf - SIZE_16*2);
}
/*
* Registers values at protection startup time.
*/
memset(registers, 0, sizeof(uint32_t) * 16);
/* Ask for the original disk to be inserted */
if (wait_prot(info->keydisk_off >= 0)) {
return 1;
}
/*
* Execute the protection code.
*
* The behavior of the protection code will be modified according
* to the patches applied above.
*/
run_prot(prog->text, (void*) TRAMPOLINE_ADDR_ROBN89, NULL,
(PROT_FLAGS_ROBN89(prog->prot) & PROT_FORCE_SUP_ROBN89));
end_wait_prot();
/* Start of the wrapped program if any */
if (info->decode_off >= 0) {
prog->doffset = (size_t) info->prog_off;
prog->binary = (unsigned int) (info->reloc_off < 0);
}
/* Size of the binary program if any */
if (prog->binary && ((info->serial_off < 0) || serial_robn89)) {
prog->dsize = (size_t) registers[IDX_A2_REG];
}
/*
* Fill the info_robn_t structure with the information obtained
* from the native execution of the protection.
* Only the dynamic information is filled here as the static information
* has already been provided during the static analysis.
*/
/* Key disk usage and serial key value */
if (info->serial_off >= 0) {
info->keydisk_hit = 1;
info->serial = serial_robn89;
info->serial_valid = 1;
}
/* Execution context of the program (binary type only) */
if (prog->dsize) {
info->dst_addr = (void*) registers[IDX_A1_REG];
if (info->dst_addr == prog->text) {
info->dst_addr = NULL;
}
info->entry_off = (size_t) (registers[IDX_A4_REG] -
registers[IDX_A1_REG]);
info->prog_len = prog->dsize;
info->zeroes_len = (size_t) registers[IDX_A3_REG];
info->dstexec_valid = 1;
}
info->prot_run = 1;
buf = (info->decode_off >= 0) ? prog->text + prog->doffset : NULL;
/* Dump the collected information */
return print_info_robn(info, buf);
}
#endif /* TARGET_ST */
/*****************************************************************************
* Main entry point
*****************************************************************************/
int do_main (int argc, char* argv[])
{
const char* cmd;
const char* src;
const char* dst;
char c;
if (argc < 2) {
if (IA_MODE_AVAIL()) {
return IA_MODE_ENTER();
}
LOG_ERROR("Missing command\n");
try_help(argv);
return 1;
}
cmd = argv[1];
if (cmd[0] == '-' && cmd[1] != '\0' && cmd[2] == '\0') {
c = cmd[1];
c = ((c >= 'A') && (c <= 'Z')) ? c + 'a' - 'A' : c;
} else {
c = '\0';
}
switch (c) {
case 'd':
if (argc == 4) {
src = argv[2];
dst = argv[3];
break;
}
if (argc > 4) {
LOG_ERROR("Unexpected parameter: '%s'\n", argv[4]);
} else if (argc == 3) {
LOG_ERROR("Missing destination file\n");
} else {
LOG_ERROR("Missing source file\n");
}
try_help(argv);
return 1;
case 't':
if (argc == 3) {
src = argv[2];
dst = NULL;
break;
}
if (argc > 3) {
LOG_ERROR("Unexpected parameter: '%s'\n", argv[3]);
} else {
LOG_ERROR("Missing source file\n");
}
try_help(argv);
return 1;
case 'p':
if (argc == 3) {
src = argv[2];
print_prot(src);
return 0;
}
if (argc > 3) {
LOG_ERROR("Unexpected parameter: '%s'\n", argv[3]);
} else {
LOG_ERROR("Missing source file\n");
}
try_help(argv);
return 1;
case 'l':
if (argc == 2) {
list_prots();
return 0;
}
LOG_ERROR("Unexpected parameter: '%s'\n", argv[2]);
try_help(argv);
return 1;
case 'h':
if (argc == 2) {
usage(argv);
return 0;
}
LOG_ERROR("Unexpected parameter: '%s'\n", argv[2]);
try_help(argv);
return 1;
case 'i':
if (argc == 2) {
info();
return 0;
}
LOG_ERROR("Unexpected parameter: '%s'\n", argv[2]);
try_help(argv);
return 1;
case 'v':
if (argc == 2) {
version();
return 0;
}
LOG_ERROR("Unexpected parameter: '%s'\n", argv[2]);
try_help(argv);
return 1;
case 'c':
if (argc == 2) {
credits();
return 0;
}
LOG_ERROR("Unexpected parameter: '%s'\n", argv[2]);
try_help(argv);
return 1;
default:
LOG_ERROR("Invalid command: '%s'\n", cmd);
try_help(argv);
return 1;
}
return decode(src, dst);
}
int main (int argc, char* argv[])
{
int diag;
diag = PROG_ATSTART();
if (diag == 0) {
diag = do_main(argc, argv);
}
PROG_ATEXIT();
return diag;
}
|
the_stack_data/70449086.c | /* David Tarazi
* adder.c
* Description: Continuously takes inputs from the user until they enter "Ctrl-D"
* where the program sums all the inputs and returns the output
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// Define Booleans
#define True 1
#define False 0
int get_sum(int nums[], int count);
int digits_only(char *str);
int main()
{
// length of the array and actual array
int arr_length = 20;
int input_length = 11;
int array[arr_length]; // int
// counter for the number of elements to index and check limit for error handling
int count = 0;
// input buffer
char input[input_length];
printf("Enter up to %d integers of up to %d digits to be summed.\n", arr_length, input_length);
printf("To stop inputting values, enter 'Ctrl-D'\n");
while (fgets(input, input_length, stdin) != NULL) {
// Collects data until it is broken or there is an error
// If the number of inputs exceeds the length of the array
if (count >= arr_length) {
printf("Error: Maximum Integer Input (%d) Reached\n", arr_length);
break;
}
// checks if the input is all digits
if (strlen(input) == 0 || digits_only(input) == False) {
printf("This is an empty or invalid integer value, try again.\n");
}
else {
// fill array and update index
array[count] = atoi(input);
count += 1;
}
printf("Enter another integer with less than %d digits. You have up to %d more integers to input\n", input_length, arr_length-count);
printf("To stop inputting values, enter 'Ctrl-D'\n");
}
// after collecting data, traverse and sum the array using get_sum
printf("Finished inputting data\n");
printf("The sum of the digits you entered is %i\n", get_sum(array, count));
return 0;
}
int get_sum(int nums[], int count) {
// traverses the array and finds the sum
// takes in the array and how many times data was collected
int sum = 0;
for (int i = 0; i < count; i++) {
sum += nums[i];
}
return sum;
}
int digits_only(char *str) {
// checks if the string is all digits and valid
int i = 0;
// loop through string until you reach end; if any char isn't a digit return False
while (str[i] != '\0') {
// printf('%s',*str);
if (*str < '0' || *str > '9') {
return False;
}
i += 1;
}
// if successfully made it through, return True
return True;
}
|
the_stack_data/184518335.c | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
char *src = "0123456789";
char *str2 = NULL;
char *str3 = (char *)malloc(1);
char *str4 = (char *)malloc(0);
char *str42 = (char *)malloc(0);
char str5[] = "0003456788";
strcpy(str2, src);
strcpy(str3, src);
strcpy(str4, src);
strcpy(str5, src);
printf("str2: %s\n", str2);
printf("str3: %s\n", str3);
printf("str4: %s, str42: %s\n", str4, str42);
printf("str5: %s\n", str5);
return 0;
} |
the_stack_data/121709.c | /******************************************************************/
/* Slicing Test Problem */
/******************************************************************/
/* Features: */
/* * Loops */
/* * Interprocedural */
/******************************************************************/
int foo(int n)
{
int i=0; /* IN */
int s=0; /* IN */
while (i<n) { /* IN */ // and the exit condition is OUT */
s = s+i; /* IN */
i++; /* IN */
}
return s; /* IN */
}
int bar(int n)
{
int x;
x = n+n; /* IN */
return x; /* IN */
}
int main()
{
int i=0; /* IN */
int x, y;
while (i<10) { /* IN */ // and the exit condition is OUT
y = y + foo(/*IN*/i); /* IN */
x = bar(/*IN*/y) + 1; /* IN */
i++; /* IN */
}
return y; /* OUT */
_SLICE(x);
}
|
the_stack_data/48576114.c | #include<stdio.h>
#include<string.h>
char movie[20];
struct ticket
{
char name[20];
char email_id[45];
long int p_number;
};
void Detail_reciver(struct ticket t,int a[],int n,FILE *det)
{
int l,r;
printf("\nEnter the following details");
printf("\nEnter your name:\t");
scanf("%s",t.name);
printf("\nEnter your phone number:\t");
scanf("%ld",&t.p_number);
printf("\nEnter your email id:\t");
scanf("%s",t.email_id);
fputs("Occupied seats: ",det);
for(int i=0;i<n;i++)
{
fprintf(det,"%d",a[i]);
fputs(", ",det);
}
fputs("\n",det);
fputs(t.name,det);
fputs("\n",det);
fputs(t.email_id,det);
fputs("\n",det);
fprintf(det,"%ld",t.p_number);
fputs("\n",det);
fputs("\n",det);
fclose(det);
}
void admin()
{
char admin_id[20],det[25];
char admin_pass[10],time[10];
int choice,size;
FILE *movdet,*d1,*d2;
char num[5],ch;
L4:printf("Admin id:\t");
scanf("%s",admin_id);
printf("Admin password:\t");
scanf("%s",admin_pass);
if(strcmp(admin_id,"admin@123")==0 && strcmp(admin_pass,"123")==0)
{
L8 :printf("\n1]----->change movie name and timings");
printf("\n2]----->get the show details");
L5:printf("\nEnter your choice : ");
scanf("%d",&choice);
if(choice==1)
{
movdet=fopen("Movie_details.txt","w+");
for(int i=0;i<2;i++)
{
num[0]=(i+1)+'0';
printf("Enter a movie name:\t");
scanf("%s",movie);
printf("Enter the movie timing:\t");
scanf("%s",time);
if(strlen(movie)>0 && strlen(time)>0)
{
fputs(num,movdet);
fputs("] ",movdet);
fputs(movie,movdet);
fputs("\t",movdet);
fputs(time,movdet);
fputs("\n",movdet);
}
}
printf("Successfully saved!!!\n\n");
}
else if(choice==2)
{
movdet=fopen("Movie_details.txt","a+");
int i=0;
while(i<2)
{
fgets(det,25,movdet);
printf("%s",det);
i++;
}
L6:printf("Enter the movie number for the user details : ");
scanf("%d",&choice);
if(choice==1)
{
d1=fopen("Details1.txt","r+");
while((ch=fgetc(d1))!= EOF)
printf("%c",ch);
printf("\n\n\n");
fclose(d1);
}
else if(choice==2)
{
d2=fopen("Details2.txt","r+");
while((ch=fgetc(d2))!=EOF)
printf("%c",ch);
printf("\n\n\n");
fclose(d2);
}
else
{
printf("\nWrong input\n");
goto L6;
}
}
else
{
printf("Sorry wrong choice!!! Try again.");
goto L5;
}
}
else
{
printf("\nInvalid credentials!\n");
goto L4;
}
fclose(movdet);
printf("\n\n----->1] Continue as admin\n----->Press any key to leave\n\n");
scanf("%d",&choice);
if(choice==1)
goto L8;
}
void book(FILE *poi,FILE *seat)
{
int a=0,tick[80],no=0,occupied;
struct ticket t1;
printf("\t\t\t\t\t\t\t\tSCREEN\n\n");
int occ[80]={0},i=0;
while((occupied=getw(seat)) != EOF)
{
occ[i]=occupied;
i++;
}
for(int j=0;j<8;j++)
{
printf("\t");
for(int k=0;k<10;k++)
{
int flag=0;
a++;
for(int r=0;r<80;r++)
{
if(occ[r]==a)
{
if(a<10)
printf("0%d-O\t",a);
else
printf("%d-O\t",a);
flag=0;
break;
}
else
flag=1;
}
if(flag==1)
{
if(a<10)
printf("0%d-V\t",a);
else
printf("%d-V\t",a);
}
}
printf("\n");
}
printf("\nPrices");
printf("\nSeats [01 - 20]---> Rs.50--->Budget");
printf("\nSeats [21 - 60]---> Rs.110--->Premium");
printf("\nSeats [61 - 80]---> Rs.140--->Elite");
L3:printf("\n\nEnter the number of tickets you want : ");
scanf("%d",&no);
if(no>(80-i))
{
printf("\nSo many number of seats not available\n");
goto L3;
}
printf("\nEnter the seat number as per the seating vacancy displayed above ");
for(int i=0;i<no;i++)
{
L7:printf("\nnext:");
scanf("%d",&tick[i]);
if(tick[i]>80)
{
printf("Oops!! Wrong input. Try again");
goto L7;
}
else
{
for(int k=0;k<80;k++)
{
if(occ[k]==tick[i])
{
printf("Oops!! Already booked. Try another seat");
goto L7;
}
}
}
for(int s=0;s<i;s++)
{
if(tick[s]==tick[i])
{
printf("\nAlready entered the seat number\n");
goto L7;
}
}
putw(tick[i],seat);
}
fclose(seat);
a=0;
Detail_reciver(t1,tick,no,poi);
float sum=0,tax=0;
for(int i=0;i<no;i++)
{
if(tick[i]>0 && tick[i]<=20)
sum=sum+50;
else if(tick[i]>=21 && tick[i]<=60)
sum=sum+110;
else
sum=sum+140;
}
printf("\nNo. of seats booked: %d",no);
printf("\nBooked seats:");
for(int r=0;r<no;r++)
printf("%d, ",tick[r]);
printf("\nTotal amount: Rs.%.2f/-",sum);
tax=(sum*5)/100;
printf("\nTax amount: Rs.%.2f/-",tax);
printf("\nNet amount: Rs.%.2f/-",sum+tax);
printf("\nHAVE A GREAT DAY!!!\n\n\n");
fclose(poi);
}
int main()
{
FILE *Md,*d1,*d2,*s1,*s2;
int choice;
int ch=0;
char det[25];
printf("____________________________________________________________________\n");
printf("____________________________________________________________________\n");
printf("| WELCOME TO MY CINEMAS |\n");
printf("| BOOK YOUR TICKETS RIGHT AWAY |\n");
printf("____________________________________________________________________\n");
printf("____________________________________________________________________\n");
l1 : printf("1]-----> Book your ticket\n");
printf("2]-----> Admin login\n");
printf("3]----->Exit\n");
scanf("%d",&choice);
if(choice==1)
{
Md=fopen("Movie_details.txt","a+");
int i=0;
while(i<2)
{
fgets(det,25,Md);
printf("%s",det);
i++;
}
L2:printf("ENTER YOUR MOVIE CHOICE\n");
scanf("%d",&ch);
if(ch==1)
{
d1=fopen("Details1.txt","a+");
s1=fopen("Seats1.txt","a+");
book(d1,s1);
goto l1;
}
else if(ch==2)
{
d2=fopen("Details2.txt","a+");
s2=fopen("Seats2.txt","a+");
book(d2,s2);
goto l1;
}
else
{
printf("\nInvalid choice. Try again");
printf("\n");
goto L2;
}
}
else if(choice==2)
{
admin();
goto l1;
}
else if(choice==3)
printf("\n\n\nHAVE A GREAT DAY!!!\n");
else
{
printf("Invalid choice. Please enter again\n");
goto l1;
}
}
|
the_stack_data/90766217.c | double bar() {
return 1.0;
}
double foo() {
double a = 0;
for(int i=0; i<1000; i++) {
a += bar();
}
return a;
// Comment after return
}
void testAppend() {
long int aLong;
long long aLongLong;
int a;
}
void testAppendJp() {
int a, b, c = 0;
c = a + b;
}
int main() {
foo();
} |
the_stack_data/31388042.c | #include <stdio.h>
int main()
{
int t, a, b, i;
scanf("%d", &t);
for(i = 0; i < t; i++ )
{
scanf("%d%d", &a, &b);
a = a + b;
printf("Case %d: %d\n", i+1, a);
}
return 0;
}
|
the_stack_data/567225.c | /*
* Copyright (c) 2018, Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
//!
//! \file igvpkrn_isa_g11_icllp.c
//! \brief File holds the kernel binary for icllp isa kernel.
//! \details This module must not contain: - OS dependent code - HW dependent code - DDI layer dependencies
//!
#ifdef IGFX_GEN11_SUPPORTED
extern const unsigned int IGVP3DLUT_GENERATION_G11_ICLLP_SIZE = 72527;
extern const unsigned int IGVP3DLUT_GENERATION_G11_ICLLP[] =
{
0x41534943, 0x00010503, 0x72646809, 0x6c64335f, 0x00307475, 0xb8cf0000, 0x1a250000, 0x00000000,
0x0a010000, 0x0000b8ff, 0x00006250, 0x00000000, 0x0000003d, 0x5f726468, 0x756c6433, 0x756e0074,
0x74006c6c, 0x61657268, 0x00785f64, 0x65726874, 0x795f6461, 0x6f726700, 0x695f7075, 0x00785f64,
0x756f7267, 0x64695f70, 0x6700795f, 0x70756f72, 0x5f64695f, 0x7374007a, 0x30720063, 0x67726100,
0x74657200, 0x006c6176, 0x66007073, 0x77680070, 0x0064695f, 0x00307273, 0x00307263, 0x00306563,
0x30676264, 0x6c6f6300, 0x5400726f, 0x31540030, 0x00325400, 0x54003354, 0x00323532, 0x35353254,
0x31335300, 0x706e4900, 0x00327475, 0x75706e49, 0x68003374, 0x335f7264, 0x74756c64, 0x5f42425f,
0x00315f30, 0x315f4242, 0x4200335f, 0x5f325f42, 0x42420034, 0x355f335f, 0x5f424200, 0x00365f34,
0x355f4242, 0x4200375f, 0x5f365f42, 0x42420038, 0x395f375f, 0x5f424200, 0x30315f38, 0x5f424200,
0x31315f39, 0x5f424200, 0x315f3031, 0x42420032, 0x5f31315f, 0x42003331, 0x32315f42, 0x0034315f,
0x315f4242, 0x35315f33, 0x5f424200, 0x315f3431, 0x42420036, 0x5f35315f, 0x42003731, 0x36315f42,
0x0038315f, 0x315f4242, 0x39315f37, 0x5f424200, 0x325f3831, 0x42420030, 0x5f39315f, 0x42003132,
0x30325f42, 0x0032325f, 0x325f4242, 0x33325f31, 0x5f424200, 0x325f3232, 0x42420034, 0x5f33325f,
0x42003532, 0x34325f42, 0x0036325f, 0x325f4242, 0x37325f35, 0x5f424200, 0x325f3632, 0x6e490038,
0x30747570, 0x706e4900, 0x00317475, 0x4e6d7341, 0x00656d61, 0x61426f4e, 0x65697272, 0x61540072,
0x74656772, 0x5c3a4400, 0x6b726f57, 0x63617073, 0x57535c65, 0x654d5f45, 0x5f616964, 0x6e72654b,
0x535f6c65, 0x74756f74, 0x65646f6d, 0x69616d5c, 0x6e696c6e, 0x45475c65, 0x4b5f394e, 0x485c4c42,
0x735c5244, 0x335f6372, 0x74756c64, 0x5244485c, 0x4c44335f, 0x485c5455, 0x335f5244, 0x54554c44,
0x7264685c, 0x6c64335f, 0x675f7475, 0x2e786e65, 0x00707063, 0x00000000, 0x0000015a, 0x0000001a,
0x00000113, 0x00000000, 0x1b000000, 0x13000000, 0x00000001, 0x00000000, 0x00000000, 0x01120000,
0x00000000, 0x00000000, 0x00000000, 0x00011200, 0x00000000, 0x00000000, 0x00000000, 0x00000121,
0x00000000, 0x00000000, 0x21000000, 0x00000001, 0x00000000, 0x00000000, 0x01210000, 0x00000000,
0x00000000, 0x00000000, 0x00012100, 0x00000000, 0x00000000, 0x00000000, 0x00004063, 0x00000000,
0x00000000, 0x21000000, 0x00000001, 0x00000000, 0x00000000, 0x40630000, 0x00000000, 0x00000000,
0x00000000, 0x00206300, 0x00000000, 0x00000000, 0x00000000, 0x00002063, 0x00000000, 0x00000000,
0x63000000, 0x00000020, 0x00000000, 0x00000000, 0x20630000, 0x00000000, 0x00000000, 0x00000000,
0x00012100, 0x00000000, 0x00000000, 0x00000000, 0x00004063, 0x00000000, 0x00000000, 0x21000000,
0x00000001, 0x00000000, 0x00000000, 0x40630000, 0x00000000, 0x00000000, 0x00000000, 0x00206300,
0x00000000, 0x00000000, 0x00000000, 0x00002063, 0x00000000, 0x00000000, 0x63000000, 0x00000020,
0x00000000, 0x00000000, 0x20630000, 0x00000000, 0x00000000, 0x00000000, 0x00012100, 0x00000000,
0x00000000, 0x00000000, 0x00004063, 0x00000000, 0x00000000, 0x63000000, 0x00000040, 0x00000000,
0x00000000, 0x20630000, 0x00000000, 0x00000000, 0x00000000, 0x00206300, 0x00000000, 0x00000000,
0x00000000, 0x00002063, 0x00000000, 0x00000000, 0x63000000, 0x00000020, 0x00000000, 0x00000000,
0x40630000, 0x00000000, 0x00000000, 0x00000000, 0x00406300, 0x00000000, 0x00000000, 0x00000000,
0x00002063, 0x00000000, 0x00000000, 0x63000000, 0x00000020, 0x00000000, 0x00000000, 0x20630000,
0x00000000, 0x00000000, 0x00000000, 0x00206300, 0x00000000, 0x00000000, 0x00000000, 0x00001062,
0x00000000, 0x00000000, 0x62000000, 0x00000010, 0x00000000, 0x00000000, 0x10620000, 0x00000000,
0x00000000, 0x00000000, 0x00106200, 0x00000000, 0x00000000, 0x00000000, 0x00002062, 0x00000000,
0x00000000, 0x62000000, 0x00000020, 0x00000000, 0x00000000, 0x10620000, 0x00000000, 0x00000000,
0x00000000, 0x00106200, 0x00000000, 0x00000000, 0x00000000, 0x00001062, 0x00000000, 0x00000000,
0x62000000, 0x00000010, 0x00000000, 0x00000000, 0x10620000, 0x00000000, 0x00000000, 0x00000000,
0x00106200, 0x00000000, 0x00000000, 0x00000000, 0x00001062, 0x00000000, 0x00000000, 0x62000000,
0x00000010, 0x00000000, 0x00000000, 0x10620000, 0x00000000, 0x00000000, 0x00000000, 0x00106200,
0x00000000, 0x00000000, 0x00000000, 0x00001062, 0x00000000, 0x00000000, 0x62000000, 0x00000010,
0x00000000, 0x00000000, 0x10670000, 0x00000000, 0x00000000, 0x00000000, 0x00106700, 0x00000000,
0x00000000, 0x00000000, 0x00001067, 0x00000000, 0x00000000, 0x67000000, 0x00000010, 0x00000000,
0x00000000, 0x10670000, 0x00000000, 0x00000000, 0x00000000, 0x00106700, 0x00000000, 0x00000000,
0x00000000, 0x00001067, 0x00000000, 0x00000000, 0x67000000, 0x00000010, 0x00000000, 0x00000000,
0x10670000, 0x00000000, 0x00000000, 0x00000000, 0x00106700, 0x00000000, 0x00000000, 0x00000000,
0x00001067, 0x00000000, 0x00000000, 0x67000000, 0x00000010, 0x00000000, 0x00000000, 0x10670000,
0x00000000, 0x00000000, 0x00000000, 0x00106700, 0x00000000, 0x00000000, 0x00000000, 0x00001067,
0x00000000, 0x00000000, 0x67000000, 0x00000010, 0x00000000, 0x00000000, 0x10670000, 0x00000000,
0x00000000, 0x00000000, 0x00106700, 0x00000000, 0x00000000, 0x00000000, 0x00001067, 0x00000000,
0x00000000, 0x67000000, 0x00000010, 0x00000000, 0x00000000, 0x10670000, 0x00000000, 0x00000000,
0x00000000, 0x00106700, 0x00000000, 0x00000000, 0x00000000, 0x00001067, 0x00000000, 0x00000000,
0x67000000, 0x00000010, 0x00000000, 0x00000000, 0x10670000, 0x00000000, 0x00000000, 0x00000000,
0x00106700, 0x00000000, 0x00000000, 0x00000000, 0x00001067, 0x00000000, 0x00000000, 0x67000000,
0x00000010, 0x00000000, 0x00000000, 0x10670000, 0x00000000, 0x00000000, 0x00000000, 0x00106700,
0x00000000, 0x00000000, 0x00000000, 0x00001067, 0x00000000, 0x00000000, 0x67000000, 0x00000010,
0x00000000, 0x00000000, 0x01270000, 0x00000000, 0x00000000, 0x00000000, 0x00012700, 0x00000000,
0x00000000, 0x00000000, 0x00000127, 0x00000000, 0x00000000, 0x27000000, 0x00000001, 0x00000000,
0x00000000, 0x01270000, 0x00000000, 0x00000000, 0x00000000, 0x00012700, 0x00000000, 0x00000000,
0x00000000, 0x00000127, 0x00000000, 0x00000000, 0x27000000, 0x00000001, 0x00000000, 0x00000000,
0x01270000, 0x00000000, 0x00000000, 0x00000000, 0x00012700, 0x00000000, 0x00000000, 0x00000000,
0x00000127, 0x00000000, 0x00000000, 0x67000000, 0x00000008, 0x00000000, 0x00000000, 0x08670000,
0x00000000, 0x00000000, 0x00000000, 0x00086700, 0x00000000, 0x00000000, 0x00000000, 0x00001067,
0x00000000, 0x00000000, 0x67000000, 0x00000010, 0x00000000, 0x00000000, 0x10670000, 0x00000000,
0x00000000, 0x00000000, 0x00106700, 0x00000000, 0x00000000, 0x00000000, 0x00001067, 0x00000000,
0x00000000, 0x67000000, 0x00000010, 0x00000000, 0x00000000, 0x10670000, 0x00000000, 0x00000000,
0x00000000, 0x00106700, 0x00000000, 0x00000000, 0x00000000, 0x00001067, 0x00000000, 0x00000000,
0x67000000, 0x00000010, 0x00000000, 0x00000000, 0x10670000, 0x00000000, 0x00000000, 0x00000000,
0x00106700, 0x00000000, 0x00000000, 0x00000000, 0x00001067, 0x00000000, 0x00000000, 0x67000000,
0x00000010, 0x00000000, 0x00000000, 0x10670000, 0x00000000, 0x00000000, 0x00000000, 0x00106700,
0x00000000, 0x00000000, 0x00000000, 0x00001067, 0x00000000, 0x00000000, 0x67000000, 0x00000010,
0x00000000, 0x00000000, 0x10670000, 0x00000000, 0x00000000, 0x00000000, 0x00106700, 0x00000000,
0x00000000, 0x00000000, 0x00001067, 0x00000000, 0x00000000, 0x67000000, 0x00000010, 0x00000000,
0x00000000, 0x10670000, 0x00000000, 0x00000000, 0x00000000, 0x00106700, 0x00000000, 0x00000000,
0x00000000, 0x00001067, 0x00000000, 0x00000000, 0x67000000, 0x00000010, 0x00000000, 0x00000000,
0x10670000, 0x00000000, 0x00000000, 0x00000000, 0x00106700, 0x00000000, 0x00000000, 0x00000000,
0x00001067, 0x00000000, 0x00000000, 0x67000000, 0x00000010, 0x00000000, 0x00000000, 0x10670000,
0x00000000, 0x00000000, 0x00000000, 0x00106700, 0x00000000, 0x00000000, 0x00000000, 0x00001067,
0x00000000, 0x00000000, 0x67000000, 0x00000010, 0x00000000, 0x00000000, 0x10670000, 0x00000000,
0x00000000, 0x00000000, 0x00106700, 0x00000000, 0x00000000, 0x00000000, 0x00001067, 0x00000000,
0x00000000, 0x67000000, 0x00000010, 0x00000000, 0x00000000, 0x10670000, 0x00000000, 0x00000000,
0x00000000, 0x00106700, 0x00000000, 0x00000000, 0x00000000, 0x00001067, 0x00000000, 0x00000000,
0x67000000, 0x00000010, 0x00000000, 0x00000000, 0x10670000, 0x00000000, 0x00000000, 0x00000000,
0x00106700, 0x00000000, 0x00000000, 0x00000000, 0x00001067, 0x00000000, 0x00000000, 0x67000000,
0x00000010, 0x00000000, 0x00000000, 0x10670000, 0x00000000, 0x00000000, 0x00000000, 0x00106700,
0x00000000, 0x00000000, 0x00000000, 0x00001067, 0x00000000, 0x00000000, 0x67000000, 0x00000010,
0x00000000, 0x00000000, 0x10670000, 0x00000000, 0x00000000, 0x00000000, 0x00106700, 0x00000000,
0x00000000, 0x00000000, 0x00001067, 0x00000000, 0x00000000, 0x67000000, 0x00000010, 0x00000000,
0x00000000, 0x10670000, 0x00000000, 0x00000000, 0x00000000, 0x00106700, 0x00000000, 0x00000000,
0x00000000, 0x00001067, 0x00000000, 0x00000000, 0x67000000, 0x00000010, 0x00000000, 0x00000000,
0x10670000, 0x00000000, 0x00000000, 0x00000000, 0x00106700, 0x00000000, 0x00000000, 0x00000000,
0x00001067, 0x00000000, 0x00000000, 0x67000000, 0x00000010, 0x00000000, 0x00000000, 0x10670000,
0x00000000, 0x00000000, 0x00000000, 0x00106700, 0x00000000, 0x00000000, 0x00000000, 0x00001067,
0x00000000, 0x00000000, 0x67000000, 0x00000040, 0x00000000, 0x00000000, 0x10670000, 0x00000000,
0x00000000, 0x00000000, 0x00106700, 0x00000000, 0x00000000, 0x00000000, 0x00001067, 0x00000000,
0x00000000, 0x67000000, 0x00000010, 0x00000000, 0x00000000, 0x10670000, 0x00000000, 0x00000000,
0x00000000, 0x00106700, 0x00000000, 0x00000000, 0x00000000, 0x00001067, 0x00000000, 0x00000000,
0x67000000, 0x00000010, 0x00000000, 0x00000000, 0x10670000, 0x00000000, 0x00000000, 0x00000000,
0x00106700, 0x00000000, 0x00000000, 0x00000000, 0x00001067, 0x00000000, 0x00000000, 0x67000000,
0x00000010, 0x00000000, 0x00000000, 0x10670000, 0x00000000, 0x00000000, 0x00000000, 0x00106700,
0x00000000, 0x00000000, 0x00000000, 0x00001067, 0x00000000, 0x00000000, 0x67000000, 0x00000010,
0x00000000, 0x00000000, 0x10670000, 0x00000000, 0x00000000, 0x00000000, 0x00106700, 0x00000000,
0x00000000, 0x00000000, 0x00001067, 0x00000000, 0x00000000, 0x67000000, 0x00000010, 0x00000000,
0x00000000, 0x10670000, 0x00000000, 0x00000000, 0x00000000, 0x00106700, 0x00000000, 0x00000000,
0x00000000, 0x00001067, 0x00000000, 0x00000000, 0x67000000, 0x00000010, 0x00000000, 0x00000000,
0x10670000, 0x00000000, 0x00000000, 0x00000000, 0x00106700, 0x00000000, 0x00000000, 0x00000000,
0x00001067, 0x00000000, 0x00000000, 0x67000000, 0x00000010, 0x00000000, 0x00000000, 0x10670000,
0x00000000, 0x00000000, 0x00000000, 0x00106700, 0x00000000, 0x00000000, 0x00000000, 0x00001067,
0x00000000, 0x00000000, 0x67000000, 0x00000010, 0x00000000, 0x00000000, 0x10670000, 0x00000000,
0x00000000, 0x00000000, 0x00106700, 0x00000000, 0x00000000, 0x00000000, 0x00001067, 0x00000000,
0x00000000, 0x67000000, 0x00000010, 0x00000000, 0x00000000, 0x10670000, 0x00000000, 0x00000000,
0x00000000, 0x00106700, 0x00000000, 0x00000000, 0x00000000, 0x00001067, 0x00000000, 0x00000000,
0x67000000, 0x00000010, 0x00000000, 0x00000000, 0x10670000, 0x00000000, 0x00000000, 0x00000000,
0x00106700, 0x00000000, 0x00000000, 0x00000000, 0x00001067, 0x00000000, 0x00000000, 0x67000000,
0x00000010, 0x00000000, 0x00000000, 0x10670000, 0x00000000, 0x00000000, 0x00000000, 0x00106700,
0x00000000, 0x00000000, 0x00000000, 0x00001067, 0x00000000, 0x00000000, 0x67000000, 0x00000010,
0x00000000, 0x00000000, 0x01270000, 0x00000000, 0x00000000, 0x00000000, 0x00012700, 0x00000000,
0x00000000, 0x00000000, 0x00001062, 0x00000000, 0x00000000, 0x62000000, 0x00000010, 0x00000000,
0x00000000, 0x10620000, 0x00000000, 0x00000000, 0x00000000, 0x00106200, 0x00000000, 0x00000000,
0x00000000, 0x00001062, 0x00000000, 0x00000000, 0x62000000, 0x00000010, 0x00000000, 0x00000000,
0x10620000, 0x00000000, 0x00000000, 0x00000000, 0x00106200, 0x00000000, 0x00000000, 0x00000000,
0x00001067, 0x00000000, 0x00000000, 0x62000000, 0x00000010, 0x00000000, 0x00000000, 0x10670000,
0x00000000, 0x00000000, 0x00000000, 0x00106200, 0x00000000, 0x00000000, 0x00000000, 0x00001067,
0x00000000, 0x00000000, 0x62000000, 0x00000010, 0x00000000, 0x00000000, 0x10670000, 0x00000000,
0x00000000, 0x00000000, 0x00106200, 0x00000000, 0x00000000, 0x00000000, 0x00001067, 0x00000000,
0x00000000, 0x62000000, 0x00000010, 0x00000000, 0x00000000, 0x10670000, 0x00000000, 0x00000000,
0x00000000, 0x00106200, 0x00000000, 0x00000000, 0x00000000, 0x00001067, 0x00000000, 0x00000000,
0x62000000, 0x00000010, 0x00000000, 0x00000000, 0x10670000, 0x00000000, 0x00000000, 0x00000000,
0x00106200, 0x00000000, 0x00000000, 0x00000000, 0x00001067, 0x00000000, 0x00000000, 0x67000000,
0x00000010, 0x00000000, 0x00000000, 0x10670000, 0x00000000, 0x00000000, 0x00000000, 0x00106700,
0x00000000, 0x00000000, 0x00000000, 0x00001067, 0x00000000, 0x00000000, 0x62000000, 0x00000010,
0x00000000, 0x00000000, 0x10670000, 0x00000000, 0x00000000, 0x00000000, 0x00106200, 0x00000000,
0x00000000, 0x00000000, 0x00001067, 0x00000000, 0x00000000, 0x62000000, 0x00000010, 0x00000000,
0x00000000, 0x10670000, 0x00000000, 0x00000000, 0x00000000, 0x00106200, 0x00000000, 0x00000000,
0x00000000, 0x00004063, 0x00000000, 0x00000000, 0x63000000, 0x00000040, 0x00000000, 0x00000000,
0x40630000, 0x00000000, 0x00000000, 0x00000000, 0x00406300, 0x00000000, 0x00000000, 0x00000000,
0x00004063, 0x00000000, 0x00000000, 0x63000000, 0x00000040, 0x00000000, 0x00000000, 0x40630000,
0x00000000, 0x00000000, 0x00000000, 0x00406300, 0x00000000, 0x00000000, 0x00000000, 0x00000127,
0x00000000, 0x00000000, 0x67000000, 0x00000010, 0x00000000, 0x00000000, 0x10670000, 0x00000000,
0x00000000, 0x00000000, 0x00106700, 0x00000000, 0x00000000, 0x00000000, 0x00001067, 0x00000000,
0x00000000, 0x67000000, 0x00000010, 0x00000000, 0x00000000, 0x10670000, 0x00000000, 0x00000000,
0x00000000, 0x00106700, 0x00000000, 0x00000000, 0x00000000, 0x00001067, 0x00000000, 0x00000000,
0x67000000, 0x00000010, 0x00000000, 0x00000000, 0x10670000, 0x00000000, 0x00000000, 0x00000000,
0x00106700, 0x00000000, 0x00000000, 0x00000000, 0x00001067, 0x00000000, 0x00000000, 0x67000000,
0x00000010, 0x00000000, 0x00000000, 0x10670000, 0x00000000, 0x00000000, 0x00000000, 0x00106700,
0x00000000, 0x00000000, 0x00000000, 0x00001067, 0x00000000, 0x00000000, 0x67000000, 0x00000010,
0x00000000, 0x00000000, 0x10670000, 0x00000000, 0x00000000, 0x00000000, 0x00106700, 0x00000000,
0x00000000, 0x00000000, 0x00001067, 0x00000000, 0x00000000, 0x67000000, 0x00000010, 0x00000000,
0x00000000, 0x10670000, 0x00000000, 0x00000000, 0x00000000, 0x00106700, 0x00000000, 0x00000000,
0x00000000, 0x00001067, 0x00000000, 0x00000000, 0x21000000, 0x00000001, 0x00000000, 0x00000000,
0x08670000, 0x00000000, 0x00000000, 0x00000000, 0x00012700, 0x00000000, 0x00000000, 0x00000000,
0x00000121, 0x00000000, 0x00000000, 0x27000000, 0x00000001, 0x00000000, 0x00000000, 0x01210000,
0x00000000, 0x00000000, 0x00000000, 0x00012700, 0x00000000, 0x00000000, 0x00000000, 0x00000127,
0x00000000, 0x00000000, 0x27000000, 0x00000001, 0x00000000, 0x00000000, 0x01270000, 0x00000000,
0x00000000, 0x00000000, 0x00012700, 0x00000000, 0x00000000, 0x00000000, 0x00000121, 0x00000000,
0x00000000, 0x27000000, 0x00000001, 0x00000000, 0x00000000, 0x01270000, 0x00000000, 0x00000000,
0x00000000, 0x00012100, 0x00000000, 0x00000000, 0x00000000, 0x00000127, 0x00000000, 0x00000000,
0x27000000, 0x00000001, 0x00000000, 0x00000000, 0x01210000, 0x00000000, 0x00000000, 0x00000000,
0x00012700, 0x00000000, 0x00000000, 0x00000000, 0x00000127, 0x00000000, 0x00000000, 0x27000000,
0x00000001, 0x00000000, 0x00000000, 0x01270000, 0x00000000, 0x00000000, 0x00000000, 0x00012700,
0x00000000, 0x00000000, 0x00000000, 0x00000127, 0x00000000, 0x00000000, 0x27000000, 0x00000001,
0x00000000, 0x00000000, 0x01270000, 0x00000000, 0x00000000, 0x00000000, 0x00012700, 0x00000000,
0x00000000, 0x00000000, 0x00000127, 0x00000000, 0x00000000, 0x27000000, 0x00000001, 0x00000000,
0x00000000, 0x01270000, 0x00000000, 0x00000000, 0x00000000, 0x00012700, 0x00000000, 0x00000000,
0x00000000, 0x00000127, 0x00000000, 0x00000000, 0x20000000, 0x00270001, 0x00000000, 0x00000000,
0x01200000, 0x00002600, 0x00000000, 0x00000000, 0x00012000, 0x00000029, 0x00000000, 0x00000000,
0x2f000120, 0x00000000, 0x00000000, 0x20000000, 0x00310001, 0x00000000, 0x00000000, 0x01200000,
0x00003700, 0x00000000, 0x00000000, 0x00106200, 0x00000081, 0x00000000, 0x00000000, 0x3e001062,
0x00000001, 0x00000000, 0x62000000, 0x00820010, 0x00000000, 0x00000000, 0x10620000, 0x00008300,
0x00000000, 0x00000000, 0x00406100, 0x000000c5, 0x00000000, 0x00000000, 0x9c002062, 0x00000000,
0x00000000, 0x62000000, 0x009b0020, 0x00000000, 0x00000000, 0x20630000, 0x0000de00, 0x00000000,
0x00000000, 0x00206300, 0x000000df, 0x00000000, 0x00000000, 0xe0002063, 0x00000000, 0x00000000,
0x63000000, 0x00e10020, 0x00000000, 0x00000000, 0x20630000, 0x0000e200, 0x00000000, 0x00000000,
0x00206300, 0x000000e3, 0x00000000, 0x00000000, 0xe4002063, 0x00000000, 0x00000000, 0x63000000,
0x00e50020, 0x00000000, 0x00000000, 0x20630000, 0x0000e600, 0x00000000, 0x00000000, 0x00206300,
0x000000e7, 0x00000000, 0x00000000, 0xe8002063, 0x00000000, 0x00000000, 0x63000000, 0x00e90020,
0x00000000, 0x00000000, 0x20630000, 0x0000ea00, 0x00000000, 0x00000000, 0x00206300, 0x000000eb,
0x00000000, 0x00000000, 0xec002063, 0x00000000, 0x00000000, 0x63000000, 0x00ed0020, 0x00000000,
0x00000000, 0x00000066, 0x00010000, 0x00000000, 0x00000100, 0x00000000, 0x00000001, 0x01000000,
0x00000000, 0x00010000, 0x00000000, 0x00000100, 0x00000000, 0x00000001, 0x01000000, 0x00000000,
0x00010000, 0x00000000, 0x00001000, 0x00000000, 0x00000010, 0x10000000, 0x00000000, 0x00100000,
0x00000000, 0x00001000, 0x00000000, 0x00000010, 0x10000000, 0x00000000, 0x00100000, 0x00000000,
0x00001000, 0x00000000, 0x00000010, 0x10000000, 0x00000000, 0x00100000, 0x00000000, 0x00001000,
0x00000000, 0x00000010, 0x10000000, 0x00000000, 0x00100000, 0x00000000, 0x00001000, 0x00000000,
0x00000010, 0x10000000, 0x00000000, 0x00100000, 0x00000000, 0x00001000, 0x00000000, 0x00000010,
0x10000000, 0x00000000, 0x00100000, 0x00000000, 0x00001000, 0x00000000, 0x00000010, 0x10000000,
0x00000000, 0x00100000, 0x00000000, 0x00001000, 0x00000000, 0x00000010, 0x10000000, 0x00000000,
0x00100000, 0x00000000, 0x00001000, 0x00000000, 0x00000010, 0x10000000, 0x00000000, 0x00100000,
0x00000000, 0x00001000, 0x00000000, 0x00000010, 0x10000000, 0x00000000, 0x00100000, 0x00000000,
0x00001000, 0x00000000, 0x00000010, 0x10000000, 0x00000000, 0x00100000, 0x00000000, 0x00001000,
0x00000000, 0x00000010, 0x10000000, 0x00000000, 0x00100000, 0x00000000, 0x00000100, 0x00000000,
0x00000001, 0x01000000, 0x00000000, 0x00100000, 0x00000000, 0x00001000, 0x00000000, 0x00000010,
0x10000000, 0x00000000, 0x00100000, 0x00000000, 0x00001000, 0x00000000, 0x00000010, 0x10000000,
0x00000000, 0x00100000, 0x00000000, 0x00001000, 0x00000000, 0x00000010, 0x10000000, 0x00000000,
0x00100000, 0x00000000, 0x00001000, 0x00000000, 0x00000010, 0x10000000, 0x00000000, 0x00100000,
0x00000000, 0x00001000, 0x00000000, 0x00000010, 0x10000000, 0x00000000, 0x00100000, 0x00000000,
0x00001000, 0x00000000, 0x00000010, 0x10000000, 0x00000000, 0x00010000, 0x00000000, 0x00000100,
0x00000000, 0x00000010, 0x10000000, 0x00000000, 0x00100000, 0x00000000, 0x00001000, 0x00000000,
0x00000010, 0x01000000, 0x00000000, 0x00010000, 0x00000000, 0x00000100, 0x00000000, 0x00000001,
0x01000000, 0x00000000, 0x00010000, 0x00000000, 0x00000100, 0x00000000, 0x00000001, 0x01000000,
0x00000000, 0x00010000, 0x00000000, 0x00000100, 0x001c001b, 0x00010000, 0x0000001d, 0x001e0000,
0x00000000, 0x0000001f, 0x00200000, 0x00000000, 0x00000021, 0x00220000, 0x00000000, 0x00000023,
0x00240000, 0x00000000, 0x00000025, 0x00260000, 0x00000000, 0x00000027, 0x00280000, 0x00000000,
0x00000029, 0x002a0000, 0x00000000, 0x0000002b, 0x002c0000, 0x00000000, 0x0000002d, 0x002e0000,
0x00000000, 0x0000002f, 0x00300000, 0x00000000, 0x00000031, 0x00320000, 0x00000000, 0x00000033,
0x00340000, 0x00000000, 0x00000035, 0x00360000, 0x00000000, 0x00370200, 0x00010000, 0x00003800,
0x00000100, 0x00000400, 0x00060200, 0x00200000, 0x07020004, 0x24000000, 0x00000400, 0x00000020,
0x00020028, 0x00002100, 0x02002a00, 0x009e8400, 0x001a4b00, 0x39000300, 0x14000000, 0x5f726468,
0x756c6433, 0x65675f74, 0x305f786e, 0x6d73612e, 0x0000003a, 0x00003b00, 0x30000100, 0x3c510000,
0x52000000, 0x00000035, 0x00000029, 0x00002200, 0x00000000, 0x00010002, 0x00000000, 0x00240121,
0x25000000, 0x00000000, 0x00020000, 0x00000022, 0x01210000, 0x00040105, 0x36520000, 0x29000000,
0x00000000, 0x00000023, 0x02000000, 0x00000200, 0x21000000, 0x00002401, 0x00240000, 0x00000000,
0x23000200, 0x00000000, 0x05012100, 0x00000301, 0x00545200, 0x00200000, 0x25000000, 0x00000000,
0x00020000, 0x00000025, 0x01210000, 0xfff00105, 0x00200000, 0x26000000, 0x00000000, 0x00020000,
0x00000024, 0x01210000, 0xfff80105, 0x00240000, 0x27000000, 0x00000000, 0x00020000, 0x00000025,
0x01210000, 0x00030105, 0x00370000, 0x04200006, 0x00015d00, 0x21000000, 0x015e0001, 0x00000000,
0x00280121, 0x00000000, 0x00000429, 0x00002b00, 0x00000000, 0x00280002, 0x00000000, 0x04290261,
0x2c000000, 0x00000000, 0x00020000, 0x00000028, 0x02610001, 0x00000429, 0x00002d00, 0x00000000,
0x00280002, 0x00020000, 0x04290261, 0x2e000000, 0x00000000, 0x00020000, 0x00000028, 0x02610003,
0x00000001, 0x00002900, 0x00000000, 0x00270002, 0x00000000, 0x01050121, 0x00000020, 0x00060037,
0x5f000420, 0x00000001, 0x00012100, 0x0000015e, 0x01210000, 0x0000002a, 0x04290000, 0x2b000000,
0x01000000, 0x00020000, 0x0000002a, 0x02610000, 0x00000429, 0x00002c00, 0x00000100, 0x002a0002,
0x00010000, 0x04290261, 0x2d000000, 0x01000000, 0x00020000, 0x0000002a, 0x02610002, 0x00000429,
0x00002e00, 0x00000100, 0x002a0002, 0x00030000, 0x00010261, 0x2f000000, 0x00000000, 0x00020000,
0x00000027, 0x01210000, 0x00400105, 0x00370000, 0x04200006, 0x00016000, 0x21000000, 0x015e0001,
0x00000000, 0x00300121, 0x00000000, 0x00000429, 0x00003300, 0x00000000, 0x00300002, 0x00000000,
0x04290261, 0x34000000, 0x00000000, 0x00020000, 0x00000030, 0x02610001, 0x00000429, 0x00003500,
0x00000000, 0x00300002, 0x00020000, 0x04290261, 0x36000000, 0x00000000, 0x00020000, 0x00000030,
0x02610003, 0x00000001, 0x00003100, 0x00000000, 0x00270002, 0x00000000, 0x01050121, 0x00000060,
0x00060037, 0x61000420, 0x00000001, 0x00012100, 0x0000015e, 0x01210000, 0x00000032, 0x04290000,
0x33000000, 0x01000000, 0x00020000, 0x00000032, 0x02610000, 0x00000429, 0x00003400, 0x00000100,
0x00320002, 0x00010000, 0x04290261, 0x35000000, 0x01000000, 0x00020000, 0x00000032, 0x02610002,
0x00000429, 0x00003600, 0x00000100, 0x00320002, 0x00030000, 0x00010261, 0x37000000, 0x00000000,
0x00020000, 0x00000026, 0x01210000, 0x00040105, 0x00370000, 0x04200006, 0x00015d00, 0x21000000,
0x01620001, 0x00000000, 0x00380121, 0x00000000, 0x00000429, 0x00003a00, 0x00000000, 0x00380002,
0x00000000, 0x04290261, 0x3b000000, 0x00000000, 0x00020000, 0x00000038, 0x02610001, 0x00000429,
0x00003c00, 0x00000000, 0x00380002, 0x00020000, 0x04290261, 0x3d000000, 0x00000000, 0x00020000,
0x00000038, 0x02610003, 0x00060037, 0x5f000420, 0x00000001, 0x00012100, 0x00000162, 0x01210000,
0x00000039, 0x04290000, 0x3a000000, 0x01000000, 0x00020000, 0x00000039, 0x02610000, 0x00000429,
0x00003b00, 0x00000100, 0x00390002, 0x00010000, 0x04290261, 0x3c000000, 0x01000000, 0x00020000,
0x00000039, 0x02610002, 0x00000429, 0x00003d00, 0x00000100, 0x00390002, 0x00030000, 0x00370261,
0x04200006, 0x00016000, 0x21000000, 0x01620001, 0x00000000, 0x003e0121, 0x00000000, 0x00000429,
0x00004000, 0x00000000, 0x003e0002, 0x00000000, 0x04290261, 0x41000000, 0x00000000, 0x00020000,
0x0000003e, 0x02610001, 0x00000429, 0x00004200, 0x00000000, 0x003e0002, 0x00020000, 0x04290261,
0x43000000, 0x00000000, 0x00020000, 0x0000003e, 0x02610003, 0x00060037, 0x61000420, 0x00000001,
0x00012100, 0x00000162, 0x01210000, 0x0000003f, 0x04290000, 0x40000000, 0x01000000, 0x00020000,
0x0000003f, 0x02610000, 0x00000429, 0x00004100, 0x00000100, 0x003f0002, 0x00010000, 0x04290261,
0x42000000, 0x01000000, 0x00020000, 0x0000003f, 0x02610002, 0x00000429, 0x00004300, 0x00000100,
0x003f0002, 0x00030000, 0x58520261, 0x29000000, 0x00000003, 0x00000163, 0x02000000, 0x00002b00,
0x51000000, 0x00032904, 0x01630000, 0x08000000, 0x33000200, 0x00000000, 0x29045100, 0x00000003,
0x00000164, 0x02000000, 0x00002c00, 0x51000000, 0x00032904, 0x01640000, 0x08000000, 0x34000200,
0x00000000, 0x29045100, 0x00000003, 0x00000165, 0x02000000, 0x00002d00, 0x51000000, 0x00032904,
0x01650000, 0x08000000, 0x35000200, 0x00000000, 0x29045100, 0x00000003, 0x00000166, 0x02000000,
0x00002e00, 0x51000000, 0x00032904, 0x01660000, 0x08000000, 0x36000200, 0x00000000, 0x52045100,
0x00000059, 0x00000329, 0x00004400, 0x00000000, 0x003a0002, 0x00000000, 0x03290451, 0x44000000,
0x00000000, 0x00020008, 0x00000040, 0x04510000, 0x00000329, 0x00004500, 0x00000000, 0x003b0002,
0x00000000, 0x03290451, 0x45000000, 0x00000000, 0x00020008, 0x00000041, 0x04510000, 0x00000329,
0x00004600, 0x00000000, 0x003c0002, 0x00000000, 0x03290451, 0x46000000, 0x00000000, 0x00020008,
0x00000042, 0x04510000, 0x00000329, 0x00004700, 0x00000000, 0x003d0002, 0x00000000, 0x03290451,
0x47000000, 0x00000000, 0x00020008, 0x00000043, 0x04510000, 0x00005a52, 0x00032900, 0x00480000,
0x00000000, 0x2b000200, 0x00000000, 0x29045101, 0x00000003, 0x00000048, 0x02000800, 0x00003300,
0x51010000, 0x00032904, 0x00480000, 0x00010000, 0x2c000200, 0x00000000, 0x29045101, 0x00000003,
0x00000048, 0x02000801, 0x00003400, 0x51010000, 0x00032904, 0x00490000, 0x00000000, 0x2d000200,
0x00000000, 0x29045101, 0x00000003, 0x00000049, 0x02000800, 0x00003500, 0x51010000, 0x00032904,
0x00490000, 0x00010000, 0x2e000200, 0x00000000, 0x29045101, 0x00000003, 0x00000049, 0x02000801,
0x00003600, 0x51010000, 0x005b5204, 0x03290000, 0x4a000000, 0x00000000, 0x00020000, 0x0000003a,
0x04510100, 0x00000329, 0x00004a00, 0x00080000, 0x00400002, 0x01000000, 0x03290451, 0x4b000000,
0x00000000, 0x00020000, 0x0000003b, 0x04510100, 0x00000329, 0x00004b00, 0x00080000, 0x00410002,
0x01000000, 0x03290451, 0x4c000000, 0x00000000, 0x00020000, 0x0000003c, 0x04510100, 0x00000329,
0x00004c00, 0x00080000, 0x00420002, 0x01000000, 0x03290451, 0x4d000000, 0x00000000, 0x00020000,
0x0000003d, 0x04510100, 0x00000329, 0x00004d00, 0x00080000, 0x00430002, 0x01000000, 0x5c520451,
0x29000000, 0x00000003, 0x0000004e, 0x02000000, 0x00002b00, 0x51020000, 0x00032904, 0x004e0000,
0x08000000, 0x33000200, 0x00000000, 0x29045102, 0x00000003, 0x0000004f, 0x02000000, 0x00002c00,
0x51020000, 0x00032904, 0x004f0000, 0x08000000, 0x34000200, 0x00000000, 0x29045102, 0x00000003,
0x00000050, 0x02000000, 0x00002d00, 0x51020000, 0x00032904, 0x00500000, 0x08000000, 0x35000200,
0x00000000, 0x29045102, 0x00000003, 0x00000051, 0x02000000, 0x00002e00, 0x51020000, 0x00032904,
0x00510000, 0x08000000, 0x36000200, 0x00000000, 0x52045102, 0x0000005d, 0x00000329, 0x00005200,
0x00000000, 0x003a0002, 0x02000000, 0x03290451, 0x52000000, 0x00000000, 0x00020008, 0x00000040,
0x04510200, 0x00000329, 0x00005300, 0x00000000, 0x003b0002, 0x02000000, 0x03290451, 0x53000000,
0x00000000, 0x00020008, 0x00000041, 0x04510200, 0x00000329, 0x00005400, 0x00000000, 0x003c0002,
0x02000000, 0x03290451, 0x54000000, 0x00000000, 0x00020008, 0x00000042, 0x04510200, 0x00000329,
0x00005500, 0x00000000, 0x003d0002, 0x02000000, 0x03290451, 0x55000000, 0x00000000, 0x00020008,
0x00000043, 0x04510200, 0x00006952, 0x00042900, 0x009d0000, 0x00000000, 0x63000200, 0x00000001,
0x10026100, 0x00000004, 0x0000009d, 0x02000000, 0x00009d00, 0x61000000, 0x08070502, 0x29378020,
0x00000004, 0x0000009f, 0x02000000, 0x00016400, 0x61000000, 0x00041002, 0x009f0000, 0x00000000,
0x9f000200, 0x00000000, 0x05026100, 0x80200807, 0x00042937, 0x00a10000, 0x00000000, 0x65000200,
0x00000001, 0x10026100, 0x00000004, 0x000000a1, 0x02000000, 0x0000a100, 0x61000000, 0x08070502,
0x29378020, 0x00000004, 0x000000a3, 0x02000000, 0x00016600, 0x61000000, 0x00041002, 0x00a30000,
0x00000000, 0xa3000200, 0x00000000, 0x05026100, 0x80200807, 0x00042937, 0x009e0000, 0x00000000,
0x48000200, 0x00000000, 0x10026100, 0x00000004, 0x0000009e, 0x02000000, 0x00009e00, 0x61000000,
0x08070502, 0x29378020, 0x00000004, 0x000000a0, 0x02000000, 0x00004800, 0x61000100, 0x00041002,
0x00a00000, 0x00000000, 0xa0000200, 0x00000000, 0x05026100, 0x80200807, 0x00042937, 0x00a20000,
0x00000000, 0x49000200, 0x00000000, 0x10026100, 0x00000004, 0x000000a2, 0x02000000, 0x0000a200,
0x61000000, 0x08070502, 0x29378020, 0x00000004, 0x000000a4, 0x02000000, 0x00004900, 0x61000100,
0x00041002, 0x00a40000, 0x00000000, 0xa4000200, 0x00000000, 0x05026100, 0x80200807, 0x00042937,
0x005f0000, 0x00000000, 0x4e000200, 0x00000000, 0x10026100, 0x00000004, 0x0000005f, 0x02000000,
0x00005f00, 0x61000000, 0x08070502, 0x29378020, 0x00000004, 0x00000061, 0x02000000, 0x00004f00,
0x61000000, 0x00041002, 0x00610000, 0x00000000, 0x61000200, 0x00000000, 0x05026100, 0x80200807,
0x00042937, 0x00630000, 0x00000000, 0x50000200, 0x00000000, 0x10026100, 0x00000004, 0x00000063,
0x02000000, 0x00006300, 0x61000000, 0x08070502, 0x29378020, 0x00000004, 0x00000065, 0x02000000,
0x00005100, 0x61000000, 0x00041002, 0x00650000, 0x00000000, 0x65000200, 0x00000000, 0x05026100,
0x80200807, 0x00042937, 0x00a50000, 0x00000000, 0x44000200, 0x00000000, 0x10026100, 0x00000004,
0x000000a5, 0x02000000, 0x0000a500, 0x61000000, 0x08070502, 0x29378020, 0x00000004, 0x000000a7,
0x02000000, 0x00004500, 0x61000000, 0x00041002, 0x00a70000, 0x00000000, 0xa7000200, 0x00000000,
0x05026100, 0x80200807, 0x00042937, 0x00a90000, 0x00000000, 0x46000200, 0x00000000, 0x10026100,
0x00000004, 0x000000a9, 0x02000000, 0x0000a900, 0x61000000, 0x08070502, 0x29378020, 0x00000004,
0x000000ab, 0x02000000, 0x00004700, 0x61000000, 0x00041002, 0x00ab0000, 0x00000000, 0xab000200,
0x00000000, 0x05026100, 0x80200807, 0x00042937, 0x00a60000, 0x00000000, 0x4a000200, 0x00000000,
0x10026100, 0x00000004, 0x000000a6, 0x02000000, 0x0000a600, 0x61000000, 0x08070502, 0x29378020,
0x00000004, 0x000000a8, 0x02000000, 0x00004b00, 0x61000000, 0x00041002, 0x00a80000, 0x00000000,
0xa8000200, 0x00000000, 0x05026100, 0x80200807, 0x00042937, 0x00aa0000, 0x00000000, 0x4c000200,
0x00000000, 0x10026100, 0x00000004, 0x000000aa, 0x02000000, 0x0000aa00, 0x61000000, 0x08070502,
0x29378020, 0x00000004, 0x000000ac, 0x02000000, 0x00004d00, 0x61000000, 0x00041002, 0x00ac0000,
0x00000000, 0xac000200, 0x00000000, 0x05026100, 0x80200807, 0x00042937, 0x006f0000, 0x00000000,
0x52000200, 0x00000000, 0x10026100, 0x00000004, 0x0000006f, 0x02000000, 0x00006f00, 0x61000000,
0x08070502, 0x29378020, 0x00000004, 0x00000071, 0x02000000, 0x00005300, 0x61000000, 0x00041002,
0x00710000, 0x00000000, 0x71000200, 0x00000000, 0x05026100, 0x80200807, 0x00042937, 0x00730000,
0x00000000, 0x54000200, 0x00000000, 0x10026100, 0x00000004, 0x00000073, 0x02000000, 0x00007300,
0x61000000, 0x08070502, 0x29378020, 0x00000004, 0x00000075, 0x02000000, 0x00005500, 0x61000000,
0x00041002, 0x00750000, 0x00000000, 0x75000200, 0x00000000, 0x05026100, 0x80200807, 0x00705237,
0x00370000, 0x08200007, 0x00000005, 0x00050000, 0x00000000, 0x000000c5, 0x76520000, 0x29000000,
0x00000000, 0x000000c5, 0x02000601, 0x00000705, 0x7752bf56, 0x29000000, 0x00000000, 0x000000c5,
0x02000602, 0xd0000705, 0x78524196, 0x29000000, 0x00000000, 0x000000c5, 0x02000603, 0x80000705,
0x7952c195, 0x29000000, 0x00000000, 0x000000c5, 0x02000604, 0xe06b0705, 0x7a5240c8, 0x29000000,
0x00000000, 0x000000c5, 0x02000605, 0xcdac0705, 0x7f523c4f, 0x11000000, 0x00000004, 0x0000009d,
0x02000000, 0x00009d00, 0x61000000, 0x00c50002, 0x06050000, 0x80520121, 0x0c000000, 0x00000004,
0x00000056, 0x02000000, 0x0000c500, 0x21060300, 0x009d0001, 0x00000000, 0xc5000261, 0x02000000,
0x52012106, 0x00000081, 0x00000401, 0x00009d00, 0x00000000, 0x009d0002, 0x00000000, 0xc5000261,
0x01000000, 0x52012106, 0x00000082, 0x00010445, 0x0000009d, 0x02000000, 0x00009d00, 0x61000000,
0x00070502, 0x52000000, 0x00000083, 0x00000403, 0x00009d00, 0x00000000, 0x009d0002, 0x00000000,
0x56000261, 0x00000000, 0x52026100, 0x00000084, 0x00000411, 0x00009d00, 0x00000000, 0x009d0002,
0x00000000, 0xc5000261, 0x04000000, 0x52012106, 0x0000007f, 0x00000411, 0x00009f00, 0x00000000,
0x009f0002, 0x00000000, 0xc5000261, 0x05000000, 0x52012106, 0x00000080, 0x0000040c, 0x00005700,
0x00000000, 0x00c50002, 0x06030000, 0x9f000121, 0x00000000, 0x00026100, 0x000000c5, 0x01210602,
0x00008152, 0x00040100, 0x009f0000, 0x00000000, 0x9f000200, 0x00000000, 0x00026100, 0x000000c5,
0x01210601, 0x00008252, 0x01044500, 0x00009f00, 0x00000000, 0x009f0002, 0x00000000, 0x07050261,
0x00000000, 0x00008352, 0x00040300, 0x009f0000, 0x00000000, 0x9f000200, 0x00000000, 0x00026100,
0x00000057, 0x02610000, 0x00008452, 0x00041100, 0x009f0000, 0x00000000, 0x9f000200, 0x00000000,
0x00026100, 0x000000c5, 0x01210604, 0x00007f52, 0x00041100, 0x00a10000, 0x00000000, 0xa1000200,
0x00000000, 0x00026100, 0x000000c5, 0x01210605, 0x00008052, 0x00040c00, 0x00580000, 0x00000000,
0xc5000200, 0x03000000, 0x00012106, 0x000000a1, 0x02610000, 0x0000c500, 0x21060200, 0x00815201,
0x04010000, 0xa1000000, 0x00000000, 0x00020000, 0x000000a1, 0x02610000, 0x0000c500, 0x21060100,
0x00825201, 0x04450000, 0x00a10001, 0x00000000, 0xa1000200, 0x00000000, 0x05026100, 0x00000007,
0x00835200, 0x04030000, 0xa1000000, 0x00000000, 0x00020000, 0x000000a1, 0x02610000, 0x00005800,
0x61000000, 0x00845202, 0x04110000, 0xa1000000, 0x00000000, 0x00020000, 0x000000a1, 0x02610000,
0x0000c500, 0x21060400, 0x007f5201, 0x04110000, 0xa3000000, 0x00000000, 0x00020000, 0x000000a3,
0x02610000, 0x0000c500, 0x21060500, 0x00805201, 0x040c0000, 0x59000000, 0x00000000, 0x00020000,
0x000000c5, 0x01210603, 0x0000a300, 0x61000000, 0x00c50002, 0x06020000, 0x81520121, 0x01000000,
0x00000004, 0x000000a3, 0x02000000, 0x0000a300, 0x61000000, 0x00c50002, 0x06010000, 0x82520121,
0x45000000, 0xa3000104, 0x00000000, 0x00020000, 0x000000a3, 0x02610000, 0x00000705, 0x83520000,
0x03000000, 0x00000004, 0x000000a3, 0x02000000, 0x0000a300, 0x61000000, 0x00590002, 0x00000000,
0x84520261, 0x11000000, 0x00000004, 0x000000a3, 0x02000000, 0x0000a300, 0x61000000, 0x00c50002,
0x06040000, 0x7f520121, 0x11000000, 0x00000004, 0x0000009e, 0x02000000, 0x00009e00, 0x61000000,
0x00c50002, 0x06050000, 0x80520121, 0x0c000000, 0x00000004, 0x0000005a, 0x02000000, 0x0000c500,
0x21060300, 0x009e0001, 0x00000000, 0xc5000261, 0x02000000, 0x52012106, 0x00000081, 0x00000401,
0x00009e00, 0x00000000, 0x009e0002, 0x00000000, 0xc5000261, 0x01000000, 0x52012106, 0x00000082,
0x00010445, 0x0000009e, 0x02000000, 0x00009e00, 0x61000000, 0x00070502, 0x52000000, 0x00000083,
0x00000403, 0x00009e00, 0x00000000, 0x009e0002, 0x00000000, 0x5a000261, 0x00000000, 0x52026100,
0x00000084, 0x00000411, 0x00009e00, 0x00000000, 0x009e0002, 0x00000000, 0xc5000261, 0x04000000,
0x52012106, 0x0000007f, 0x00000411, 0x0000a000, 0x00000000, 0x00a00002, 0x00000000, 0xc5000261,
0x05000000, 0x52012106, 0x00000080, 0x0000040c, 0x00005b00, 0x00000000, 0x00c50002, 0x06030000,
0xa0000121, 0x00000000, 0x00026100, 0x000000c5, 0x01210602, 0x00008152, 0x00040100, 0x00a00000,
0x00000000, 0xa0000200, 0x00000000, 0x00026100, 0x000000c5, 0x01210601, 0x00008252, 0x01044500,
0x0000a000, 0x00000000, 0x00a00002, 0x00000000, 0x07050261, 0x00000000, 0x00008352, 0x00040300,
0x00a00000, 0x00000000, 0xa0000200, 0x00000000, 0x00026100, 0x0000005b, 0x02610000, 0x00008452,
0x00041100, 0x00a00000, 0x00000000, 0xa0000200, 0x00000000, 0x00026100, 0x000000c5, 0x01210604,
0x00007f52, 0x00041100, 0x00a20000, 0x00000000, 0xa2000200, 0x00000000, 0x00026100, 0x000000c5,
0x01210605, 0x00008052, 0x00040c00, 0x005c0000, 0x00000000, 0xc5000200, 0x03000000, 0x00012106,
0x000000a2, 0x02610000, 0x0000c500, 0x21060200, 0x00815201, 0x04010000, 0xa2000000, 0x00000000,
0x00020000, 0x000000a2, 0x02610000, 0x0000c500, 0x21060100, 0x00825201, 0x04450000, 0x00a20001,
0x00000000, 0xa2000200, 0x00000000, 0x05026100, 0x00000007, 0x00835200, 0x04030000, 0xa2000000,
0x00000000, 0x00020000, 0x000000a2, 0x02610000, 0x00005c00, 0x61000000, 0x00845202, 0x04110000,
0xa2000000, 0x00000000, 0x00020000, 0x000000a2, 0x02610000, 0x0000c500, 0x21060400, 0x007f5201,
0x04110000, 0xa4000000, 0x00000000, 0x00020000, 0x000000a4, 0x02610000, 0x0000c500, 0x21060500,
0x00805201, 0x040c0000, 0x5d000000, 0x00000000, 0x00020000, 0x000000c5, 0x01210603, 0x0000a400,
0x61000000, 0x00c50002, 0x06020000, 0x81520121, 0x01000000, 0x00000004, 0x000000a4, 0x02000000,
0x0000a400, 0x61000000, 0x00c50002, 0x06010000, 0x82520121, 0x45000000, 0xa4000104, 0x00000000,
0x00020000, 0x000000a4, 0x02610000, 0x00000705, 0x83520000, 0x03000000, 0x00000004, 0x000000a4,
0x02000000, 0x0000a400, 0x61000000, 0x005d0002, 0x00000000, 0x84520261, 0x11000000, 0x00000004,
0x000000a4, 0x02000000, 0x0000a400, 0x61000000, 0x00c50002, 0x06040000, 0x7f520121, 0x11000000,
0x00000004, 0x0000005f, 0x02000000, 0x00005f00, 0x61000000, 0x00c50002, 0x06050000, 0x80520121,
0x0c000000, 0x00000004, 0x0000005e, 0x02000000, 0x0000c500, 0x21060300, 0x005f0001, 0x00000000,
0xc5000261, 0x02000000, 0x52012106, 0x00000081, 0x00000401, 0x00005f00, 0x00000000, 0x005f0002,
0x00000000, 0xc5000261, 0x01000000, 0x52012106, 0x00000082, 0x00010445, 0x0000005f, 0x02000000,
0x00005f00, 0x61000000, 0x00070502, 0x52000000, 0x00000083, 0x00000403, 0x00005f00, 0x00000000,
0x005f0002, 0x00000000, 0x5e000261, 0x00000000, 0x52026100, 0x00000084, 0x00000411, 0x00005f00,
0x00000000, 0x005f0002, 0x00000000, 0xc5000261, 0x04000000, 0x52012106, 0x0000007f, 0x00000411,
0x00006100, 0x00000000, 0x00610002, 0x00000000, 0xc5000261, 0x05000000, 0x52012106, 0x00000080,
0x0000040c, 0x00006000, 0x00000000, 0x00c50002, 0x06030000, 0x61000121, 0x00000000, 0x00026100,
0x000000c5, 0x01210602, 0x00008152, 0x00040100, 0x00610000, 0x00000000, 0x61000200, 0x00000000,
0x00026100, 0x000000c5, 0x01210601, 0x00008252, 0x01044500, 0x00006100, 0x00000000, 0x00610002,
0x00000000, 0x07050261, 0x00000000, 0x00008352, 0x00040300, 0x00610000, 0x00000000, 0x61000200,
0x00000000, 0x00026100, 0x00000060, 0x02610000, 0x00008452, 0x00041100, 0x00610000, 0x00000000,
0x61000200, 0x00000000, 0x00026100, 0x000000c5, 0x01210604, 0x00007f52, 0x00041100, 0x00630000,
0x00000000, 0x63000200, 0x00000000, 0x00026100, 0x000000c5, 0x01210605, 0x00008052, 0x00040c00,
0x00620000, 0x00000000, 0xc5000200, 0x03000000, 0x00012106, 0x00000063, 0x02610000, 0x0000c500,
0x21060200, 0x00815201, 0x04010000, 0x63000000, 0x00000000, 0x00020000, 0x00000063, 0x02610000,
0x0000c500, 0x21060100, 0x00825201, 0x04450000, 0x00630001, 0x00000000, 0x63000200, 0x00000000,
0x05026100, 0x00000007, 0x00835200, 0x04030000, 0x63000000, 0x00000000, 0x00020000, 0x00000063,
0x02610000, 0x00006200, 0x61000000, 0x00845202, 0x04110000, 0x63000000, 0x00000000, 0x00020000,
0x00000063, 0x02610000, 0x0000c500, 0x21060400, 0x007f5201, 0x04110000, 0x65000000, 0x00000000,
0x00020000, 0x00000065, 0x02610000, 0x0000c500, 0x21060500, 0x00805201, 0x040c0000, 0x64000000,
0x00000000, 0x00020000, 0x000000c5, 0x01210603, 0x00006500, 0x61000000, 0x00c50002, 0x06020000,
0x81520121, 0x01000000, 0x00000004, 0x00000065, 0x02000000, 0x00006500, 0x61000000, 0x00c50002,
0x06010000, 0x82520121, 0x45000000, 0x65000104, 0x00000000, 0x00020000, 0x00000065, 0x02610000,
0x00000705, 0x83520000, 0x03000000, 0x00000004, 0x00000065, 0x02000000, 0x00006500, 0x61000000,
0x00640002, 0x00000000, 0x84520261, 0x11000000, 0x00000004, 0x00000065, 0x02000000, 0x00006500,
0x61000000, 0x00c50002, 0x06040000, 0x7f520121, 0x11000000, 0x00000004, 0x000000a5, 0x02000000,
0x0000a500, 0x61000000, 0x00c50002, 0x06050000, 0x80520121, 0x0c000000, 0x00000004, 0x00000066,
0x02000000, 0x0000c500, 0x21060300, 0x00a50001, 0x00000000, 0xc5000261, 0x02000000, 0x52012106,
0x00000081, 0x00000401, 0x0000a500, 0x00000000, 0x00a50002, 0x00000000, 0xc5000261, 0x01000000,
0x52012106, 0x00000082, 0x00010445, 0x000000a5, 0x02000000, 0x0000a500, 0x61000000, 0x00070502,
0x52000000, 0x00000083, 0x00000403, 0x0000a500, 0x00000000, 0x00a50002, 0x00000000, 0x66000261,
0x00000000, 0x52026100, 0x00000084, 0x00000411, 0x0000a500, 0x00000000, 0x00a50002, 0x00000000,
0xc5000261, 0x04000000, 0x52012106, 0x0000007f, 0x00000411, 0x0000a700, 0x00000000, 0x00a70002,
0x00000000, 0xc5000261, 0x05000000, 0x52012106, 0x00000080, 0x0000040c, 0x00006700, 0x00000000,
0x00c50002, 0x06030000, 0xa7000121, 0x00000000, 0x00026100, 0x000000c5, 0x01210602, 0x00008152,
0x00040100, 0x00a70000, 0x00000000, 0xa7000200, 0x00000000, 0x00026100, 0x000000c5, 0x01210601,
0x00008252, 0x01044500, 0x0000a700, 0x00000000, 0x00a70002, 0x00000000, 0x07050261, 0x00000000,
0x00008352, 0x00040300, 0x00a70000, 0x00000000, 0xa7000200, 0x00000000, 0x00026100, 0x00000067,
0x02610000, 0x00008452, 0x00041100, 0x00a70000, 0x00000000, 0xa7000200, 0x00000000, 0x00026100,
0x000000c5, 0x01210604, 0x00007f52, 0x00041100, 0x00a90000, 0x00000000, 0xa9000200, 0x00000000,
0x00026100, 0x000000c5, 0x01210605, 0x00008052, 0x00040c00, 0x00680000, 0x00000000, 0xc5000200,
0x03000000, 0x00012106, 0x000000a9, 0x02610000, 0x0000c500, 0x21060200, 0x00815201, 0x04010000,
0xa9000000, 0x00000000, 0x00020000, 0x000000a9, 0x02610000, 0x0000c500, 0x21060100, 0x00825201,
0x04450000, 0x00a90001, 0x00000000, 0xa9000200, 0x00000000, 0x05026100, 0x00000007, 0x00835200,
0x04030000, 0xa9000000, 0x00000000, 0x00020000, 0x000000a9, 0x02610000, 0x00006800, 0x61000000,
0x00845202, 0x04110000, 0xa9000000, 0x00000000, 0x00020000, 0x000000a9, 0x02610000, 0x0000c500,
0x21060400, 0x007f5201, 0x04110000, 0xab000000, 0x00000000, 0x00020000, 0x000000ab, 0x02610000,
0x0000c500, 0x21060500, 0x00805201, 0x040c0000, 0x69000000, 0x00000000, 0x00020000, 0x000000c5,
0x01210603, 0x0000ab00, 0x61000000, 0x00c50002, 0x06020000, 0x81520121, 0x01000000, 0x00000004,
0x000000ab, 0x02000000, 0x0000ab00, 0x61000000, 0x00c50002, 0x06010000, 0x82520121, 0x45000000,
0xab000104, 0x00000000, 0x00020000, 0x000000ab, 0x02610000, 0x00000705, 0x83520000, 0x03000000,
0x00000004, 0x000000ab, 0x02000000, 0x0000ab00, 0x61000000, 0x00690002, 0x00000000, 0x84520261,
0x11000000, 0x00000004, 0x000000ab, 0x02000000, 0x0000ab00, 0x61000000, 0x00c50002, 0x06040000,
0x7f520121, 0x11000000, 0x00000004, 0x000000a6, 0x02000000, 0x0000a600, 0x61000000, 0x00c50002,
0x06050000, 0x80520121, 0x0c000000, 0x00000004, 0x0000006a, 0x02000000, 0x0000c500, 0x21060300,
0x00a60001, 0x00000000, 0xc5000261, 0x02000000, 0x52012106, 0x00000081, 0x00000401, 0x0000a600,
0x00000000, 0x00a60002, 0x00000000, 0xc5000261, 0x01000000, 0x52012106, 0x00000082, 0x00010445,
0x000000a6, 0x02000000, 0x0000a600, 0x61000000, 0x00070502, 0x52000000, 0x00000083, 0x00000403,
0x0000a600, 0x00000000, 0x00a60002, 0x00000000, 0x6a000261, 0x00000000, 0x52026100, 0x00000084,
0x00000411, 0x0000a600, 0x00000000, 0x00a60002, 0x00000000, 0xc5000261, 0x04000000, 0x52012106,
0x0000007f, 0x00000411, 0x0000a800, 0x00000000, 0x00a80002, 0x00000000, 0xc5000261, 0x05000000,
0x52012106, 0x00000080, 0x0000040c, 0x00006b00, 0x00000000, 0x00c50002, 0x06030000, 0xa8000121,
0x00000000, 0x00026100, 0x000000c5, 0x01210602, 0x00008152, 0x00040100, 0x00a80000, 0x00000000,
0xa8000200, 0x00000000, 0x00026100, 0x000000c5, 0x01210601, 0x00008252, 0x01044500, 0x0000a800,
0x00000000, 0x00a80002, 0x00000000, 0x07050261, 0x00000000, 0x00008352, 0x00040300, 0x00a80000,
0x00000000, 0xa8000200, 0x00000000, 0x00026100, 0x0000006b, 0x02610000, 0x00008452, 0x00041100,
0x00a80000, 0x00000000, 0xa8000200, 0x00000000, 0x00026100, 0x000000c5, 0x01210604, 0x00007f52,
0x00041100, 0x00aa0000, 0x00000000, 0xaa000200, 0x00000000, 0x00026100, 0x000000c5, 0x01210605,
0x00008052, 0x00040c00, 0x006c0000, 0x00000000, 0xc5000200, 0x03000000, 0x00012106, 0x000000aa,
0x02610000, 0x0000c500, 0x21060200, 0x00815201, 0x04010000, 0xaa000000, 0x00000000, 0x00020000,
0x000000aa, 0x02610000, 0x0000c500, 0x21060100, 0x00825201, 0x04450000, 0x00aa0001, 0x00000000,
0xaa000200, 0x00000000, 0x05026100, 0x00000007, 0x00835200, 0x04030000, 0xaa000000, 0x00000000,
0x00020000, 0x000000aa, 0x02610000, 0x00006c00, 0x61000000, 0x00845202, 0x04110000, 0xaa000000,
0x00000000, 0x00020000, 0x000000aa, 0x02610000, 0x0000c500, 0x21060400, 0x007f5201, 0x04110000,
0xac000000, 0x00000000, 0x00020000, 0x000000ac, 0x02610000, 0x0000c500, 0x21060500, 0x00805201,
0x040c0000, 0x6d000000, 0x00000000, 0x00020000, 0x000000c5, 0x01210603, 0x0000ac00, 0x61000000,
0x00c50002, 0x06020000, 0x81520121, 0x01000000, 0x00000004, 0x000000ac, 0x02000000, 0x0000ac00,
0x61000000, 0x00c50002, 0x06010000, 0x82520121, 0x45000000, 0xac000104, 0x00000000, 0x00020000,
0x000000ac, 0x02610000, 0x00000705, 0x83520000, 0x03000000, 0x00000004, 0x000000ac, 0x02000000,
0x0000ac00, 0x61000000, 0x006d0002, 0x00000000, 0x84520261, 0x11000000, 0x00000004, 0x000000ac,
0x02000000, 0x0000ac00, 0x61000000, 0x00c50002, 0x06040000, 0x7f520121, 0x11000000, 0x00000004,
0x0000006f, 0x02000000, 0x00006f00, 0x61000000, 0x00c50002, 0x06050000, 0x80520121, 0x0c000000,
0x00000004, 0x0000006e, 0x02000000, 0x0000c500, 0x21060300, 0x006f0001, 0x00000000, 0xc5000261,
0x02000000, 0x52012106, 0x00000081, 0x00000401, 0x00006f00, 0x00000000, 0x006f0002, 0x00000000,
0xc5000261, 0x01000000, 0x52012106, 0x00000082, 0x00010445, 0x0000006f, 0x02000000, 0x00006f00,
0x61000000, 0x00070502, 0x52000000, 0x00000083, 0x00000403, 0x00006f00, 0x00000000, 0x006f0002,
0x00000000, 0x6e000261, 0x00000000, 0x52026100, 0x00000084, 0x00000411, 0x00006f00, 0x00000000,
0x006f0002, 0x00000000, 0xc5000261, 0x04000000, 0x52012106, 0x0000007f, 0x00000411, 0x00007100,
0x00000000, 0x00710002, 0x00000000, 0xc5000261, 0x05000000, 0x52012106, 0x00000080, 0x0000040c,
0x00007000, 0x00000000, 0x00c50002, 0x06030000, 0x71000121, 0x00000000, 0x00026100, 0x000000c5,
0x01210602, 0x00008152, 0x00040100, 0x00710000, 0x00000000, 0x71000200, 0x00000000, 0x00026100,
0x000000c5, 0x01210601, 0x00008252, 0x01044500, 0x00007100, 0x00000000, 0x00710002, 0x00000000,
0x07050261, 0x00000000, 0x00008352, 0x00040300, 0x00710000, 0x00000000, 0x71000200, 0x00000000,
0x00026100, 0x00000070, 0x02610000, 0x00008452, 0x00041100, 0x00710000, 0x00000000, 0x71000200,
0x00000000, 0x00026100, 0x000000c5, 0x01210604, 0x00007f52, 0x00041100, 0x00730000, 0x00000000,
0x73000200, 0x00000000, 0x00026100, 0x000000c5, 0x01210605, 0x00008052, 0x00040c00, 0x00720000,
0x00000000, 0xc5000200, 0x03000000, 0x00012106, 0x00000073, 0x02610000, 0x0000c500, 0x21060200,
0x00815201, 0x04010000, 0x73000000, 0x00000000, 0x00020000, 0x00000073, 0x02610000, 0x0000c500,
0x21060100, 0x00825201, 0x04450000, 0x00730001, 0x00000000, 0x73000200, 0x00000000, 0x05026100,
0x00000007, 0x00835200, 0x04030000, 0x73000000, 0x00000000, 0x00020000, 0x00000073, 0x02610000,
0x00007200, 0x61000000, 0x00845202, 0x04110000, 0x73000000, 0x00000000, 0x00020000, 0x00000073,
0x02610000, 0x0000c500, 0x21060400, 0x007f5201, 0x04110000, 0x75000000, 0x00000000, 0x00020000,
0x00000075, 0x02610000, 0x0000c500, 0x21060500, 0x00805201, 0x040c0000, 0x74000000, 0x00000000,
0x00020000, 0x000000c5, 0x01210603, 0x00007500, 0x61000000, 0x00c50002, 0x06020000, 0x81520121,
0x01000000, 0x00000004, 0x00000075, 0x02000000, 0x00007500, 0x61000000, 0x00c50002, 0x06010000,
0x82520121, 0x45000000, 0x75000104, 0x00000000, 0x00020000, 0x00000075, 0x02610000, 0x00000705,
0x83520000, 0x03000000, 0x00000004, 0x00000075, 0x02000000, 0x00007500, 0x61000000, 0x00740002,
0x00000000, 0x84520261, 0x11000000, 0x00000004, 0x00000075, 0x02000000, 0x00007500, 0x61000000,
0x00c50002, 0x06040000, 0x8f520121, 0x03000000, 0x00000000, 0x00000076, 0x02000000, 0x0000c500,
0x21060700, 0x00070501, 0x52461c40, 0x00000090, 0x00000003, 0x00007700, 0x00000000, 0x00c50002,
0x07070000, 0x07050121, 0x461c4000, 0x00009c52, 0x00002900, 0x00810000, 0x00000000, 0x07050200,
0x00000000, 0x00009852, 0x00002c00, 0x00000102, 0x00000167, 0x01210706, 0x00010105, 0x00320000,
0x00118001, 0x00009d52, 0x00002900, 0x00810000, 0x01000000, 0x07050200, 0x3d000000, 0x00009e52,
0x00002900, 0x00810000, 0x02000000, 0x07050200, 0x3dc00000, 0x00009f52, 0x00002900, 0x00810000,
0x03000000, 0x07050200, 0x3e000000, 0x0000a052, 0x00002900, 0x00810000, 0x04000000, 0x07050200,
0x3e600000, 0x0000a152, 0x00002900, 0x00810000, 0x05000000, 0x07050200, 0x3ed00000, 0x0000a352,
0x00002900, 0x013e0000, 0x00000000, 0x07050200, 0x00000000, 0x0000a452, 0x00002900, 0x013e0000,
0x01000000, 0x07050200, 0x3f333333, 0x0000a552, 0x00002900, 0x013e0000, 0x02000000, 0x07050200,
0x3f666666, 0x0000a652, 0x00002900, 0x013e0000, 0x03000000, 0x07050200, 0x3f733333, 0x0000a752,
0x00002900, 0x013e0000, 0x04000000, 0x07050200, 0x3f7d70a4, 0x0000a852, 0x00002900, 0x013e0000,
0x05000000, 0x07050200, 0x3f800000, 0x00000029, 0x00007800, 0x00000000, 0x00070502, 0x52000000,
0x000000aa, 0x0202002c, 0x81000002, 0x00000000, 0x05012101, 0x00000007, 0x02003200, 0x03000180,
0x00000000, 0x00000078, 0x02000000, 0x00013e00, 0x21010000, 0x00810001, 0x01000000, 0x01310121,
0x00002900, 0x00820000, 0x00000000, 0x78000200, 0x00000000, 0x52012100, 0x000000ab, 0x00000010,
0x00013e00, 0x00010000, 0x00820002, 0x00000000, 0x81000121, 0x00000000, 0x52012101, 0x000000ac,
0x00000001, 0x00007900, 0x00000000, 0x00810002, 0x02000000, 0x81100121, 0x00000000, 0x29012101,
0x00000000, 0x0000007a, 0x02000000, 0x00000705, 0x002c0000, 0x00030202, 0x00007900, 0x21000000,
0x00070501, 0x32000000, 0x02800300, 0x00000100, 0x007a0000, 0x00000000, 0x3e000200, 0x00000001,
0x10012102, 0x0000013e, 0x01210100, 0x00000003, 0x00007a00, 0x00000000, 0x007a0002, 0x00000000,
0x79000121, 0x00000000, 0x31012100, 0x00290002, 0x82000000, 0x00000000, 0x00020001, 0x0000007a,
0x01210000, 0x0000ad52, 0x00000c00, 0x013e0000, 0x02000000, 0x82000200, 0x00000000, 0x00012101,
0x00000079, 0x01210000, 0x00013e00, 0x21010000, 0x00ae5201, 0x00010000, 0x7b000000, 0x00000000,
0x00020000, 0x00000081, 0x01210300, 0x00008110, 0x21020000, 0x00002901, 0x007c0000, 0x00000000,
0x07050200, 0x00000000, 0x0202002c, 0x7b000004, 0x00000000, 0x05012100, 0x00000007, 0x04003200,
0x01000380, 0x00000000, 0x0000007c, 0x02000000, 0x00013e00, 0x21030000, 0x013e1001, 0x02000000,
0x00030121, 0x7c000000, 0x00000000, 0x00020000, 0x0000007c, 0x01210000, 0x00007b00, 0x21000000,
0x00033101, 0x00000029, 0x00008200, 0x00020000, 0x007c0002, 0x00000000, 0xaf520121, 0x0c000000,
0x00000000, 0x0000013e, 0x02000300, 0x00008200, 0x21020000, 0x007b0001, 0x00000000, 0x3e000121,
0x00000001, 0x52012102, 0x000000b0, 0x00000001, 0x00007d00, 0x00000000, 0x00810002, 0x04000000,
0x81100121, 0x00000000, 0x29012103, 0x00000000, 0x0000007e, 0x02000000, 0x00000705, 0x002c0000,
0x00050202, 0x00007d00, 0x21000000, 0x00070501, 0x32000000, 0x04800500, 0x00000100, 0x007e0000,
0x00000000, 0x3e000200, 0x00000001, 0x10012104, 0x0000013e, 0x01210300, 0x00000003, 0x00007e00,
0x00000000, 0x007e0002, 0x00000000, 0x7d000121, 0x00000000, 0x31012100, 0x00290004, 0x82000000,
0x00000000, 0x00020003, 0x0000007e, 0x01210000, 0x0000b152, 0x00000c00, 0x013e0000, 0x04000000,
0x82000200, 0x00000000, 0x00012103, 0x0000007d, 0x01210000, 0x00013e00, 0x21030000, 0x00b25201,
0x00010000, 0x7f000000, 0x00000000, 0x00020000, 0x00000081, 0x01210500, 0x00008110, 0x21040000,
0x00002901, 0x00800000, 0x00000000, 0x07050200, 0x00000000, 0x0202002c, 0x7f000006, 0x00000000,
0x05012100, 0x00000007, 0x06003200, 0x01000580, 0x00000000, 0x00000080, 0x02000000, 0x00013e00,
0x21050000, 0x013e1001, 0x04000000, 0x00030121, 0x80000000, 0x00000000, 0x00020000, 0x00000080,
0x01210000, 0x00007f00, 0x21000000, 0x00053101, 0x00000029, 0x00008200, 0x00040000, 0x00800002,
0x00000000, 0xb3520121, 0x29000000, 0x00000000, 0x00000082, 0x02000500, 0x00000705, 0xb5520000,
0x29000000, 0x00000000, 0x00000083, 0x02000000, 0x00000705, 0xb6520000, 0x0c000000, 0x00000000,
0x00000083, 0x02000100, 0x00008200, 0x21010000, 0x00811001, 0x01000000, 0x3e000121, 0x00000001,
0x52012101, 0x000000b7, 0x0000000c, 0x00008300, 0x00020000, 0x00820002, 0x02000000, 0x81100121,
0x00000000, 0x00012102, 0x0000013e, 0x01210200, 0x0000b852, 0x00000c00, 0x00830000, 0x03000000,
0x82000200, 0x00000000, 0x10012103, 0x00000081, 0x01210300, 0x00013e00, 0x21030000, 0x00b95201,
0x000c0000, 0x83000000, 0x00000000, 0x00020004, 0x00000082, 0x01210400, 0x00008110, 0x21040000,
0x013e0001, 0x04000000, 0xba520121, 0x29000000, 0x00000000, 0x00000083, 0x02000500, 0x00000705,
0x06313f80, 0x00bb5200, 0x002c0000, 0x00070204, 0x00016700, 0x21060600, 0x03010501, 0x32000000,
0x10000700, 0x04002c00, 0x00000802, 0x00000167, 0x01210606, 0x00040105, 0x00320000, 0x000f0008,
0x0200002c, 0x67000009, 0x06000001, 0x05012106, 0x00000401, 0x09003200, 0x52000e80, 0x00000105,
0x00000029, 0x0000c500, 0x00060600, 0xd0070502, 0x523e59b3, 0x00000106, 0x00000029, 0x0000c500,
0x00070600, 0x59070502, 0x523f3717, 0x00000107, 0x00000029, 0x0000c500, 0x00060700, 0x98070502,
0x313d93dd, 0x27520007, 0x10000001, 0x00000004, 0x00000084, 0x02000000, 0x0000c500, 0x21070600,
0x009e0001, 0x00000000, 0x040c0261, 0x84000000, 0x00000000, 0x00020000, 0x000000c5, 0x01210606,
0x00009d00, 0x61000000, 0x00840002, 0x00000000, 0x040c0261, 0x84000000, 0x00000000, 0x00020000,
0x000000c5, 0x01210607, 0x00005f00, 0x61000000, 0x00840002, 0x00000000, 0x29520261, 0x2c000001,
0x0a020204, 0x00840000, 0x00000000, 0x81000261, 0x00000000, 0x2a012101, 0x00000a04, 0x000000af,
0x02000000, 0x00008200, 0x21010000, 0x00820001, 0x00000000, 0x2a520121, 0x2c000001, 0x0b020204,
0x00840000, 0x00000000, 0x81000261, 0x00000000, 0x2a012102, 0x00000b04, 0x000000af, 0x02000000,
0x00008200, 0x21020000, 0x00af0001, 0x00000000, 0x2b520261, 0x2c000001, 0x0c020204, 0x00840000,
0x00000000, 0x81000261, 0x00000000, 0x2a012103, 0x00000c04, 0x000000af, 0x02000000, 0x00008200,
0x21030000, 0x00af0001, 0x00000000, 0x2c520261, 0x2c000001, 0x0d020204, 0x00840000, 0x00000000,
0x81000261, 0x00000000, 0x2a012104, 0x00000d04, 0x000000af, 0x02000000, 0x00008200, 0x21040000,
0x00af0001, 0x00000000, 0x2d520261, 0x2c000001, 0x0e020204, 0x00840000, 0x00000000, 0x81000261,
0x00000000, 0x2a012105, 0x00000e04, 0x000000af, 0x02000000, 0x00008200, 0x21050000, 0x00af0001,
0x00000000, 0x30520261, 0x2a000001, 0x00000a04, 0x00000085, 0x02000000, 0x00008300, 0x21010000,
0x00830001, 0x00000000, 0x31520121, 0x2a000001, 0x00000b04, 0x00000085, 0x02000000, 0x00008300,
0x21020000, 0x00850001, 0x00000000, 0x32520261, 0x2a000001, 0x00000c04, 0x00000085, 0x02000000,
0x00008300, 0x21030000, 0x00850001, 0x00000000, 0x33520261, 0x2a000001, 0x00000d04, 0x00000085,
0x02000000, 0x00008300, 0x21040000, 0x00850001, 0x00000000, 0x34520261, 0x2a000001, 0x00000e04,
0x00000085, 0x02000000, 0x00008300, 0x21050000, 0x00850001, 0x00000000, 0x36520261, 0x0c000001,
0x00000004, 0x000000af, 0x02000000, 0x00008400, 0x61000000, 0x00af0002, 0x00000000, 0x85000261,
0x00000000, 0x52026100, 0x00000138, 0x0000041b, 0x00008600, 0x00000000, 0x00840002, 0x00000000,
0x04100261, 0xaf000000, 0x00000000, 0x00020000, 0x000000af, 0x02610000, 0x00008600, 0x61000000,
0x01395202, 0x042c0000, 0x000f0200, 0x00008400, 0x61000000, 0x00070502, 0x2a000000, 0x00000f04,
0x000000af, 0x02000000, 0x00000705, 0xaf000000, 0x00000000, 0x52026100, 0x0000013a, 0x00000410,
0x00009d00, 0x00000000, 0x009d0002, 0x00000000, 0xaf000261, 0x00000000, 0x45026100, 0x9d000004,
0x00000000, 0x00020000, 0x0000009d, 0x02610000, 0x00000705, 0x3b523f80, 0x10000001, 0x00000004,
0x0000009e, 0x02000000, 0x0000af00, 0x61000000, 0x009e0002, 0x00000000, 0x04450261, 0x009e0000,
0x00000000, 0x9e000200, 0x00000000, 0x05026100, 0x80000007, 0x013c523f, 0x04100000, 0xaf000000,
0x00000000, 0x00020000, 0x000000af, 0x02610000, 0x00005f00, 0x61000000, 0x00044502, 0x0000af00,
0x00000000, 0x00af0002, 0x00000000, 0x07050261, 0x3f800000, 0x00012752, 0x00041000, 0x00870000,
0x00000000, 0xc5000200, 0x06000000, 0x00012107, 0x000000a0, 0x02610000, 0x0000040c, 0x00008700,
0x00000000, 0x00c50002, 0x06060000, 0x9f000121, 0x00000000, 0x00026100, 0x00000087, 0x02610000,
0x0000040c, 0x00008700, 0x00000000, 0x00c50002, 0x06070000, 0x61000121, 0x00000000, 0x00026100,
0x00000087, 0x02610000, 0x00012952, 0x02042c00, 0x00001002, 0x00000087, 0x02610000, 0x00008100,
0x21010000, 0x10042a01, 0x00b20000, 0x00000000, 0x82000200, 0x00000000, 0x00012101, 0x00000082,
0x01210000, 0x00012a52, 0x02042c00, 0x00001102, 0x00000087, 0x02610000, 0x00008100, 0x21020000,
0x11042a01, 0x00b20000, 0x00000000, 0x82000200, 0x00000000, 0x00012102, 0x000000b2, 0x02610000,
0x00012b52, 0x02042c00, 0x00001202, 0x00000087, 0x02610000, 0x00008100, 0x21030000, 0x12042a01,
0x00b20000, 0x00000000, 0x82000200, 0x00000000, 0x00012103, 0x000000b2, 0x02610000, 0x00012c52,
0x02042c00, 0x00001302, 0x00000087, 0x02610000, 0x00008100, 0x21040000, 0x13042a01, 0x00b20000,
0x00000000, 0x82000200, 0x00000000, 0x00012104, 0x000000b2, 0x02610000, 0x00012d52, 0x02042c00,
0x00001402, 0x00000087, 0x02610000, 0x00008100, 0x21050000, 0x14042a01, 0x00b20000, 0x00000000,
0x82000200, 0x00000000, 0x00012105, 0x000000b2, 0x02610000, 0x00013052, 0x10042a00, 0x00880000,
0x00000000, 0x83000200, 0x00000000, 0x00012101, 0x00000083, 0x01210000, 0x00013152, 0x11042a00,
0x00880000, 0x00000000, 0x83000200, 0x00000000, 0x00012102, 0x00000088, 0x02610000, 0x00013252,
0x12042a00, 0x00880000, 0x00000000, 0x83000200, 0x00000000, 0x00012103, 0x00000088, 0x02610000,
0x00013352, 0x13042a00, 0x00880000, 0x00000000, 0x83000200, 0x00000000, 0x00012104, 0x00000088,
0x02610000, 0x00013452, 0x14042a00, 0x00880000, 0x00000000, 0x83000200, 0x00000000, 0x00012105,
0x00000088, 0x02610000, 0x00013652, 0x00040c00, 0x00b20000, 0x00000000, 0x87000200, 0x00000000,
0x00026100, 0x000000b2, 0x02610000, 0x00008800, 0x61000000, 0x01385202, 0x041b0000, 0x89000000,
0x00000000, 0x00020000, 0x00000087, 0x02610000, 0x00000410, 0x0000b200, 0x00000000, 0x00b20002,
0x00000000, 0x89000261, 0x00000000, 0x52026100, 0x00000139, 0x0200042c, 0x87000015, 0x00000000,
0x05026100, 0x00000007, 0x15042a00, 0x00b20000, 0x00000000, 0x07050200, 0x00000000, 0x0000b200,
0x61000000, 0x013a5202, 0x04100000, 0x9f000000, 0x00000000, 0x00020000, 0x0000009f, 0x02610000,
0x0000b200, 0x61000000, 0x00044502, 0x00009f00, 0x00000000, 0x009f0002, 0x00000000, 0x07050261,
0x3f800000, 0x00013b52, 0x00041000, 0x00a00000, 0x00000000, 0xb2000200, 0x00000000, 0x00026100,
0x000000a0, 0x02610000, 0x00000445, 0x000000a0, 0x02000000, 0x0000a000, 0x61000000, 0x00070502,
0x523f8000, 0x0000013c, 0x00000410, 0x0000b200, 0x00000000, 0x00b20002, 0x00000000, 0x61000261,
0x00000000, 0x45026100, 0xb2000004, 0x00000000, 0x00020000, 0x000000b2, 0x02610000, 0x00000705,
0x27523f80, 0x10000001, 0x00000004, 0x0000008a, 0x02000000, 0x0000c500, 0x21070600, 0x00a20001,
0x00000000, 0x040c0261, 0x8a000000, 0x00000000, 0x00020000, 0x000000c5, 0x01210606, 0x0000a100,
0x61000000, 0x008a0002, 0x00000000, 0x040c0261, 0x8a000000, 0x00000000, 0x00020000, 0x000000c5,
0x01210607, 0x00006300, 0x61000000, 0x008a0002, 0x00000000, 0x29520261, 0x2c000001, 0x16020204,
0x008a0000, 0x00000000, 0x81000261, 0x00000000, 0x2a012101, 0x00001604, 0x000000b5, 0x02000000,
0x00008200, 0x21010000, 0x00820001, 0x00000000, 0x2a520121, 0x2c000001, 0x17020204, 0x008a0000,
0x00000000, 0x81000261, 0x00000000, 0x2a012102, 0x00001704, 0x000000b5, 0x02000000, 0x00008200,
0x21020000, 0x00b50001, 0x00000000, 0x2b520261, 0x2c000001, 0x18020204, 0x008a0000, 0x00000000,
0x81000261, 0x00000000, 0x2a012103, 0x00001804, 0x000000b5, 0x02000000, 0x00008200, 0x21030000,
0x00b50001, 0x00000000, 0x2c520261, 0x2c000001, 0x19020204, 0x008a0000, 0x00000000, 0x81000261,
0x00000000, 0x2a012104, 0x00001904, 0x000000b5, 0x02000000, 0x00008200, 0x21040000, 0x00b50001,
0x00000000, 0x2d520261, 0x2c000001, 0x1a020204, 0x008a0000, 0x00000000, 0x81000261, 0x00000000,
0x2a012105, 0x00001a04, 0x000000b5, 0x02000000, 0x00008200, 0x21050000, 0x00b50001, 0x00000000,
0x30520261, 0x2a000001, 0x00001604, 0x0000008b, 0x02000000, 0x00008300, 0x21010000, 0x00830001,
0x00000000, 0x31520121, 0x2a000001, 0x00001704, 0x0000008b, 0x02000000, 0x00008300, 0x21020000,
0x008b0001, 0x00000000, 0x32520261, 0x2a000001, 0x00001804, 0x0000008b, 0x02000000, 0x00008300,
0x21030000, 0x008b0001, 0x00000000, 0x33520261, 0x2a000001, 0x00001904, 0x0000008b, 0x02000000,
0x00008300, 0x21040000, 0x008b0001, 0x00000000, 0x34520261, 0x2a000001, 0x00001a04, 0x0000008b,
0x02000000, 0x00008300, 0x21050000, 0x008b0001, 0x00000000, 0x36520261, 0x0c000001, 0x00000004,
0x000000b5, 0x02000000, 0x00008a00, 0x61000000, 0x00b50002, 0x00000000, 0x8b000261, 0x00000000,
0x52026100, 0x00000138, 0x0000041b, 0x00008c00, 0x00000000, 0x008a0002, 0x00000000, 0x04100261,
0xb5000000, 0x00000000, 0x00020000, 0x000000b5, 0x02610000, 0x00008c00, 0x61000000, 0x01395202,
0x042c0000, 0x001b0200, 0x00008a00, 0x61000000, 0x00070502, 0x2a000000, 0x00001b04, 0x000000b5,
0x02000000, 0x00000705, 0xb5000000, 0x00000000, 0x52026100, 0x0000013a, 0x00000410, 0x0000a100,
0x00000000, 0x00a10002, 0x00000000, 0xb5000261, 0x00000000, 0x45026100, 0xa1000004, 0x00000000,
0x00020000, 0x000000a1, 0x02610000, 0x00000705, 0x3b523f80, 0x10000001, 0x00000004, 0x000000a2,
0x02000000, 0x0000b500, 0x61000000, 0x00a20002, 0x00000000, 0x04450261, 0x00a20000, 0x00000000,
0xa2000200, 0x00000000, 0x05026100, 0x80000007, 0x013c523f, 0x04100000, 0xb5000000, 0x00000000,
0x00020000, 0x000000b5, 0x02610000, 0x00006300, 0x61000000, 0x00044502, 0x0000b500, 0x00000000,
0x00b50002, 0x00000000, 0x07050261, 0x3f800000, 0x00012752, 0x00041000, 0x008d0000, 0x00000000,
0xc5000200, 0x06000000, 0x00012107, 0x000000a4, 0x02610000, 0x0000040c, 0x00008d00, 0x00000000,
0x00c50002, 0x06060000, 0xa3000121, 0x00000000, 0x00026100, 0x0000008d, 0x02610000, 0x0000040c,
0x00008d00, 0x00000000, 0x00c50002, 0x06070000, 0x65000121, 0x00000000, 0x00026100, 0x0000008d,
0x02610000, 0x00012952, 0x02042c00, 0x00001c02, 0x0000008d, 0x02610000, 0x00008100, 0x21010000,
0x1c042a01, 0x00b80000, 0x00000000, 0x82000200, 0x00000000, 0x00012101, 0x00000082, 0x01210000,
0x00012a52, 0x02042c00, 0x00001d02, 0x0000008d, 0x02610000, 0x00008100, 0x21020000, 0x1d042a01,
0x00b80000, 0x00000000, 0x82000200, 0x00000000, 0x00012102, 0x000000b8, 0x02610000, 0x00012b52,
0x02042c00, 0x00001e02, 0x0000008d, 0x02610000, 0x00008100, 0x21030000, 0x1e042a01, 0x00b80000,
0x00000000, 0x82000200, 0x00000000, 0x00012103, 0x000000b8, 0x02610000, 0x00012c52, 0x02042c00,
0x00001f02, 0x0000008d, 0x02610000, 0x00008100, 0x21040000, 0x1f042a01, 0x00b80000, 0x00000000,
0x82000200, 0x00000000, 0x00012104, 0x000000b8, 0x02610000, 0x00012d52, 0x02042c00, 0x00002002,
0x0000008d, 0x02610000, 0x00008100, 0x21050000, 0x20042a01, 0x00b80000, 0x00000000, 0x82000200,
0x00000000, 0x00012105, 0x000000b8, 0x02610000, 0x00013052, 0x1c042a00, 0x008e0000, 0x00000000,
0x83000200, 0x00000000, 0x00012101, 0x00000083, 0x01210000, 0x00013152, 0x1d042a00, 0x008e0000,
0x00000000, 0x83000200, 0x00000000, 0x00012102, 0x0000008e, 0x02610000, 0x00013252, 0x1e042a00,
0x008e0000, 0x00000000, 0x83000200, 0x00000000, 0x00012103, 0x0000008e, 0x02610000, 0x00013352,
0x1f042a00, 0x008e0000, 0x00000000, 0x83000200, 0x00000000, 0x00012104, 0x0000008e, 0x02610000,
0x00013452, 0x20042a00, 0x008e0000, 0x00000000, 0x83000200, 0x00000000, 0x00012105, 0x0000008e,
0x02610000, 0x00013652, 0x00040c00, 0x00b80000, 0x00000000, 0x8d000200, 0x00000000, 0x00026100,
0x000000b8, 0x02610000, 0x00008e00, 0x61000000, 0x01385202, 0x041b0000, 0x8f000000, 0x00000000,
0x00020000, 0x0000008d, 0x02610000, 0x00000410, 0x0000b800, 0x00000000, 0x00b80002, 0x00000000,
0x8f000261, 0x00000000, 0x52026100, 0x00000139, 0x0200042c, 0x8d000021, 0x00000000, 0x05026100,
0x00000007, 0x21042a00, 0x00b80000, 0x00000000, 0x07050200, 0x00000000, 0x0000b800, 0x61000000,
0x013a5202, 0x04100000, 0xa3000000, 0x00000000, 0x00020000, 0x000000a3, 0x02610000, 0x0000b800,
0x61000000, 0x00044502, 0x0000a300, 0x00000000, 0x00a30002, 0x00000000, 0x07050261, 0x3f800000,
0x00013b52, 0x00041000, 0x00a40000, 0x00000000, 0xb8000200, 0x00000000, 0x00026100, 0x000000a4,
0x02610000, 0x00000445, 0x000000a4, 0x02000000, 0x0000a400, 0x61000000, 0x00070502, 0x523f8000,
0x0000013c, 0x00000410, 0x0000b800, 0x00000000, 0x00b80002, 0x00000000, 0x65000261, 0x00000000,
0x45026100, 0xb8000004, 0x00000000, 0x00020000, 0x000000b8, 0x02610000, 0x00000705, 0x27523f80,
0x10000001, 0x00000004, 0x00000090, 0x02000000, 0x0000c500, 0x21070600, 0x00a60001, 0x00000000,
0x040c0261, 0x90000000, 0x00000000, 0x00020000, 0x000000c5, 0x01210606, 0x0000a500, 0x61000000,
0x00900002, 0x00000000, 0x040c0261, 0x90000000, 0x00000000, 0x00020000, 0x000000c5, 0x01210607,
0x00006f00, 0x61000000, 0x00900002, 0x00000000, 0x29520261, 0x2c000001, 0x22020204, 0x00900000,
0x00000000, 0x81000261, 0x00000000, 0x2a012101, 0x00002204, 0x000000bb, 0x02000000, 0x00008200,
0x21010000, 0x00820001, 0x00000000, 0x2a520121, 0x2c000001, 0x23020204, 0x00900000, 0x00000000,
0x81000261, 0x00000000, 0x2a012102, 0x00002304, 0x000000bb, 0x02000000, 0x00008200, 0x21020000,
0x00bb0001, 0x00000000, 0x2b520261, 0x2c000001, 0x24020204, 0x00900000, 0x00000000, 0x81000261,
0x00000000, 0x2a012103, 0x00002404, 0x000000bb, 0x02000000, 0x00008200, 0x21030000, 0x00bb0001,
0x00000000, 0x2c520261, 0x2c000001, 0x25020204, 0x00900000, 0x00000000, 0x81000261, 0x00000000,
0x2a012104, 0x00002504, 0x000000bb, 0x02000000, 0x00008200, 0x21040000, 0x00bb0001, 0x00000000,
0x2d520261, 0x2c000001, 0x26020204, 0x00900000, 0x00000000, 0x81000261, 0x00000000, 0x2a012105,
0x00002604, 0x000000bb, 0x02000000, 0x00008200, 0x21050000, 0x00bb0001, 0x00000000, 0x30520261,
0x2a000001, 0x00002204, 0x00000091, 0x02000000, 0x00008300, 0x21010000, 0x00830001, 0x00000000,
0x31520121, 0x2a000001, 0x00002304, 0x00000091, 0x02000000, 0x00008300, 0x21020000, 0x00910001,
0x00000000, 0x32520261, 0x2a000001, 0x00002404, 0x00000091, 0x02000000, 0x00008300, 0x21030000,
0x00910001, 0x00000000, 0x33520261, 0x2a000001, 0x00002504, 0x00000091, 0x02000000, 0x00008300,
0x21040000, 0x00910001, 0x00000000, 0x34520261, 0x2a000001, 0x00002604, 0x00000091, 0x02000000,
0x00008300, 0x21050000, 0x00910001, 0x00000000, 0x36520261, 0x0c000001, 0x00000004, 0x000000bb,
0x02000000, 0x00009000, 0x61000000, 0x00bb0002, 0x00000000, 0x91000261, 0x00000000, 0x52026100,
0x00000138, 0x0000041b, 0x00009200, 0x00000000, 0x00900002, 0x00000000, 0x04100261, 0xbb000000,
0x00000000, 0x00020000, 0x000000bb, 0x02610000, 0x00009200, 0x61000000, 0x01395202, 0x042c0000,
0x00270200, 0x00009000, 0x61000000, 0x00070502, 0x2a000000, 0x00002704, 0x000000bb, 0x02000000,
0x00000705, 0xbb000000, 0x00000000, 0x52026100, 0x0000013a, 0x00000410, 0x0000a500, 0x00000000,
0x00a50002, 0x00000000, 0xbb000261, 0x00000000, 0x45026100, 0xa5000004, 0x00000000, 0x00020000,
0x000000a5, 0x02610000, 0x00000705, 0x3b523f80, 0x10000001, 0x00000004, 0x000000a6, 0x02000000,
0x0000bb00, 0x61000000, 0x00a60002, 0x00000000, 0x04450261, 0x00a60000, 0x00000000, 0xa6000200,
0x00000000, 0x05026100, 0x80000007, 0x013c523f, 0x04100000, 0xbb000000, 0x00000000, 0x00020000,
0x000000bb, 0x02610000, 0x00006f00, 0x61000000, 0x00044502, 0x0000bb00, 0x00000000, 0x00bb0002,
0x00000000, 0x07050261, 0x3f800000, 0x00012752, 0x00041000, 0x00930000, 0x00000000, 0xc5000200,
0x06000000, 0x00012107, 0x000000a8, 0x02610000, 0x0000040c, 0x00009300, 0x00000000, 0x00c50002,
0x06060000, 0xa7000121, 0x00000000, 0x00026100, 0x00000093, 0x02610000, 0x0000040c, 0x00009300,
0x00000000, 0x00c50002, 0x06070000, 0x71000121, 0x00000000, 0x00026100, 0x00000093, 0x02610000,
0x00012952, 0x02042c00, 0x00002802, 0x00000093, 0x02610000, 0x00008100, 0x21010000, 0x28042a01,
0x00be0000, 0x00000000, 0x82000200, 0x00000000, 0x00012101, 0x00000082, 0x01210000, 0x00012a52,
0x02042c00, 0x00002902, 0x00000093, 0x02610000, 0x00008100, 0x21020000, 0x29042a01, 0x00be0000,
0x00000000, 0x82000200, 0x00000000, 0x00012102, 0x000000be, 0x02610000, 0x00012b52, 0x02042c00,
0x00002a02, 0x00000093, 0x02610000, 0x00008100, 0x21030000, 0x2a042a01, 0x00be0000, 0x00000000,
0x82000200, 0x00000000, 0x00012103, 0x000000be, 0x02610000, 0x00012c52, 0x02042c00, 0x00002b02,
0x00000093, 0x02610000, 0x00008100, 0x21040000, 0x2b042a01, 0x00be0000, 0x00000000, 0x82000200,
0x00000000, 0x00012104, 0x000000be, 0x02610000, 0x00012d52, 0x02042c00, 0x00002c02, 0x00000093,
0x02610000, 0x00008100, 0x21050000, 0x2c042a01, 0x00be0000, 0x00000000, 0x82000200, 0x00000000,
0x00012105, 0x000000be, 0x02610000, 0x00013052, 0x28042a00, 0x00940000, 0x00000000, 0x83000200,
0x00000000, 0x00012101, 0x00000083, 0x01210000, 0x00013152, 0x29042a00, 0x00940000, 0x00000000,
0x83000200, 0x00000000, 0x00012102, 0x00000094, 0x02610000, 0x00013252, 0x2a042a00, 0x00940000,
0x00000000, 0x83000200, 0x00000000, 0x00012103, 0x00000094, 0x02610000, 0x00013352, 0x2b042a00,
0x00940000, 0x00000000, 0x83000200, 0x00000000, 0x00012104, 0x00000094, 0x02610000, 0x00013452,
0x2c042a00, 0x00940000, 0x00000000, 0x83000200, 0x00000000, 0x00012105, 0x00000094, 0x02610000,
0x00013652, 0x00040c00, 0x00be0000, 0x00000000, 0x93000200, 0x00000000, 0x00026100, 0x000000be,
0x02610000, 0x00009400, 0x61000000, 0x01385202, 0x041b0000, 0x95000000, 0x00000000, 0x00020000,
0x00000093, 0x02610000, 0x00000410, 0x0000be00, 0x00000000, 0x00be0002, 0x00000000, 0x95000261,
0x00000000, 0x52026100, 0x00000139, 0x0200042c, 0x9300002d, 0x00000000, 0x05026100, 0x00000007,
0x2d042a00, 0x00be0000, 0x00000000, 0x07050200, 0x00000000, 0x0000be00, 0x61000000, 0x013a5202,
0x04100000, 0xa7000000, 0x00000000, 0x00020000, 0x000000a7, 0x02610000, 0x0000be00, 0x61000000,
0x00044502, 0x0000a700, 0x00000000, 0x00a70002, 0x00000000, 0x07050261, 0x3f800000, 0x00013b52,
0x00041000, 0x00a80000, 0x00000000, 0xbe000200, 0x00000000, 0x00026100, 0x000000a8, 0x02610000,
0x00000445, 0x000000a8, 0x02000000, 0x0000a800, 0x61000000, 0x00070502, 0x523f8000, 0x0000013c,
0x00000410, 0x0000be00, 0x00000000, 0x00be0002, 0x00000000, 0x71000261, 0x00000000, 0x45026100,
0xbe000004, 0x00000000, 0x00020000, 0x000000be, 0x02610000, 0x00000705, 0x27523f80, 0x10000001,
0x00000004, 0x00000096, 0x02000000, 0x0000c500, 0x21070600, 0x00aa0001, 0x00000000, 0x040c0261,
0x96000000, 0x00000000, 0x00020000, 0x000000c5, 0x01210606, 0x0000a900, 0x61000000, 0x00960002,
0x00000000, 0x040c0261, 0x96000000, 0x00000000, 0x00020000, 0x000000c5, 0x01210607, 0x00007300,
0x61000000, 0x00960002, 0x00000000, 0x29520261, 0x2c000001, 0x2e020204, 0x00960000, 0x00000000,
0x81000261, 0x00000000, 0x2a012101, 0x00002e04, 0x000000c1, 0x02000000, 0x00008200, 0x21010000,
0x00820001, 0x00000000, 0x2a520121, 0x2c000001, 0x2f020204, 0x00960000, 0x00000000, 0x81000261,
0x00000000, 0x2a012102, 0x00002f04, 0x000000c1, 0x02000000, 0x00008200, 0x21020000, 0x00c10001,
0x00000000, 0x2b520261, 0x2c000001, 0x30020204, 0x00960000, 0x00000000, 0x81000261, 0x00000000,
0x2a012103, 0x00003004, 0x000000c1, 0x02000000, 0x00008200, 0x21030000, 0x00c10001, 0x00000000,
0x2c520261, 0x2c000001, 0x31020204, 0x00960000, 0x00000000, 0x81000261, 0x00000000, 0x2a012104,
0x00003104, 0x000000c1, 0x02000000, 0x00008200, 0x21040000, 0x00c10001, 0x00000000, 0x2d520261,
0x2c000001, 0x32020204, 0x00960000, 0x00000000, 0x81000261, 0x00000000, 0x2a012105, 0x00003204,
0x000000c1, 0x02000000, 0x00008200, 0x21050000, 0x00c10001, 0x00000000, 0x30520261, 0x2a000001,
0x00002e04, 0x00000097, 0x02000000, 0x00008300, 0x21010000, 0x00830001, 0x00000000, 0x31520121,
0x2a000001, 0x00002f04, 0x00000097, 0x02000000, 0x00008300, 0x21020000, 0x00970001, 0x00000000,
0x32520261, 0x2a000001, 0x00003004, 0x00000097, 0x02000000, 0x00008300, 0x21030000, 0x00970001,
0x00000000, 0x33520261, 0x2a000001, 0x00003104, 0x00000097, 0x02000000, 0x00008300, 0x21040000,
0x00970001, 0x00000000, 0x34520261, 0x2a000001, 0x00003204, 0x00000097, 0x02000000, 0x00008300,
0x21050000, 0x00970001, 0x00000000, 0x36520261, 0x0c000001, 0x00000004, 0x000000c1, 0x02000000,
0x00009600, 0x61000000, 0x00c10002, 0x00000000, 0x97000261, 0x00000000, 0x52026100, 0x00000138,
0x0000041b, 0x00009800, 0x00000000, 0x00960002, 0x00000000, 0x04100261, 0xc1000000, 0x00000000,
0x00020000, 0x000000c1, 0x02610000, 0x00009800, 0x61000000, 0x01395202, 0x042c0000, 0x00330200,
0x00009600, 0x61000000, 0x00070502, 0x2a000000, 0x00003304, 0x000000c1, 0x02000000, 0x00000705,
0xc1000000, 0x00000000, 0x52026100, 0x0000013a, 0x00000410, 0x0000a900, 0x00000000, 0x00a90002,
0x00000000, 0xc1000261, 0x00000000, 0x45026100, 0xa9000004, 0x00000000, 0x00020000, 0x000000a9,
0x02610000, 0x00000705, 0x3b523f80, 0x10000001, 0x00000004, 0x000000aa, 0x02000000, 0x0000c100,
0x61000000, 0x00aa0002, 0x00000000, 0x04450261, 0x00aa0000, 0x00000000, 0xaa000200, 0x00000000,
0x05026100, 0x80000007, 0x013c523f, 0x04100000, 0xc1000000, 0x00000000, 0x00020000, 0x000000c1,
0x02610000, 0x00007300, 0x61000000, 0x00044502, 0x0000c100, 0x00000000, 0x00c10002, 0x00000000,
0x07050261, 0x3f800000, 0x00012752, 0x00041000, 0x00990000, 0x00000000, 0xc5000200, 0x06000000,
0x00012107, 0x000000ac, 0x02610000, 0x0000040c, 0x00009900, 0x00000000, 0x00c50002, 0x06060000,
0xab000121, 0x00000000, 0x00026100, 0x00000099, 0x02610000, 0x0000040c, 0x00009900, 0x00000000,
0x00c50002, 0x06070000, 0x75000121, 0x00000000, 0x00026100, 0x00000099, 0x02610000, 0x00012952,
0x02042c00, 0x00003402, 0x00000099, 0x02610000, 0x00008100, 0x21010000, 0x34042a01, 0x009b0000,
0x00000000, 0x82000200, 0x00000000, 0x00012101, 0x00000082, 0x01210000, 0x00012a52, 0x02042c00,
0x00003502, 0x00000099, 0x02610000, 0x00008100, 0x21020000, 0x35042a01, 0x009b0000, 0x00000000,
0x82000200, 0x00000000, 0x00012102, 0x0000009b, 0x02610000, 0x00012b52, 0x02042c00, 0x00003602,
0x00000099, 0x02610000, 0x00008100, 0x21030000, 0x36042a01, 0x009b0000, 0x00000000, 0x82000200,
0x00000000, 0x00012103, 0x0000009b, 0x02610000, 0x00012c52, 0x02042c00, 0x00003702, 0x00000099,
0x02610000, 0x00008100, 0x21040000, 0x37042a01, 0x009b0000, 0x00000000, 0x82000200, 0x00000000,
0x00012104, 0x0000009b, 0x02610000, 0x00012d52, 0x02042c00, 0x00003802, 0x00000099, 0x02610000,
0x00008100, 0x21050000, 0x38042a01, 0x009b0000, 0x00000000, 0x82000200, 0x00000000, 0x00012105,
0x0000009b, 0x02610000, 0x00013052, 0x34042a00, 0x009c0000, 0x00000000, 0x83000200, 0x00000000,
0x00012101, 0x00000083, 0x01210000, 0x00013152, 0x35042a00, 0x009c0000, 0x00000000, 0x83000200,
0x00000000, 0x00012102, 0x0000009c, 0x02610000, 0x00013252, 0x36042a00, 0x009c0000, 0x00000000,
0x83000200, 0x00000000, 0x00012103, 0x0000009c, 0x02610000, 0x00013352, 0x37042a00, 0x009c0000,
0x00000000, 0x83000200, 0x00000000, 0x00012104, 0x0000009c, 0x02610000, 0x00013452, 0x38042a00,
0x009c0000, 0x00000000, 0x83000200, 0x00000000, 0x00012105, 0x0000009c, 0x02610000, 0x00013652,
0x00040c00, 0x00c40000, 0x00000000, 0x99000200, 0x00000000, 0x00026100, 0x0000009b, 0x02610000,
0x00009c00, 0x61000000, 0x01385202, 0x041b0000, 0x9a000000, 0x00000000, 0x00020000, 0x00000099,
0x02610000, 0x00000410, 0x0000c400, 0x00000000, 0x00c40002, 0x00000000, 0x9a000261, 0x00000000,
0x52026100, 0x00000139, 0x0200042c, 0x99000039, 0x00000000, 0x05026100, 0x00000007, 0x39042a00,
0x00c40000, 0x00000000, 0x07050200, 0x00000000, 0x0000c400, 0x61000000, 0x013a5202, 0x04100000,
0xab000000, 0x00000000, 0x00020000, 0x000000ab, 0x02610000, 0x0000c400, 0x61000000, 0x00044502,
0x0000ab00, 0x00000000, 0x00ab0002, 0x00000000, 0x07050261, 0x3f800000, 0x00013b52, 0x00041000,
0x00ac0000, 0x00000000, 0xc4000200, 0x00000000, 0x00026100, 0x000000ac, 0x02610000, 0x00000445,
0x000000ac, 0x02000000, 0x0000ac00, 0x61000000, 0x00070502, 0x523f8000, 0x0000013c, 0x00000410,
0x0000c400, 0x00000000, 0x00c40002, 0x00000000, 0x75000261, 0x00000000, 0x45026100, 0xc4000004,
0x00000000, 0x00020000, 0x000000c4, 0x02610000, 0x00000705, 0x08313f80, 0x01495200, 0x040c0000,
0xad000000, 0x00000000, 0x00020000, 0x000000c5, 0x01210002, 0x00009d00, 0x61000000, 0x00c50002,
0x03020000, 0x040c0121, 0xad000000, 0x00000000, 0x00020000, 0x000000c5, 0x01210102, 0x00009e00,
0x61000000, 0x00ad0002, 0x00000000, 0x040c0261, 0xad000000, 0x00000000, 0x00020000, 0x000000c5,
0x01210202, 0x0000af00, 0x61000000, 0x00ad0002, 0x00000000, 0x4c520261, 0x0c000001, 0x00000004,
0x000000ae, 0x02000000, 0x00009d00, 0x61000000, 0x00c50002, 0x04020000, 0xc5000121, 0x03000000,
0x0c012101, 0x00000004, 0x000000ae, 0x02000000, 0x00009e00, 0x61000000, 0x00c50002, 0x05020000,
0xae000121, 0x00000000, 0x0c026100, 0x00000004, 0x000000ae, 0x02000000, 0x0000af00, 0x61000000,
0x00c50002, 0x00030000, 0xae000121, 0x00000000, 0x52026100, 0x0000014f, 0x0000040c, 0x00009d00,
0x00000000, 0x009d0002, 0x00000000, 0xc5000261, 0x03000000, 0x00012102, 0x000000c5, 0x01210503,
0x0000040c, 0x00009e00, 0x00000000, 0x009e0002, 0x00000000, 0xc5000261, 0x03000000, 0x00012103,
0x0000009d, 0x02610000, 0x0000040c, 0x0000af00, 0x00000000, 0x00af0002, 0x00000000, 0xc5000261,
0x03000000, 0x00012104, 0x0000009e, 0x02610000, 0x00014952, 0x00040c00, 0x00b00000, 0x00000000,
0xc5000200, 0x02000000, 0x00012100, 0x0000009f, 0x02610000, 0x0000c500, 0x21030200, 0x00040c01,
0x00b00000, 0x00000000, 0xc5000200, 0x02000000, 0x00012101, 0x000000a0, 0x02610000, 0x0000b000,
0x61000000, 0x00040c02, 0x00b00000, 0x00000000, 0xc5000200, 0x02000000, 0x00012102, 0x000000b2,
0x02610000, 0x0000b000, 0x61000000, 0x014c5202, 0x040c0000, 0xb1000000, 0x00000000, 0x00020000,
0x0000009f, 0x02610000, 0x0000c500, 0x21040200, 0x00c50001, 0x01030000, 0x040c0121, 0xb1000000,
0x00000000, 0x00020000, 0x000000a0, 0x02610000, 0x0000c500, 0x21050200, 0x00b10001, 0x00000000,
0x040c0261, 0xb1000000, 0x00000000, 0x00020000, 0x000000b2, 0x02610000, 0x0000c500, 0x21000300,
0x00b10001, 0x00000000, 0x4f520261, 0x0c000001, 0x00000004, 0x0000009f, 0x02000000, 0x00009f00,
0x61000000, 0x00c50002, 0x02030000, 0xc5000121, 0x03000000, 0x0c012105, 0x00000004, 0x000000a0,
0x02000000, 0x0000a000, 0x61000000, 0x00c50002, 0x03030000, 0x9f000121, 0x00000000, 0x0c026100,
0x00000004, 0x000000b2, 0x02000000, 0x0000b200, 0x61000000, 0x00c50002, 0x04030000, 0xa0000121,
0x00000000, 0x52026100, 0x00000149, 0x0000040c, 0x0000b300, 0x00000000, 0x00c50002, 0x00020000,
0xa1000121, 0x00000000, 0x00026100, 0x000000c5, 0x01210302, 0x0000040c, 0x0000b300, 0x00000000,
0x00c50002, 0x01020000, 0xa2000121, 0x00000000, 0x00026100, 0x000000b3, 0x02610000, 0x0000040c,
0x0000b300, 0x00000000, 0x00c50002, 0x02020000, 0xb5000121, 0x00000000, 0x00026100, 0x000000b3,
0x02610000, 0x00014c52, 0x00040c00, 0x00b40000, 0x00000000, 0xa1000200, 0x00000000, 0x00026100,
0x000000c5, 0x01210402, 0x0000c500, 0x21010300, 0x00040c01, 0x00b40000, 0x00000000, 0xa2000200,
0x00000000, 0x00026100, 0x000000c5, 0x01210502, 0x0000b400, 0x61000000, 0x00040c02, 0x00b40000,
0x00000000, 0xb5000200, 0x00000000, 0x00026100, 0x000000c5, 0x01210003, 0x0000b400, 0x61000000,
0x014f5202, 0x040c0000, 0xa1000000, 0x00000000, 0x00020000, 0x000000a1, 0x02610000, 0x0000c500,
0x21020300, 0x00c50001, 0x05030000, 0x040c0121, 0xa2000000, 0x00000000, 0x00020000, 0x000000a2,
0x02610000, 0x0000c500, 0x21030300, 0x00a10001, 0x00000000, 0x040c0261, 0xb5000000, 0x00000000,
0x00020000, 0x000000b5, 0x02610000, 0x0000c500, 0x21040300, 0x00a20001, 0x00000000, 0x49520261,
0x0c000001, 0x00000004, 0x000000b6, 0x02000000, 0x0000c500, 0x21000200, 0x00a30001, 0x00000000,
0xc5000261, 0x02000000, 0x0c012103, 0x00000004, 0x000000b6, 0x02000000, 0x0000c500, 0x21010200,
0x00a40001, 0x00000000, 0xb6000261, 0x00000000, 0x0c026100, 0x00000004, 0x000000b6, 0x02000000,
0x0000c500, 0x21020200, 0x00b80001, 0x00000000, 0xb6000261, 0x00000000, 0x52026100, 0x0000014c,
0x0000040c, 0x0000b700, 0x00000000, 0x00a30002, 0x00000000, 0xc5000261, 0x02000000, 0x00012104,
0x000000c5, 0x01210103, 0x0000040c, 0x0000b700, 0x00000000, 0x00a40002, 0x00000000, 0xc5000261,
0x02000000, 0x00012105, 0x000000b7, 0x02610000, 0x0000040c, 0x0000b700, 0x00000000, 0x00b80002,
0x00000000, 0xc5000261, 0x03000000, 0x00012100, 0x000000b7, 0x02610000, 0x00014f52, 0x00040c00,
0x00a30000, 0x00000000, 0xa3000200, 0x00000000, 0x00026100, 0x000000c5, 0x01210203, 0x0000c500,
0x21050300, 0x00040c01, 0x00a40000, 0x00000000, 0xa4000200, 0x00000000, 0x00026100, 0x000000c5,
0x01210303, 0x0000a300, 0x61000000, 0x00040c02, 0x00b80000, 0x00000000, 0xb8000200, 0x00000000,
0x00026100, 0x000000c5, 0x01210403, 0x0000a400, 0x61000000, 0x01495202, 0x040c0000, 0xb9000000,
0x00000000, 0x00020000, 0x000000c5, 0x01210002, 0x0000a500, 0x61000000, 0x00c50002, 0x03020000,
0x040c0121, 0xb9000000, 0x00000000, 0x00020000, 0x000000c5, 0x01210102, 0x0000a600, 0x61000000,
0x00b90002, 0x00000000, 0x040c0261, 0xb9000000, 0x00000000, 0x00020000, 0x000000c5, 0x01210202,
0x0000bb00, 0x61000000, 0x00b90002, 0x00000000, 0x4c520261, 0x0c000001, 0x00000004, 0x000000ba,
0x02000000, 0x0000a500, 0x61000000, 0x00c50002, 0x04020000, 0xc5000121, 0x03000000, 0x0c012101,
0x00000004, 0x000000ba, 0x02000000, 0x0000a600, 0x61000000, 0x00c50002, 0x05020000, 0xba000121,
0x00000000, 0x0c026100, 0x00000004, 0x000000ba, 0x02000000, 0x0000bb00, 0x61000000, 0x00c50002,
0x00030000, 0xba000121, 0x00000000, 0x52026100, 0x0000014f, 0x0000040c, 0x0000a500, 0x00000000,
0x00a50002, 0x00000000, 0xc5000261, 0x03000000, 0x00012102, 0x000000c5, 0x01210503, 0x0000040c,
0x0000a600, 0x00000000, 0x00a60002, 0x00000000, 0xc5000261, 0x03000000, 0x00012103, 0x000000a5,
0x02610000, 0x0000040c, 0x0000bb00, 0x00000000, 0x00bb0002, 0x00000000, 0xc5000261, 0x03000000,
0x00012104, 0x000000a6, 0x02610000, 0x00014952, 0x00040c00, 0x00bc0000, 0x00000000, 0xc5000200,
0x02000000, 0x00012100, 0x000000a7, 0x02610000, 0x0000c500, 0x21030200, 0x00040c01, 0x00bc0000,
0x00000000, 0xc5000200, 0x02000000, 0x00012101, 0x000000a8, 0x02610000, 0x0000bc00, 0x61000000,
0x00040c02, 0x00bc0000, 0x00000000, 0xc5000200, 0x02000000, 0x00012102, 0x000000be, 0x02610000,
0x0000bc00, 0x61000000, 0x014c5202, 0x040c0000, 0xbd000000, 0x00000000, 0x00020000, 0x000000a7,
0x02610000, 0x0000c500, 0x21040200, 0x00c50001, 0x01030000, 0x040c0121, 0xbd000000, 0x00000000,
0x00020000, 0x000000a8, 0x02610000, 0x0000c500, 0x21050200, 0x00bd0001, 0x00000000, 0x040c0261,
0xbd000000, 0x00000000, 0x00020000, 0x000000be, 0x02610000, 0x0000c500, 0x21000300, 0x00bd0001,
0x00000000, 0x4f520261, 0x0c000001, 0x00000004, 0x000000a7, 0x02000000, 0x0000a700, 0x61000000,
0x00c50002, 0x02030000, 0xc5000121, 0x03000000, 0x0c012105, 0x00000004, 0x000000a8, 0x02000000,
0x0000a800, 0x61000000, 0x00c50002, 0x03030000, 0xa7000121, 0x00000000, 0x0c026100, 0x00000004,
0x000000be, 0x02000000, 0x0000be00, 0x61000000, 0x00c50002, 0x04030000, 0xa8000121, 0x00000000,
0x52026100, 0x00000149, 0x0000040c, 0x0000bf00, 0x00000000, 0x00c50002, 0x00020000, 0xa9000121,
0x00000000, 0x00026100, 0x000000c5, 0x01210302, 0x0000040c, 0x0000bf00, 0x00000000, 0x00c50002,
0x01020000, 0xaa000121, 0x00000000, 0x00026100, 0x000000bf, 0x02610000, 0x0000040c, 0x0000bf00,
0x00000000, 0x00c50002, 0x02020000, 0xc1000121, 0x00000000, 0x00026100, 0x000000bf, 0x02610000,
0x00014c52, 0x00040c00, 0x00c00000, 0x00000000, 0xa9000200, 0x00000000, 0x00026100, 0x000000c5,
0x01210402, 0x0000c500, 0x21010300, 0x00040c01, 0x00c00000, 0x00000000, 0xaa000200, 0x00000000,
0x00026100, 0x000000c5, 0x01210502, 0x0000c000, 0x61000000, 0x00040c02, 0x00c00000, 0x00000000,
0xc1000200, 0x00000000, 0x00026100, 0x000000c5, 0x01210003, 0x0000c000, 0x61000000, 0x014f5202,
0x040c0000, 0xa9000000, 0x00000000, 0x00020000, 0x000000a9, 0x02610000, 0x0000c500, 0x21020300,
0x00c50001, 0x05030000, 0x040c0121, 0xaa000000, 0x00000000, 0x00020000, 0x000000aa, 0x02610000,
0x0000c500, 0x21030300, 0x00a90001, 0x00000000, 0x040c0261, 0xc1000000, 0x00000000, 0x00020000,
0x000000c1, 0x02610000, 0x0000c500, 0x21040300, 0x00aa0001, 0x00000000, 0x49520261, 0x0c000001,
0x00000004, 0x000000c2, 0x02000000, 0x0000c500, 0x21000200, 0x00ab0001, 0x00000000, 0xc5000261,
0x02000000, 0x0c012103, 0x00000004, 0x000000c2, 0x02000000, 0x0000c500, 0x21010200, 0x00ac0001,
0x00000000, 0xc2000261, 0x00000000, 0x0c026100, 0x00000004, 0x000000c2, 0x02000000, 0x0000c500,
0x21020200, 0x00c40001, 0x00000000, 0xc2000261, 0x00000000, 0x52026100, 0x0000014c, 0x0000040c,
0x0000c300, 0x00000000, 0x00ab0002, 0x00000000, 0xc5000261, 0x02000000, 0x00012104, 0x000000c5,
0x01210103, 0x0000040c, 0x0000c300, 0x00000000, 0x00ac0002, 0x00000000, 0xc5000261, 0x02000000,
0x00012105, 0x000000c3, 0x02610000, 0x0000040c, 0x0000c300, 0x00000000, 0x00c40002, 0x00000000,
0xc5000261, 0x03000000, 0x00012100, 0x000000c3, 0x02610000, 0x00014f52, 0x00040c00, 0x00ab0000,
0x00000000, 0xab000200, 0x00000000, 0x00026100, 0x000000c5, 0x01210203, 0x0000c500, 0x21050300,
0x00040c01, 0x00ac0000, 0x00000000, 0xac000200, 0x00000000, 0x00026100, 0x000000c5, 0x01210303,
0x0000ab00, 0x61000000, 0x00040c02, 0x00c40000, 0x00000000, 0xc4000200, 0x00000000, 0x00026100,
0x000000c5, 0x01210403, 0x0000ac00, 0x61000000, 0x01605202, 0x04450000, 0x00ad0001, 0x00000000,
0xad000200, 0x00000000, 0x05026100, 0x00000007, 0x01615200, 0x04450000, 0x00ad0000, 0x00000000,
0xad000200, 0x00000000, 0x05026100, 0x80000007, 0x0162523f, 0x04450000, 0x00ae0001, 0x00000000,
0xae000200, 0x00000000, 0x05026100, 0x00000007, 0x01635200, 0x04450000, 0x00ae0000, 0x00000000,
0xae000200, 0x00000000, 0x05026100, 0x80000007, 0x0164523f, 0x04450000, 0x00af0001, 0x00000000,
0xaf000200, 0x00000000, 0x05026100, 0x00000007, 0x01655200, 0x04450000, 0x00af0000, 0x00000000,
0xaf000200, 0x00000000, 0x05026100, 0x80000007, 0x0160523f, 0x04450000, 0x00b00001, 0x00000000,
0xb0000200, 0x00000000, 0x05026100, 0x00000007, 0x01615200, 0x04450000, 0x00b00000, 0x00000000,
0xb0000200, 0x00000000, 0x05026100, 0x80000007, 0x0162523f, 0x04450000, 0x00b10001, 0x00000000,
0xb1000200, 0x00000000, 0x05026100, 0x00000007, 0x01635200, 0x04450000, 0x00b10000, 0x00000000,
0xb1000200, 0x00000000, 0x05026100, 0x80000007, 0x0164523f, 0x04450000, 0x00b20001, 0x00000000,
0xb2000200, 0x00000000, 0x05026100, 0x00000007, 0x01655200, 0x04450000, 0x00b20000, 0x00000000,
0xb2000200, 0x00000000, 0x05026100, 0x80000007, 0x0160523f, 0x04450000, 0x00b30001, 0x00000000,
0xb3000200, 0x00000000, 0x05026100, 0x00000007, 0x01615200, 0x04450000, 0x00b30000, 0x00000000,
0xb3000200, 0x00000000, 0x05026100, 0x80000007, 0x0162523f, 0x04450000, 0x00b40001, 0x00000000,
0xb4000200, 0x00000000, 0x05026100, 0x00000007, 0x01635200, 0x04450000, 0x00b40000, 0x00000000,
0xb4000200, 0x00000000, 0x05026100, 0x80000007, 0x0164523f, 0x04450000, 0x00b50001, 0x00000000,
0xb5000200, 0x00000000, 0x05026100, 0x00000007, 0x01655200, 0x04450000, 0x00b50000, 0x00000000,
0xb5000200, 0x00000000, 0x05026100, 0x80000007, 0x0160523f, 0x04450000, 0x00b60001, 0x00000000,
0xb6000200, 0x00000000, 0x05026100, 0x00000007, 0x01615200, 0x04450000, 0x00b60000, 0x00000000,
0xb6000200, 0x00000000, 0x05026100, 0x80000007, 0x0162523f, 0x04450000, 0x00b70001, 0x00000000,
0xb7000200, 0x00000000, 0x05026100, 0x00000007, 0x01635200, 0x04450000, 0x00b70000, 0x00000000,
0xb7000200, 0x00000000, 0x05026100, 0x80000007, 0x0164523f, 0x04450000, 0x00b80001, 0x00000000,
0xb8000200, 0x00000000, 0x05026100, 0x00000007, 0x01655200, 0x04450000, 0x00b80000, 0x00000000,
0xb8000200, 0x00000000, 0x05026100, 0x80000007, 0x0160523f, 0x04450000, 0x00b90001, 0x00000000,
0xb9000200, 0x00000000, 0x05026100, 0x00000007, 0x01615200, 0x04450000, 0x00b90000, 0x00000000,
0xb9000200, 0x00000000, 0x05026100, 0x80000007, 0x0162523f, 0x04450000, 0x00ba0001, 0x00000000,
0xba000200, 0x00000000, 0x05026100, 0x00000007, 0x01635200, 0x04450000, 0x00ba0000, 0x00000000,
0xba000200, 0x00000000, 0x05026100, 0x80000007, 0x0164523f, 0x04450000, 0x00bb0001, 0x00000000,
0xbb000200, 0x00000000, 0x05026100, 0x00000007, 0x01655200, 0x04450000, 0x00bb0000, 0x00000000,
0xbb000200, 0x00000000, 0x05026100, 0x80000007, 0x0160523f, 0x04450000, 0x00bc0001, 0x00000000,
0xbc000200, 0x00000000, 0x05026100, 0x00000007, 0x01615200, 0x04450000, 0x00bc0000, 0x00000000,
0xbc000200, 0x00000000, 0x05026100, 0x80000007, 0x0162523f, 0x04450000, 0x00bd0001, 0x00000000,
0xbd000200, 0x00000000, 0x05026100, 0x00000007, 0x01635200, 0x04450000, 0x00bd0000, 0x00000000,
0xbd000200, 0x00000000, 0x05026100, 0x80000007, 0x0164523f, 0x04450000, 0x00be0001, 0x00000000,
0xbe000200, 0x00000000, 0x05026100, 0x00000007, 0x01655200, 0x04450000, 0x00be0000, 0x00000000,
0xbe000200, 0x00000000, 0x05026100, 0x80000007, 0x0160523f, 0x04450000, 0x00bf0001, 0x00000000,
0xbf000200, 0x00000000, 0x05026100, 0x00000007, 0x01615200, 0x04450000, 0x00bf0000, 0x00000000,
0xbf000200, 0x00000000, 0x05026100, 0x80000007, 0x0162523f, 0x04450000, 0x00c00001, 0x00000000,
0xc0000200, 0x00000000, 0x05026100, 0x00000007, 0x01635200, 0x04450000, 0x00c00000, 0x00000000,
0xc0000200, 0x00000000, 0x05026100, 0x80000007, 0x0164523f, 0x04450000, 0x00c10001, 0x00000000,
0xc1000200, 0x00000000, 0x05026100, 0x00000007, 0x01655200, 0x04450000, 0x00c10000, 0x00000000,
0xc1000200, 0x00000000, 0x05026100, 0x80000007, 0x0160523f, 0x04450000, 0x00c20001, 0x00000000,
0xc2000200, 0x00000000, 0x05026100, 0x00000007, 0x01615200, 0x04450000, 0x00c20000, 0x00000000,
0xc2000200, 0x00000000, 0x05026100, 0x80000007, 0x0162523f, 0x04450000, 0x00c30001, 0x00000000,
0xc3000200, 0x00000000, 0x05026100, 0x00000007, 0x01635200, 0x04450000, 0x00c30000, 0x00000000,
0xc3000200, 0x00000000, 0x05026100, 0x80000007, 0x0164523f, 0x04450000, 0x00c40001, 0x00000000,
0xc4000200, 0x00000000, 0x05026100, 0x00000007, 0x01655200, 0x04450000, 0x00c40000, 0x00000000,
0xc4000200, 0x00000000, 0x05026100, 0x80000007, 0x016d523f, 0x002c0000, 0x003a0204, 0x00016700,
0x21070000, 0x01010501, 0x32000000, 0x0d003a00, 0x00002c00, 0x00003b02, 0x00000167, 0x01210700,
0x00010105, 0x00320000, 0x000c803b, 0x00017652, 0x00002900, 0x00c50000, 0x07010000, 0x07050200,
0x3f560000, 0x00017752, 0x00002900, 0x00c50000, 0x07020000, 0x07050200, 0x4196d000, 0x00017852,
0x00002900, 0x00c50000, 0x07030000, 0x07050200, 0x41958000, 0x00017952, 0x00002900, 0x00c50000,
0x07040000, 0x07050200, 0x3e232000, 0x00017a52, 0x00002900, 0x00c50000, 0x07050000, 0x07050200,
0x429db000, 0x52000931, 0x00000184, 0x0200002c, 0x6700003c, 0x00000001, 0x05012107, 0x00000101,
0x3c003200, 0x52000b00, 0x00000194, 0x00000410, 0x0000de00, 0x00000000, 0x00ad0002, 0x00000000,
0xc5000261, 0x02000000, 0x52012107, 0x00000195, 0x00000411, 0x0000c600, 0x00000000, 0x00ad0002,
0x00000000, 0xc5000261, 0x05000000, 0x0c012107, 0x00000004, 0x000000c6, 0x02000000, 0x0000c500,
0x21070300, 0x00c60001, 0x00000000, 0xc5000261, 0x04000000, 0x2c012107, 0x3d020504, 0x00ad0000,
0x00000000, 0xc5000261, 0x01000000, 0x2a012107, 0x00003d04, 0x000000de, 0x02000000, 0x0000de00,
0x61000000, 0x00c60002, 0x00000000, 0x94520261, 0x10000001, 0x00000004, 0x000000df, 0x02000000,
0x0000b000, 0x61000000, 0x00c50002, 0x07020000, 0x95520121, 0x11000001, 0x00000004, 0x000000c7,
0x02000000, 0x0000b000, 0x61000000, 0x00c50002, 0x07050000, 0x040c0121, 0xc7000000, 0x00000000,
0x00020000, 0x000000c5, 0x01210703, 0x0000c700, 0x61000000, 0x00c50002, 0x07040000, 0x042c0121,
0x003e0205, 0x0000b000, 0x61000000, 0x00c50002, 0x07010000, 0x042a0121, 0xdf00003e, 0x00000000,
0x00020000, 0x000000df, 0x02610000, 0x0000c700, 0x61000000, 0x01945202, 0x04100000, 0xe0000000,
0x00000000, 0x00020000, 0x000000b3, 0x02610000, 0x0000c500, 0x21070200, 0x01955201, 0x04110000,
0xc8000000, 0x00000000, 0x00020000, 0x000000b3, 0x02610000, 0x0000c500, 0x21070500, 0x00040c01,
0x00c80000, 0x00000000, 0xc5000200, 0x03000000, 0x00012107, 0x000000c8, 0x02610000, 0x0000c500,
0x21070400, 0x05042c01, 0x00003f02, 0x000000b3, 0x02610000, 0x0000c500, 0x21070100, 0x3f042a01,
0x00e00000, 0x00000000, 0xe0000200, 0x00000000, 0x00026100, 0x000000c8, 0x02610000, 0x00019452,
0x00041000, 0x00e10000, 0x00000000, 0xb6000200, 0x00000000, 0x00026100, 0x000000c5, 0x01210702,
0x00019552, 0x00041100, 0x00c90000, 0x00000000, 0xb6000200, 0x00000000, 0x00026100, 0x000000c5,
0x01210705, 0x0000040c, 0x0000c900, 0x00000000, 0x00c50002, 0x07030000, 0xc9000121, 0x00000000,
0x00026100, 0x000000c5, 0x01210704, 0x0205042c, 0xb6000040, 0x00000000, 0x00026100, 0x000000c5,
0x01210701, 0x0040042a, 0x0000e100, 0x00000000, 0x00e10002, 0x00000000, 0xc9000261, 0x00000000,
0x52026100, 0x00000194, 0x00000410, 0x0000e200, 0x00000000, 0x00ae0002, 0x00000000, 0xc5000261,
0x02000000, 0x52012107, 0x00000195, 0x00000411, 0x0000ca00, 0x00000000, 0x00ae0002, 0x00000000,
0xc5000261, 0x05000000, 0x0c012107, 0x00000004, 0x000000ca, 0x02000000, 0x0000c500, 0x21070300,
0x00ca0001, 0x00000000, 0xc5000261, 0x04000000, 0x2c012107, 0x41020504, 0x00ae0000, 0x00000000,
0xc5000261, 0x01000000, 0x2a012107, 0x00004104, 0x000000e2, 0x02000000, 0x0000e200, 0x61000000,
0x00ca0002, 0x00000000, 0x94520261, 0x10000001, 0x00000004, 0x000000e3, 0x02000000, 0x0000b100,
0x61000000, 0x00c50002, 0x07020000, 0x95520121, 0x11000001, 0x00000004, 0x000000cb, 0x02000000,
0x0000b100, 0x61000000, 0x00c50002, 0x07050000, 0x040c0121, 0xcb000000, 0x00000000, 0x00020000,
0x000000c5, 0x01210703, 0x0000cb00, 0x61000000, 0x00c50002, 0x07040000, 0x042c0121, 0x00420205,
0x0000b100, 0x61000000, 0x00c50002, 0x07010000, 0x042a0121, 0xe3000042, 0x00000000, 0x00020000,
0x000000e3, 0x02610000, 0x0000cb00, 0x61000000, 0x01945202, 0x04100000, 0xe4000000, 0x00000000,
0x00020000, 0x000000b4, 0x02610000, 0x0000c500, 0x21070200, 0x01955201, 0x04110000, 0xcc000000,
0x00000000, 0x00020000, 0x000000b4, 0x02610000, 0x0000c500, 0x21070500, 0x00040c01, 0x00cc0000,
0x00000000, 0xc5000200, 0x03000000, 0x00012107, 0x000000cc, 0x02610000, 0x0000c500, 0x21070400,
0x05042c01, 0x00004302, 0x000000b4, 0x02610000, 0x0000c500, 0x21070100, 0x43042a01, 0x00e40000,
0x00000000, 0xe4000200, 0x00000000, 0x00026100, 0x000000cc, 0x02610000, 0x00019452, 0x00041000,
0x00e50000, 0x00000000, 0xb7000200, 0x00000000, 0x00026100, 0x000000c5, 0x01210702, 0x00019552,
0x00041100, 0x00cd0000, 0x00000000, 0xb7000200, 0x00000000, 0x00026100, 0x000000c5, 0x01210705,
0x0000040c, 0x0000cd00, 0x00000000, 0x00c50002, 0x07030000, 0xcd000121, 0x00000000, 0x00026100,
0x000000c5, 0x01210704, 0x0205042c, 0xb7000044, 0x00000000, 0x00026100, 0x000000c5, 0x01210701,
0x0044042a, 0x0000e500, 0x00000000, 0x00e50002, 0x00000000, 0xcd000261, 0x00000000, 0x52026100,
0x00000194, 0x00000410, 0x0000e600, 0x00000000, 0x00af0002, 0x00000000, 0xc5000261, 0x02000000,
0x52012107, 0x00000195, 0x00000411, 0x0000ce00, 0x00000000, 0x00af0002, 0x00000000, 0xc5000261,
0x05000000, 0x0c012107, 0x00000004, 0x000000ce, 0x02000000, 0x0000c500, 0x21070300, 0x00ce0001,
0x00000000, 0xc5000261, 0x04000000, 0x2c012107, 0x45020504, 0x00af0000, 0x00000000, 0xc5000261,
0x01000000, 0x2a012107, 0x00004504, 0x000000e6, 0x02000000, 0x0000e600, 0x61000000, 0x00ce0002,
0x00000000, 0x94520261, 0x10000001, 0x00000004, 0x000000e7, 0x02000000, 0x0000b200, 0x61000000,
0x00c50002, 0x07020000, 0x95520121, 0x11000001, 0x00000004, 0x000000cf, 0x02000000, 0x0000b200,
0x61000000, 0x00c50002, 0x07050000, 0x040c0121, 0xcf000000, 0x00000000, 0x00020000, 0x000000c5,
0x01210703, 0x0000cf00, 0x61000000, 0x00c50002, 0x07040000, 0x042c0121, 0x00460205, 0x0000b200,
0x61000000, 0x00c50002, 0x07010000, 0x042a0121, 0xe7000046, 0x00000000, 0x00020000, 0x000000e7,
0x02610000, 0x0000cf00, 0x61000000, 0x01945202, 0x04100000, 0xe8000000, 0x00000000, 0x00020000,
0x000000b5, 0x02610000, 0x0000c500, 0x21070200, 0x01955201, 0x04110000, 0xd0000000, 0x00000000,
0x00020000, 0x000000b5, 0x02610000, 0x0000c500, 0x21070500, 0x00040c01, 0x00d00000, 0x00000000,
0xc5000200, 0x03000000, 0x00012107, 0x000000d0, 0x02610000, 0x0000c500, 0x21070400, 0x05042c01,
0x00004702, 0x000000b5, 0x02610000, 0x0000c500, 0x21070100, 0x47042a01, 0x00e80000, 0x00000000,
0xe8000200, 0x00000000, 0x00026100, 0x000000d0, 0x02610000, 0x00019452, 0x00041000, 0x00e90000,
0x00000000, 0xb8000200, 0x00000000, 0x00026100, 0x000000c5, 0x01210702, 0x00019552, 0x00041100,
0x00d10000, 0x00000000, 0xb8000200, 0x00000000, 0x00026100, 0x000000c5, 0x01210705, 0x0000040c,
0x0000d100, 0x00000000, 0x00c50002, 0x07030000, 0xd1000121, 0x00000000, 0x00026100, 0x000000c5,
0x01210704, 0x0205042c, 0xb8000048, 0x00000000, 0x00026100, 0x000000c5, 0x01210701, 0x0048042a,
0x0000e900, 0x00000000, 0x00e90002, 0x00000000, 0xd1000261, 0x00000000, 0x52026100, 0x00000194,
0x00000410, 0x0000ea00, 0x00000000, 0x00b90002, 0x00000000, 0xc5000261, 0x02000000, 0x52012107,
0x00000195, 0x00000411, 0x0000d200, 0x00000000, 0x00b90002, 0x00000000, 0xc5000261, 0x05000000,
0x0c012107, 0x00000004, 0x000000d2, 0x02000000, 0x0000c500, 0x21070300, 0x00d20001, 0x00000000,
0xc5000261, 0x04000000, 0x2c012107, 0x49020504, 0x00b90000, 0x00000000, 0xc5000261, 0x01000000,
0x2a012107, 0x00004904, 0x000000ea, 0x02000000, 0x0000ea00, 0x61000000, 0x00d20002, 0x00000000,
0x94520261, 0x10000001, 0x00000004, 0x000000eb, 0x02000000, 0x0000bc00, 0x61000000, 0x00c50002,
0x07020000, 0x95520121, 0x11000001, 0x00000004, 0x000000d3, 0x02000000, 0x0000bc00, 0x61000000,
0x00c50002, 0x07050000, 0x040c0121, 0xd3000000, 0x00000000, 0x00020000, 0x000000c5, 0x01210703,
0x0000d300, 0x61000000, 0x00c50002, 0x07040000, 0x042c0121, 0x004a0205, 0x0000bc00, 0x61000000,
0x00c50002, 0x07010000, 0x042a0121, 0xeb00004a, 0x00000000, 0x00020000, 0x000000eb, 0x02610000,
0x0000d300, 0x61000000, 0x01945202, 0x04100000, 0xec000000, 0x00000000, 0x00020000, 0x000000bf,
0x02610000, 0x0000c500, 0x21070200, 0x01955201, 0x04110000, 0xd4000000, 0x00000000, 0x00020000,
0x000000bf, 0x02610000, 0x0000c500, 0x21070500, 0x00040c01, 0x00d40000, 0x00000000, 0xc5000200,
0x03000000, 0x00012107, 0x000000d4, 0x02610000, 0x0000c500, 0x21070400, 0x05042c01, 0x00004b02,
0x000000bf, 0x02610000, 0x0000c500, 0x21070100, 0x4b042a01, 0x00ec0000, 0x00000000, 0xec000200,
0x00000000, 0x00026100, 0x000000d4, 0x02610000, 0x00019452, 0x00041000, 0x00ed0000, 0x00000000,
0xc2000200, 0x00000000, 0x00026100, 0x000000c5, 0x01210702, 0x00019552, 0x00041100, 0x00d50000,
0x00000000, 0xc2000200, 0x00000000, 0x00026100, 0x000000c5, 0x01210705, 0x0000040c, 0x0000d500,
0x00000000, 0x00c50002, 0x07030000, 0xd5000121, 0x00000000, 0x00026100, 0x000000c5, 0x01210704,
0x0205042c, 0xc200004c, 0x00000000, 0x00026100, 0x000000c5, 0x01210701, 0x004c042a, 0x0000ed00,
0x00000000, 0x00ed0002, 0x00000000, 0xd5000261, 0x00000000, 0x52026100, 0x00000194, 0x00000410,
0x0000ee00, 0x00000000, 0x00ba0002, 0x00000000, 0xc5000261, 0x02000000, 0x52012107, 0x00000195,
0x00000411, 0x0000d600, 0x00000000, 0x00ba0002, 0x00000000, 0xc5000261, 0x05000000, 0x0c012107,
0x00000004, 0x000000d6, 0x02000000, 0x0000c500, 0x21070300, 0x00d60001, 0x00000000, 0xc5000261,
0x04000000, 0x2c012107, 0x4d020504, 0x00ba0000, 0x00000000, 0xc5000261, 0x01000000, 0x2a012107,
0x00004d04, 0x000000ee, 0x02000000, 0x0000ee00, 0x61000000, 0x00d60002, 0x00000000, 0x94520261,
0x10000001, 0x00000004, 0x000000ef, 0x02000000, 0x0000bd00, 0x61000000, 0x00c50002, 0x07020000,
0x95520121, 0x11000001, 0x00000004, 0x000000d7, 0x02000000, 0x0000bd00, 0x61000000, 0x00c50002,
0x07050000, 0x040c0121, 0xd7000000, 0x00000000, 0x00020000, 0x000000c5, 0x01210703, 0x0000d700,
0x61000000, 0x00c50002, 0x07040000, 0x042c0121, 0x004e0205, 0x0000bd00, 0x61000000, 0x00c50002,
0x07010000, 0x042a0121, 0xef00004e, 0x00000000, 0x00020000, 0x000000ef, 0x02610000, 0x0000d700,
0x61000000, 0x01945202, 0x04100000, 0xf0000000, 0x00000000, 0x00020000, 0x000000c0, 0x02610000,
0x0000c500, 0x21070200, 0x01955201, 0x04110000, 0xd8000000, 0x00000000, 0x00020000, 0x000000c0,
0x02610000, 0x0000c500, 0x21070500, 0x00040c01, 0x00d80000, 0x00000000, 0xc5000200, 0x03000000,
0x00012107, 0x000000d8, 0x02610000, 0x0000c500, 0x21070400, 0x05042c01, 0x00004f02, 0x000000c0,
0x02610000, 0x0000c500, 0x21070100, 0x4f042a01, 0x00f00000, 0x00000000, 0xf0000200, 0x00000000,
0x00026100, 0x000000d8, 0x02610000, 0x00019452, 0x00041000, 0x00f10000, 0x00000000, 0xc3000200,
0x00000000, 0x00026100, 0x000000c5, 0x01210702, 0x00019552, 0x00041100, 0x00d90000, 0x00000000,
0xc3000200, 0x00000000, 0x00026100, 0x000000c5, 0x01210705, 0x0000040c, 0x0000d900, 0x00000000,
0x00c50002, 0x07030000, 0xd9000121, 0x00000000, 0x00026100, 0x000000c5, 0x01210704, 0x0205042c,
0xc3000050, 0x00000000, 0x00026100, 0x000000c5, 0x01210701, 0x0050042a, 0x0000f100, 0x00000000,
0x00f10002, 0x00000000, 0xd9000261, 0x00000000, 0x52026100, 0x00000194, 0x00000410, 0x0000f200,
0x00000000, 0x00bb0002, 0x00000000, 0xc5000261, 0x02000000, 0x52012107, 0x00000195, 0x00000411,
0x0000da00, 0x00000000, 0x00bb0002, 0x00000000, 0xc5000261, 0x05000000, 0x0c012107, 0x00000004,
0x000000da, 0x02000000, 0x0000c500, 0x21070300, 0x00da0001, 0x00000000, 0xc5000261, 0x04000000,
0x2c012107, 0x51020504, 0x00bb0000, 0x00000000, 0xc5000261, 0x01000000, 0x2a012107, 0x00005104,
0x000000f2, 0x02000000, 0x0000f200, 0x61000000, 0x00da0002, 0x00000000, 0x94520261, 0x10000001,
0x00000004, 0x000000f3, 0x02000000, 0x0000be00, 0x61000000, 0x00c50002, 0x07020000, 0x95520121,
0x11000001, 0x00000004, 0x000000db, 0x02000000, 0x0000be00, 0x61000000, 0x00c50002, 0x07050000,
0x040c0121, 0xdb000000, 0x00000000, 0x00020000, 0x000000c5, 0x01210703, 0x0000db00, 0x61000000,
0x00c50002, 0x07040000, 0x042c0121, 0x00520205, 0x0000be00, 0x61000000, 0x00c50002, 0x07010000,
0x042a0121, 0xf3000052, 0x00000000, 0x00020000, 0x000000f3, 0x02610000, 0x0000db00, 0x61000000,
0x01945202, 0x04100000, 0xf4000000, 0x00000000, 0x00020000, 0x000000c1, 0x02610000, 0x0000c500,
0x21070200, 0x01955201, 0x04110000, 0xdc000000, 0x00000000, 0x00020000, 0x000000c1, 0x02610000,
0x0000c500, 0x21070500, 0x00040c01, 0x00dc0000, 0x00000000, 0xc5000200, 0x03000000, 0x00012107,
0x000000dc, 0x02610000, 0x0000c500, 0x21070400, 0x05042c01, 0x00005302, 0x000000c1, 0x02610000,
0x0000c500, 0x21070100, 0x53042a01, 0x00f40000, 0x00000000, 0xf4000200, 0x00000000, 0x00026100,
0x000000dc, 0x02610000, 0x00019452, 0x00041000, 0x00f50000, 0x00000000, 0xc4000200, 0x00000000,
0x00026100, 0x000000c5, 0x01210702, 0x00019552, 0x00041100, 0x00dd0000, 0x00000000, 0xc4000200,
0x00000000, 0x00026100, 0x000000c5, 0x01210705, 0x0000040c, 0x0000dd00, 0x00000000, 0x00c50002,
0x07030000, 0xdd000121, 0x00000000, 0x00026100, 0x000000c5, 0x01210704, 0x0205042c, 0xc4000054,
0x00000000, 0x00026100, 0x000000c5, 0x01210701, 0x0054042a, 0x0000f500, 0x00000000, 0x00f50002,
0x00000000, 0xdd000261, 0x00000000, 0x31026100, 0x0029000a, 0xf6000000, 0x00000000, 0x05020000,
0x7fff0007, 0x00002947, 0x00f70000, 0x00000000, 0x07050200, 0x3f000000, 0x0001a252, 0x00040c00,
0x00f50000, 0x00000000, 0xf5000200, 0x00000000, 0x00026100, 0x000000f6, 0x01210000, 0x0000f700,
0x21000000, 0x00042901, 0x00f82000, 0x00000000, 0xf5000200, 0x00000000, 0x0c026100, 0x00000004,
0x000000f4, 0x02000000, 0x0000f400, 0x61000000, 0x00f60002, 0x00000000, 0xf7000121, 0x00000000,
0x29012100, 0x20000004, 0x000000f9, 0x02000000, 0x0000f400, 0x61000000, 0x00040c02, 0x00f30000,
0x00000000, 0xf3000200, 0x00000000, 0x00026100, 0x000000f6, 0x01210000, 0x0000f700, 0x21000000,
0x00042901, 0x00fa2000, 0x00000000, 0xf3000200, 0x00000000, 0x0c026100, 0x00000004, 0x000000f2,
0x02000000, 0x0000f200, 0x61000000, 0x00f60002, 0x00000000, 0xf7000121, 0x00000000, 0x29012100,
0x20000004, 0x000000fb, 0x02000000, 0x0000f200, 0x61000000, 0x00040c02, 0x00f10000, 0x00000000,
0xf1000200, 0x00000000, 0x00026100, 0x000000f6, 0x01210000, 0x0000f700, 0x21000000, 0x00042901,
0x00fc2000, 0x00000000, 0xf1000200, 0x00000000, 0x0c026100, 0x00000004, 0x000000f0, 0x02000000,
0x0000f000, 0x61000000, 0x00f60002, 0x00000000, 0xf7000121, 0x00000000, 0x29012100, 0x20000004,
0x000000fd, 0x02000000, 0x0000f000, 0x61000000, 0x00040c02, 0x00ef0000, 0x00000000, 0xef000200,
0x00000000, 0x00026100, 0x000000f6, 0x01210000, 0x0000f700, 0x21000000, 0x00042901, 0x00fe2000,
0x00000000, 0xef000200, 0x00000000, 0x0c026100, 0x00000004, 0x000000ee, 0x02000000, 0x0000ee00,
0x61000000, 0x00f60002, 0x00000000, 0xf7000121, 0x00000000, 0x29012100, 0x20000004, 0x000000ff,
0x02000000, 0x0000ee00, 0x61000000, 0x00040c02, 0x01000000, 0x00000000, 0xed000200, 0x00000000,
0x00026100, 0x000000f6, 0x01210000, 0x0000f700, 0x21000000, 0x00042901, 0x01012000, 0x00000000,
0x00000200, 0x00000001, 0x0c026100, 0x00000004, 0x00000102, 0x02000000, 0x0000ec00, 0x61000000,
0x00f60002, 0x00000000, 0xf7000121, 0x00000000, 0x29012100, 0x20000004, 0x00000103, 0x02000000,
0x00010200, 0x61000000, 0x00040c02, 0x01040000, 0x00000000, 0xeb000200, 0x00000000, 0x00026100,
0x000000f6, 0x01210000, 0x0000f700, 0x21000000, 0x00042901, 0x01052000, 0x00000000, 0x04000200,
0x00000001, 0x0c026100, 0x00000004, 0x00000106, 0x02000000, 0x0000ea00, 0x61000000, 0x00f60002,
0x00000000, 0xf7000121, 0x00000000, 0x29012100, 0x20000004, 0x00000107, 0x02000000, 0x00010600,
0x61000000, 0x00040c02, 0x01080000, 0x00000000, 0xe9000200, 0x00000000, 0x00026100, 0x000000f6,
0x01210000, 0x0000f700, 0x21000000, 0x00042901, 0x01092000, 0x00000000, 0x08000200, 0x00000001,
0x0c026100, 0x00000004, 0x0000010a, 0x02000000, 0x0000e800, 0x61000000, 0x00f60002, 0x00000000,
0xf7000121, 0x00000000, 0x29012100, 0x20000004, 0x0000010b, 0x02000000, 0x00010a00, 0x61000000,
0x00040c02, 0x010c0000, 0x00000000, 0xe7000200, 0x00000000, 0x00026100, 0x000000f6, 0x01210000,
0x0000f700, 0x21000000, 0x00042901, 0x010d2000, 0x00000000, 0x0c000200, 0x00000001, 0x0c026100,
0x00000004, 0x0000010e, 0x02000000, 0x0000e600, 0x61000000, 0x00f60002, 0x00000000, 0xf7000121,
0x00000000, 0x29012100, 0x20000004, 0x0000010f, 0x02000000, 0x00010e00, 0x61000000, 0x00040c02,
0x01100000, 0x00000000, 0xe5000200, 0x00000000, 0x00026100, 0x000000f6, 0x01210000, 0x0000f700,
0x21000000, 0x00042901, 0x01682000, 0x00010000, 0x10000200, 0x00000001, 0x0c026100, 0x00000004,
0x00000111, 0x02000000, 0x0000e400, 0x61000000, 0x00f60002, 0x00000000, 0xf7000121, 0x00000000,
0x29012100, 0x20000004, 0x00000168, 0x02000000, 0x00011100, 0x61000000, 0x00040c02, 0x01120000,
0x00000000, 0xe3000200, 0x00000000, 0x00026100, 0x000000f6, 0x01210000, 0x0000f700, 0x21000000,
0x00042901, 0x01692000, 0x00010000, 0x12000200, 0x00000001, 0x0c026100, 0x00000004, 0x00000113,
0x02000000, 0x0000e200, 0x61000000, 0x00f60002, 0x00000000, 0xf7000121, 0x00000000, 0x29012100,
0x20000004, 0x00000169, 0x02000000, 0x00011300, 0x61000000, 0x00040c02, 0x01140000, 0x00000000,
0xe1000200, 0x00000000, 0x00026100, 0x000000f6, 0x01210000, 0x0000f700, 0x21000000, 0x00042901,
0x01152000, 0x00000000, 0x14000200, 0x00000001, 0x0c026100, 0x00000004, 0x00000116, 0x02000000,
0x0000e000, 0x61000000, 0x00f60002, 0x00000000, 0xf7000121, 0x00000000, 0x29012100, 0x20000004,
0x00000117, 0x02000000, 0x00011600, 0x61000000, 0x00040c02, 0x01180000, 0x00000000, 0xdf000200,
0x00000000, 0x00026100, 0x000000f6, 0x01210000, 0x0000f700, 0x21000000, 0x00042901, 0x01192000,
0x00000000, 0x18000200, 0x00000001, 0x0c026100, 0x00000004, 0x0000011a, 0x02000000, 0x0000de00,
0x61000000, 0x00f60002, 0x00000000, 0xf7000121, 0x00000000, 0x29012100, 0x20000004, 0x0000011b,
0x02000000, 0x00011a00, 0x61000000, 0x01a65202, 0x03290000, 0x6a000000, 0x00000001, 0x00040000,
0x0000011b, 0x02510000, 0x00000329, 0x00016b00, 0x00000000, 0x011b0004, 0x08000000, 0x03290251,
0x6c000000, 0x00000001, 0x00040000, 0x00000119, 0x02510000, 0x00000329, 0x00016d00, 0x00000000,
0x01190004, 0x08000000, 0x03290251, 0x6e000000, 0x00000001, 0x00040000, 0x00000117, 0x02510000,
0x00000329, 0x00016f00, 0x00000000, 0x01170004, 0x08000000, 0x03290251, 0x70000000, 0x00000001,
0x00040000, 0x00000115, 0x02510000, 0x00000329, 0x00017100, 0x00000000, 0x01150004, 0x08000000,
0xa7520251, 0x29000001, 0x00000003, 0x00000172, 0x04000000, 0x00010700, 0x51000000, 0x00032902,
0x01730000, 0x00000000, 0x07000400, 0x00000001, 0x29025108, 0x00000003, 0x00000174, 0x04000000,
0x00010500, 0x51000000, 0x00032902, 0x01750000, 0x00000000, 0x05000400, 0x00000001, 0x29025108,
0x00000003, 0x00000176, 0x04000000, 0x00010300, 0x51000000, 0x00032902, 0x01770000, 0x00000000,
0x03000400, 0x00000001, 0x29025108, 0x00000003, 0x00000178, 0x04000000, 0x00010100, 0x51000000,
0x00032902, 0x01790000, 0x00000000, 0x01000400, 0x00000001, 0x52025108, 0x000001a8, 0x00000329,
0x00016a00, 0x00010000, 0x01690004, 0x00000000, 0x03290251, 0x6b000000, 0x00000001, 0x00040001,
0x00000169, 0x02510800, 0x00000329, 0x00016c00, 0x00010000, 0x01690004, 0x00010000, 0x03290251,
0x6d000000, 0x00000001, 0x00040001, 0x00000169, 0x02510801, 0x00000329, 0x00016e00, 0x00010000,
0x01680004, 0x00000000, 0x03290251, 0x6f000000, 0x00000001, 0x00040001, 0x00000168, 0x02510800,
0x00000329, 0x00017000, 0x00010000, 0x01680004, 0x00010000, 0x03290251, 0x71000000, 0x00000001,
0x00040001, 0x00000168, 0x02510801, 0x0001a952, 0x00032900, 0x01720000, 0x01000000, 0xff000400,
0x00000000, 0x29025100, 0x00000003, 0x00000173, 0x04000100, 0x0000ff00, 0x51080000, 0x00032902,
0x01740000, 0x01000000, 0xfe000400, 0x00000000, 0x29025100, 0x00000003, 0x00000175, 0x04000100,
0x0000fe00, 0x51080000, 0x00032902, 0x01760000, 0x01000000, 0xfd000400, 0x00000000, 0x29025100,
0x00000003, 0x00000177, 0x04000100, 0x0000fd00, 0x51080000, 0x00032902, 0x01780000, 0x01000000,
0xfc000400, 0x00000000, 0x29025100, 0x00000003, 0x00000179, 0x04000100, 0x0000fc00, 0x51080000,
0x01aa5202, 0x03290000, 0x6a000000, 0x00000001, 0x00040002, 0x0000010f, 0x02510000, 0x00000329,
0x00016b00, 0x00020000, 0x010f0004, 0x08000000, 0x03290251, 0x6c000000, 0x00000001, 0x00040002,
0x0000010d, 0x02510000, 0x00000329, 0x00016d00, 0x00020000, 0x010d0004, 0x08000000, 0x03290251,
0x6e000000, 0x00000001, 0x00040002, 0x0000010b, 0x02510000, 0x00000329, 0x00016f00, 0x00020000,
0x010b0004, 0x08000000, 0x03290251, 0x70000000, 0x00000001, 0x00040002, 0x00000109, 0x02510000,
0x00000329, 0x00017100, 0x00020000, 0x01090004, 0x08000000, 0xab520251, 0x29000001, 0x00000003,
0x00000172, 0x04000200, 0x0000fb00, 0x51000000, 0x00032902, 0x01730000, 0x02000000, 0xfb000400,
0x00000000, 0x29025108, 0x00000003, 0x00000174, 0x04000200, 0x0000fa00, 0x51000000, 0x00032902,
0x01750000, 0x02000000, 0xfa000400, 0x00000000, 0x29025108, 0x00000003, 0x00000176, 0x04000200,
0x0000f900, 0x51000000, 0x00032902, 0x01770000, 0x02000000, 0xf9000400, 0x00000000, 0x29025108,
0x00000003, 0x00000178, 0x04000200, 0x0000f800, 0x51000000, 0x00032902, 0x01790000, 0x02000000,
0xf8000400, 0x00000000, 0x52025108, 0x000001ac, 0x00000329, 0x00016a00, 0x00030000, 0x00030504,
0x29000000, 0x00000003, 0x0000016b, 0x04000300, 0x00000305, 0x03290000, 0x6c000000, 0x00000001,
0x05040003, 0x00000003, 0x00032900, 0x016d0000, 0x03000000, 0x03050400, 0x00000000, 0x00000329,
0x00016e00, 0x00030000, 0x00030504, 0x29000000, 0x00000003, 0x0000016f, 0x04000300, 0x00000305,
0x03290000, 0x70000000, 0x00000001, 0x05040003, 0x00000003, 0x00032900, 0x01710000, 0x03000000,
0x03050400, 0x00000000, 0x0001ad52, 0x00032900, 0x01720000, 0x03000000, 0x03050400, 0x00000000,
0x00000329, 0x00017300, 0x00030000, 0x00030504, 0x29000000, 0x00000003, 0x00000174, 0x04000300,
0x00000305, 0x03290000, 0x75000000, 0x00000001, 0x05040003, 0x00000003, 0x00032900, 0x01760000,
0x03000000, 0x03050400, 0x00000000, 0x00000329, 0x00017700, 0x00030000, 0x00030504, 0x29000000,
0x00000003, 0x00000178, 0x04000300, 0x00000305, 0x03290000, 0x79000000, 0x00000001, 0x05040003,
0x00000003, 0x01b65200, 0x04290000, 0x1c000000, 0x00000001, 0x00020000, 0x0000016a, 0x02610000,
0x00000429, 0x00011c00, 0x00000100, 0x016c0002, 0x00000000, 0x04290261, 0x1c000000, 0x02000001,
0x00020000, 0x0000016e, 0x02610000, 0x00000429, 0x00011c00, 0x00000300, 0x01700002, 0x00000000,
0x00380261, 0x04200006, 0x00015d00, 0x21000000, 0x015e0001, 0x00000000, 0x011c0121, 0x00000000,
0x00000429, 0x00011d00, 0x00000000, 0x016a0002, 0x00010000, 0x04290261, 0x1d000000, 0x01000001,
0x00020000, 0x0000016c, 0x02610001, 0x00000429, 0x00011d00, 0x00000200, 0x016e0002, 0x00010000,
0x04290261, 0x1d000000, 0x03000001, 0x00020000, 0x00000170, 0x02610001, 0x00060038, 0x5f000420,
0x00000001, 0x00012100, 0x0000015e, 0x01210000, 0x0000011d, 0x04290000, 0x1e000000, 0x00000001,
0x00020000, 0x0000016b, 0x02610000, 0x00000429, 0x00011e00, 0x00000100, 0x016d0002, 0x00000000,
0x04290261, 0x1e000000, 0x02000001, 0x00020000, 0x0000016f, 0x02610000, 0x00000429, 0x00011e00,
0x00000300, 0x01710002, 0x00000000, 0x00380261, 0x04200006, 0x00016000, 0x21000000, 0x015e0001,
0x00000000, 0x011e0121, 0x00000000, 0x00000429, 0x00011f00, 0x00000000, 0x016b0002, 0x00010000,
0x04290261, 0x1f000000, 0x01000001, 0x00020000, 0x0000016d, 0x02610001, 0x00000429, 0x00011f00,
0x00000200, 0x016f0002, 0x00010000, 0x04290261, 0x1f000000, 0x03000001, 0x00020000, 0x00000171,
0x02610001, 0x00060038, 0x61000420, 0x00000001, 0x00012100, 0x0000015e, 0x01210000, 0x0000011f,
0x04290000, 0x20000000, 0x00000001, 0x00020000, 0x00000172, 0x02610000, 0x00000429, 0x00012000,
0x00000100, 0x01740002, 0x00000000, 0x04290261, 0x20000000, 0x02000001, 0x00020000, 0x00000176,
0x02610000, 0x00000429, 0x00012000, 0x00000300, 0x01780002, 0x00000000, 0x00380261, 0x04200006,
0x00015d00, 0x21000000, 0x01620001, 0x00000000, 0x01200121, 0x00000000, 0x00000429, 0x00012100,
0x00000000, 0x01720002, 0x00010000, 0x04290261, 0x21000000, 0x01000001, 0x00020000, 0x00000174,
0x02610001, 0x00000429, 0x00012100, 0x00000200, 0x01760002, 0x00010000, 0x04290261, 0x21000000,
0x03000001, 0x00020000, 0x00000178, 0x02610001, 0x00060038, 0x5f000420, 0x00000001, 0x00012100,
0x00000162, 0x01210000, 0x00000121, 0x04290000, 0x22000000, 0x00000001, 0x00020000, 0x00000173,
0x02610000, 0x00000429, 0x00012200, 0x00000100, 0x01750002, 0x00000000, 0x04290261, 0x22000000,
0x02000001, 0x00020000, 0x00000177, 0x02610000, 0x00000429, 0x00012200, 0x00000300, 0x01790002,
0x00000000, 0x00380261, 0x04200006, 0x00016000, 0x21000000, 0x01620001, 0x00000000, 0x01220121,
0x00000000, 0x00000429, 0x00012300, 0x00000000, 0x01730002, 0x00010000, 0x04290261, 0x23000000,
0x01000001, 0x00020000, 0x00000175, 0x02610001, 0x00000429, 0x00012300, 0x00000200, 0x01770002,
0x00010000, 0x04290261, 0x23000000, 0x03000001, 0x00020000, 0x00000179, 0x02610001, 0x00060038,
0x61000420, 0x00000001, 0x00012100, 0x00000162, 0x01210000, 0x00000123, 0xb8520000, 0x34000001,
0x31000000, 0x8952000b, 0x11000001, 0x00000004, 0x000000ad, 0x02000000, 0x0000ad00, 0x61000000,
0x00c50002, 0x07040000, 0x00290121, 0x24000000, 0x00000001, 0x05020000, 0x80000007, 0x018a523f,
0x040c0000, 0x25000000, 0x00000001, 0x00020000, 0x000000c5, 0x01210703, 0x0000ad00, 0x61000000,
0x01240002, 0x00000000, 0x8b520121, 0x0c000001, 0x00000004, 0x000000ad, 0x02000000, 0x0000ad00,
0x61000000, 0x00c50002, 0x07020000, 0xc5000121, 0x01000000, 0x52012107, 0x0000018c, 0x00000403,
0x0000ad00, 0x00000000, 0x00ad0002, 0x00000000, 0x25000261, 0x00000001, 0x52026100, 0x0000018d,
0x00000411, 0x0000de00, 0x00000000, 0x00ad0002, 0x00000000, 0xc5000261, 0x05000000, 0x52012107,
0x00000189, 0x00000411, 0x0000b000, 0x00000000, 0x00b00002, 0x00000000, 0xc5000261, 0x04000000,
0x52012107, 0x0000018a, 0x0000040c, 0x00012600, 0x00000000, 0x00c50002, 0x07030000, 0xb0000121,
0x00000000, 0x00026100, 0x00000124, 0x01210000, 0x00018b52, 0x00040c00, 0x00b00000, 0x00000000,
0xb0000200, 0x00000000, 0x00026100, 0x000000c5, 0x01210702, 0x0000c500, 0x21070100, 0x018c5201,
0x04030000, 0xb0000000, 0x00000000, 0x00020000, 0x000000b0, 0x02610000, 0x00012600, 0x61000000,
0x018d5202, 0x04110000, 0xdf000000, 0x00000000, 0x00020000, 0x000000b0, 0x02610000, 0x0000c500,
0x21070500, 0x01895201, 0x04110000, 0xb3000000, 0x00000000, 0x00020000, 0x000000b3, 0x02610000,
0x0000c500, 0x21070400, 0x018a5201, 0x040c0000, 0x27000000, 0x00000001, 0x00020000, 0x000000c5,
0x01210703, 0x0000b300, 0x61000000, 0x01240002, 0x00000000, 0x8b520121, 0x0c000001, 0x00000004,
0x000000b3, 0x02000000, 0x0000b300, 0x61000000, 0x00c50002, 0x07020000, 0xc5000121, 0x01000000,
0x52012107, 0x0000018c, 0x00000403, 0x0000b300, 0x00000000, 0x00b30002, 0x00000000, 0x27000261,
0x00000001, 0x52026100, 0x0000018d, 0x00000411, 0x0000e000, 0x00000000, 0x00b30002, 0x00000000,
0xc5000261, 0x05000000, 0x52012107, 0x00000189, 0x00000411, 0x0000b600, 0x00000000, 0x00b60002,
0x00000000, 0xc5000261, 0x04000000, 0x52012107, 0x0000018a, 0x0000040c, 0x00012800, 0x00000000,
0x00c50002, 0x07030000, 0xb6000121, 0x00000000, 0x00026100, 0x00000124, 0x01210000, 0x00018b52,
0x00040c00, 0x00b60000, 0x00000000, 0xb6000200, 0x00000000, 0x00026100, 0x000000c5, 0x01210702,
0x0000c500, 0x21070100, 0x018c5201, 0x04030000, 0xb6000000, 0x00000000, 0x00020000, 0x000000b6,
0x02610000, 0x00012800, 0x61000000, 0x018d5202, 0x04110000, 0xe1000000, 0x00000000, 0x00020000,
0x000000b6, 0x02610000, 0x0000c500, 0x21070500, 0x01895201, 0x04110000, 0xae000000, 0x00000000,
0x00020000, 0x000000ae, 0x02610000, 0x0000c500, 0x21070400, 0x018a5201, 0x040c0000, 0x29000000,
0x00000001, 0x00020000, 0x000000c5, 0x01210703, 0x0000ae00, 0x61000000, 0x01240002, 0x00000000,
0x8b520121, 0x0c000001, 0x00000004, 0x000000ae, 0x02000000, 0x0000ae00, 0x61000000, 0x00c50002,
0x07020000, 0xc5000121, 0x01000000, 0x52012107, 0x0000018c, 0x00000403, 0x0000ae00, 0x00000000,
0x00ae0002, 0x00000000, 0x29000261, 0x00000001, 0x52026100, 0x0000018d, 0x00000411, 0x0000e200,
0x00000000, 0x00ae0002, 0x00000000, 0xc5000261, 0x05000000, 0x52012107, 0x00000189, 0x00000411,
0x0000b100, 0x00000000, 0x00b10002, 0x00000000, 0xc5000261, 0x04000000, 0x52012107, 0x0000018a,
0x0000040c, 0x00012a00, 0x00000000, 0x00c50002, 0x07030000, 0xb1000121, 0x00000000, 0x00026100,
0x00000124, 0x01210000, 0x00018b52, 0x00040c00, 0x00b10000, 0x00000000, 0xb1000200, 0x00000000,
0x00026100, 0x000000c5, 0x01210702, 0x0000c500, 0x21070100, 0x018c5201, 0x04030000, 0xb1000000,
0x00000000, 0x00020000, 0x000000b1, 0x02610000, 0x00012a00, 0x61000000, 0x018d5202, 0x04110000,
0xe3000000, 0x00000000, 0x00020000, 0x000000b1, 0x02610000, 0x0000c500, 0x21070500, 0x01895201,
0x04110000, 0xb4000000, 0x00000000, 0x00020000, 0x000000b4, 0x02610000, 0x0000c500, 0x21070400,
0x018a5201, 0x040c0000, 0x2b000000, 0x00000001, 0x00020000, 0x000000c5, 0x01210703, 0x0000b400,
0x61000000, 0x01240002, 0x00000000, 0x8b520121, 0x0c000001, 0x00000004, 0x000000b4, 0x02000000,
0x0000b400, 0x61000000, 0x00c50002, 0x07020000, 0xc5000121, 0x01000000, 0x52012107, 0x0000018c,
0x00000403, 0x0000b400, 0x00000000, 0x00b40002, 0x00000000, 0x2b000261, 0x00000001, 0x52026100,
0x0000018d, 0x00000411, 0x0000e400, 0x00000000, 0x00b40002, 0x00000000, 0xc5000261, 0x05000000,
0x52012107, 0x00000189, 0x00000411, 0x0000b700, 0x00000000, 0x00b70002, 0x00000000, 0xc5000261,
0x04000000, 0x52012107, 0x0000018a, 0x0000040c, 0x00012c00, 0x00000000, 0x00c50002, 0x07030000,
0xb7000121, 0x00000000, 0x00026100, 0x00000124, 0x01210000, 0x00018b52, 0x00040c00, 0x00b70000,
0x00000000, 0xb7000200, 0x00000000, 0x00026100, 0x000000c5, 0x01210702, 0x0000c500, 0x21070100,
0x018c5201, 0x04030000, 0xb7000000, 0x00000000, 0x00020000, 0x000000b7, 0x02610000, 0x00012c00,
0x61000000, 0x018d5202, 0x04110000, 0xe5000000, 0x00000000, 0x00020000, 0x000000b7, 0x02610000,
0x0000c500, 0x21070500, 0x01895201, 0x04110000, 0xaf000000, 0x00000000, 0x00020000, 0x000000af,
0x02610000, 0x0000c500, 0x21070400, 0x018a5201, 0x040c0000, 0x2d000000, 0x00000001, 0x00020000,
0x000000c5, 0x01210703, 0x0000af00, 0x61000000, 0x01240002, 0x00000000, 0x8b520121, 0x0c000001,
0x00000004, 0x000000af, 0x02000000, 0x0000af00, 0x61000000, 0x00c50002, 0x07020000, 0xc5000121,
0x01000000, 0x52012107, 0x0000018c, 0x00000403, 0x0000af00, 0x00000000, 0x00af0002, 0x00000000,
0x2d000261, 0x00000001, 0x52026100, 0x0000018d, 0x00000411, 0x0000e600, 0x00000000, 0x00af0002,
0x00000000, 0xc5000261, 0x05000000, 0x52012107, 0x00000189, 0x00000411, 0x0000b200, 0x00000000,
0x00b20002, 0x00000000, 0xc5000261, 0x04000000, 0x52012107, 0x0000018a, 0x0000040c, 0x00012e00,
0x00000000, 0x00c50002, 0x07030000, 0xb2000121, 0x00000000, 0x00026100, 0x00000124, 0x01210000,
0x00018b52, 0x00040c00, 0x00b20000, 0x00000000, 0xb2000200, 0x00000000, 0x00026100, 0x000000c5,
0x01210702, 0x0000c500, 0x21070100, 0x018c5201, 0x04030000, 0xb2000000, 0x00000000, 0x00020000,
0x000000b2, 0x02610000, 0x00012e00, 0x61000000, 0x018d5202, 0x04110000, 0xe7000000, 0x00000000,
0x00020000, 0x000000b2, 0x02610000, 0x0000c500, 0x21070500, 0x01895201, 0x04110000, 0xb5000000,
0x00000000, 0x00020000, 0x000000b5, 0x02610000, 0x0000c500, 0x21070400, 0x018a5201, 0x040c0000,
0x2f000000, 0x00000001, 0x00020000, 0x000000c5, 0x01210703, 0x0000b500, 0x61000000, 0x01240002,
0x00000000, 0x8b520121, 0x0c000001, 0x00000004, 0x000000b5, 0x02000000, 0x0000b500, 0x61000000,
0x00c50002, 0x07020000, 0xc5000121, 0x01000000, 0x52012107, 0x0000018c, 0x00000403, 0x0000b500,
0x00000000, 0x00b50002, 0x00000000, 0x2f000261, 0x00000001, 0x52026100, 0x0000018d, 0x00000411,
0x0000e800, 0x00000000, 0x00b50002, 0x00000000, 0xc5000261, 0x05000000, 0x52012107, 0x00000189,
0x00000411, 0x0000b800, 0x00000000, 0x00b80002, 0x00000000, 0xc5000261, 0x04000000, 0x52012107,
0x0000018a, 0x0000040c, 0x00013000, 0x00000000, 0x00c50002, 0x07030000, 0xb8000121, 0x00000000,
0x00026100, 0x00000124, 0x01210000, 0x00018b52, 0x00040c00, 0x00b80000, 0x00000000, 0xb8000200,
0x00000000, 0x00026100, 0x000000c5, 0x01210702, 0x0000c500, 0x21070100, 0x018c5201, 0x04030000,
0xb8000000, 0x00000000, 0x00020000, 0x000000b8, 0x02610000, 0x00013000, 0x61000000, 0x018d5202,
0x04110000, 0xe9000000, 0x00000000, 0x00020000, 0x000000b8, 0x02610000, 0x0000c500, 0x21070500,
0x01895201, 0x04110000, 0xb9000000, 0x00000000, 0x00020000, 0x000000b9, 0x02610000, 0x0000c500,
0x21070400, 0x018a5201, 0x040c0000, 0x31000000, 0x00000001, 0x00020000, 0x000000c5, 0x01210703,
0x0000b900, 0x61000000, 0x01240002, 0x00000000, 0x8b520121, 0x0c000001, 0x00000004, 0x000000b9,
0x02000000, 0x0000b900, 0x61000000, 0x00c50002, 0x07020000, 0xc5000121, 0x01000000, 0x52012107,
0x0000018c, 0x00000403, 0x0000b900, 0x00000000, 0x00b90002, 0x00000000, 0x31000261, 0x00000001,
0x52026100, 0x0000018d, 0x00000411, 0x0000ea00, 0x00000000, 0x00b90002, 0x00000000, 0xc5000261,
0x05000000, 0x52012107, 0x00000189, 0x00000411, 0x0000bc00, 0x00000000, 0x00bc0002, 0x00000000,
0xc5000261, 0x04000000, 0x52012107, 0x0000018a, 0x0000040c, 0x00013200, 0x00000000, 0x00c50002,
0x07030000, 0xbc000121, 0x00000000, 0x00026100, 0x00000124, 0x01210000, 0x00018b52, 0x00040c00,
0x00bc0000, 0x00000000, 0xbc000200, 0x00000000, 0x00026100, 0x000000c5, 0x01210702, 0x0000c500,
0x21070100, 0x018c5201, 0x04030000, 0xbc000000, 0x00000000, 0x00020000, 0x000000bc, 0x02610000,
0x00013200, 0x61000000, 0x018d5202, 0x04110000, 0xeb000000, 0x00000000, 0x00020000, 0x000000bc,
0x02610000, 0x0000c500, 0x21070500, 0x01895201, 0x04110000, 0xbf000000, 0x00000000, 0x00020000,
0x000000bf, 0x02610000, 0x0000c500, 0x21070400, 0x018a5201, 0x040c0000, 0x33000000, 0x00000001,
0x00020000, 0x000000c5, 0x01210703, 0x0000bf00, 0x61000000, 0x01240002, 0x00000000, 0x8b520121,
0x0c000001, 0x00000004, 0x000000bf, 0x02000000, 0x0000bf00, 0x61000000, 0x00c50002, 0x07020000,
0xc5000121, 0x01000000, 0x52012107, 0x0000018c, 0x00000403, 0x0000bf00, 0x00000000, 0x00bf0002,
0x00000000, 0x33000261, 0x00000001, 0x52026100, 0x0000018d, 0x00000411, 0x0000ec00, 0x00000000,
0x00bf0002, 0x00000000, 0xc5000261, 0x05000000, 0x52012107, 0x00000189, 0x00000411, 0x0000c200,
0x00000000, 0x00c20002, 0x00000000, 0xc5000261, 0x04000000, 0x52012107, 0x0000018a, 0x0000040c,
0x00013400, 0x00000000, 0x00c50002, 0x07030000, 0xc2000121, 0x00000000, 0x00026100, 0x00000124,
0x01210000, 0x00018b52, 0x00040c00, 0x00c20000, 0x00000000, 0xc2000200, 0x00000000, 0x00026100,
0x000000c5, 0x01210702, 0x0000c500, 0x21070100, 0x018c5201, 0x04030000, 0xc2000000, 0x00000000,
0x00020000, 0x000000c2, 0x02610000, 0x00013400, 0x61000000, 0x018d5202, 0x04110000, 0xed000000,
0x00000000, 0x00020000, 0x000000c2, 0x02610000, 0x0000c500, 0x21070500, 0x01895201, 0x04110000,
0xba000000, 0x00000000, 0x00020000, 0x000000ba, 0x02610000, 0x0000c500, 0x21070400, 0x018a5201,
0x040c0000, 0x35000000, 0x00000001, 0x00020000, 0x000000c5, 0x01210703, 0x0000ba00, 0x61000000,
0x01240002, 0x00000000, 0x8b520121, 0x0c000001, 0x00000004, 0x000000ba, 0x02000000, 0x0000ba00,
0x61000000, 0x00c50002, 0x07020000, 0xc5000121, 0x01000000, 0x52012107, 0x0000018c, 0x00000403,
0x0000ba00, 0x00000000, 0x00ba0002, 0x00000000, 0x35000261, 0x00000001, 0x52026100, 0x0000018d,
0x00000411, 0x0000ee00, 0x00000000, 0x00ba0002, 0x00000000, 0xc5000261, 0x05000000, 0x52012107,
0x00000189, 0x00000411, 0x0000bd00, 0x00000000, 0x00bd0002, 0x00000000, 0xc5000261, 0x04000000,
0x52012107, 0x0000018a, 0x0000040c, 0x00013600, 0x00000000, 0x00c50002, 0x07030000, 0xbd000121,
0x00000000, 0x00026100, 0x00000124, 0x01210000, 0x00018b52, 0x00040c00, 0x00bd0000, 0x00000000,
0xbd000200, 0x00000000, 0x00026100, 0x000000c5, 0x01210702, 0x0000c500, 0x21070100, 0x018c5201,
0x04030000, 0xbd000000, 0x00000000, 0x00020000, 0x000000bd, 0x02610000, 0x00013600, 0x61000000,
0x018d5202, 0x04110000, 0xef000000, 0x00000000, 0x00020000, 0x000000bd, 0x02610000, 0x0000c500,
0x21070500, 0x01895201, 0x04110000, 0xc0000000, 0x00000000, 0x00020000, 0x000000c0, 0x02610000,
0x0000c500, 0x21070400, 0x018a5201, 0x040c0000, 0x37000000, 0x00000001, 0x00020000, 0x000000c5,
0x01210703, 0x0000c000, 0x61000000, 0x01240002, 0x00000000, 0x8b520121, 0x0c000001, 0x00000004,
0x000000c0, 0x02000000, 0x0000c000, 0x61000000, 0x00c50002, 0x07020000, 0xc5000121, 0x01000000,
0x52012107, 0x0000018c, 0x00000403, 0x0000c000, 0x00000000, 0x00c00002, 0x00000000, 0x37000261,
0x00000001, 0x52026100, 0x0000018d, 0x00000411, 0x0000f000, 0x00000000, 0x00c00002, 0x00000000,
0xc5000261, 0x05000000, 0x52012107, 0x00000189, 0x00000411, 0x0000c300, 0x00000000, 0x00c30002,
0x00000000, 0xc5000261, 0x04000000, 0x52012107, 0x0000018a, 0x0000040c, 0x00013800, 0x00000000,
0x00c50002, 0x07030000, 0xc3000121, 0x00000000, 0x00026100, 0x00000124, 0x01210000, 0x00018b52,
0x00040c00, 0x00c30000, 0x00000000, 0xc3000200, 0x00000000, 0x00026100, 0x000000c5, 0x01210702,
0x0000c500, 0x21070100, 0x018c5201, 0x04030000, 0xc3000000, 0x00000000, 0x00020000, 0x000000c3,
0x02610000, 0x00013800, 0x61000000, 0x018d5202, 0x04110000, 0xf1000000, 0x00000000, 0x00020000,
0x000000c3, 0x02610000, 0x0000c500, 0x21070500, 0x01895201, 0x04110000, 0xbb000000, 0x00000000,
0x00020000, 0x000000bb, 0x02610000, 0x0000c500, 0x21070400, 0x018a5201, 0x040c0000, 0x39000000,
0x00000001, 0x00020000, 0x000000c5, 0x01210703, 0x0000bb00, 0x61000000, 0x01240002, 0x00000000,
0x8b520121, 0x0c000001, 0x00000004, 0x000000bb, 0x02000000, 0x0000bb00, 0x61000000, 0x00c50002,
0x07020000, 0xc5000121, 0x01000000, 0x52012107, 0x0000018c, 0x00000403, 0x0000bb00, 0x00000000,
0x00bb0002, 0x00000000, 0x39000261, 0x00000001, 0x52026100, 0x0000018d, 0x00000411, 0x0000f200,
0x00000000, 0x00bb0002, 0x00000000, 0xc5000261, 0x05000000, 0x52012107, 0x00000189, 0x00000411,
0x0000be00, 0x00000000, 0x00be0002, 0x00000000, 0xc5000261, 0x04000000, 0x52012107, 0x0000018a,
0x0000040c, 0x00013a00, 0x00000000, 0x00c50002, 0x07030000, 0xbe000121, 0x00000000, 0x00026100,
0x00000124, 0x01210000, 0x00018b52, 0x00040c00, 0x00be0000, 0x00000000, 0xbe000200, 0x00000000,
0x00026100, 0x000000c5, 0x01210702, 0x0000c500, 0x21070100, 0x018c5201, 0x04030000, 0xbe000000,
0x00000000, 0x00020000, 0x000000be, 0x02610000, 0x00013a00, 0x61000000, 0x018d5202, 0x04110000,
0xf3000000, 0x00000000, 0x00020000, 0x000000be, 0x02610000, 0x0000c500, 0x21070500, 0x01895201,
0x04110000, 0xc1000000, 0x00000000, 0x00020000, 0x000000c1, 0x02610000, 0x0000c500, 0x21070400,
0x018a5201, 0x040c0000, 0x3b000000, 0x00000001, 0x00020000, 0x000000c5, 0x01210703, 0x0000c100,
0x61000000, 0x01240002, 0x00000000, 0x8b520121, 0x0c000001, 0x00000004, 0x000000c1, 0x02000000,
0x0000c100, 0x61000000, 0x00c50002, 0x07020000, 0xc5000121, 0x01000000, 0x52012107, 0x0000018c,
0x00000403, 0x0000c100, 0x00000000, 0x00c10002, 0x00000000, 0x3b000261, 0x00000001, 0x52026100,
0x0000018d, 0x00000411, 0x0000f400, 0x00000000, 0x00c10002, 0x00000000, 0xc5000261, 0x05000000,
0x52012107, 0x00000189, 0x00000411, 0x0000c400, 0x00000000, 0x00c40002, 0x00000000, 0xc5000261,
0x04000000, 0x52012107, 0x0000018a, 0x0000040c, 0x00013c00, 0x00000000, 0x00c50002, 0x07030000,
0xc4000121, 0x00000000, 0x00026100, 0x00000124, 0x01210000, 0x00018b52, 0x00040c00, 0x00c40000,
0x00000000, 0xc4000200, 0x00000000, 0x00026100, 0x000000c5, 0x01210702, 0x0000c500, 0x21070100,
0x018c5201, 0x04030000, 0xc4000000, 0x00000000, 0x00020000, 0x000000c4, 0x02610000, 0x00013c00,
0x61000000, 0x018d5202, 0x04110000, 0xf5000000, 0x00000000, 0x00020000, 0x000000c4, 0x02610000,
0x0000c500, 0x21070500, 0x00003201, 0x31000a00, 0x7d52000c, 0x29000001, 0x00000000, 0x000000c5,
0x02000701, 0x20b00705, 0x7e523b4d, 0x29000001, 0x00000000, 0x000000c5, 0x02000702, 0xb8520705,
0x7f52414e, 0x29000001, 0x00000000, 0x000000c5, 0x02000703, 0x0a3d0705, 0x80523f87, 0x29000001,
0x00000000, 0x000000c5, 0x02000704, 0x47ae0705, 0x8152bd61, 0x29000001, 0x00000000, 0x000000c5,
0x02000705, 0x55c50705, 0x00323ed5, 0x00090000, 0x2c000d31, 0x55020000, 0x01670000, 0x07000000,
0x01050121, 0x00000000, 0x80550032, 0x6f52000c, 0x29000001, 0x00000000, 0x000000c5, 0x02000701,
0xe5fb0705, 0x70523c93, 0x29000001, 0x00000000, 0x000000c5, 0x02000702, 0x00000705, 0x71524090,
0x29000001, 0x00000000, 0x000000c5, 0x02000703, 0xb5c40705, 0x72523f8c, 0x29000001, 0x00000000,
0x000000c5, 0x02000704, 0x5c3a0705, 0x7352bdcb, 0x29000001, 0x00000000, 0x000000c5, 0x02000705,
0x66660705, 0x74523ee6, 0x32000001, 0x09000000, 0x000e3100, 0x00008d52, 0x00002900, 0x013d0000,
0x00000000, 0x67000200, 0x06000001, 0x52012106, 0x0000010a, 0x00000029, 0x0000c500, 0x00060600,
0x00070502, 0x523e8000, 0x0000010b, 0x00000029, 0x0000c500, 0x00070600, 0x00070502, 0x523f2000,
0x0000010c, 0x00000029, 0x0000c500, 0x00060700, 0x00070502, 0x523e0000, 0x0000010f, 0x0200002c,
0x3d000056, 0x00000001, 0x05012100, 0x00000101, 0x56003200, 0x52000780, 0x00000115, 0x0202042c,
0x74000057, 0x00000000, 0x00026100, 0x00000081, 0x01210100, 0x0057042a, 0x00009b00, 0x00000000,
0x00820002, 0x01000000, 0x82000121, 0x00000000, 0x52012100, 0x00000116, 0x0202042c, 0x74000058,
0x00000000, 0x00026100, 0x00000081, 0x01210200, 0x0058042a, 0x00009b00, 0x00000000, 0x00820002,
0x02000000, 0x9b000121, 0x00000000, 0x52026100, 0x00000117, 0x0202042c, 0x74000059, 0x00000000,
0x00026100, 0x00000081, 0x01210300, 0x0059042a, 0x00009b00, 0x00000000, 0x00820002, 0x03000000,
0x9b000121, 0x00000000, 0x52026100, 0x00000118, 0x0202042c, 0x7400005a, 0x00000000, 0x00026100,
0x00000081, 0x01210400, 0x005a042a, 0x00009b00, 0x00000000, 0x00820002, 0x04000000, 0x9b000121,
0x00000000, 0x52026100, 0x00000119, 0x0202042c, 0x7400005b, 0x00000000, 0x00026100, 0x00000081,
0x01210500, 0x005b042a, 0x00009b00, 0x00000000, 0x00820002, 0x05000000, 0x9b000121, 0x00000000,
0x52026100, 0x0000011b, 0x0057042a, 0x00009c00, 0x00000000, 0x00830002, 0x01000000, 0x83000121,
0x00000000, 0x52012100, 0x0000011c, 0x0058042a, 0x00009c00, 0x00000000, 0x00830002, 0x02000000,
0x9c000121, 0x00000000, 0x52026100, 0x0000011d, 0x0059042a, 0x00009c00, 0x00000000, 0x00830002,
0x03000000, 0x9c000121, 0x00000000, 0x52026100, 0x0000011e, 0x005a042a, 0x00009c00, 0x00000000,
0x00830002, 0x04000000, 0x9c000121, 0x00000000, 0x52026100, 0x0000011f, 0x005b042a, 0x00009c00,
0x00000000, 0x00830002, 0x05000000, 0x9c000121, 0x00000000, 0x52026100, 0x00000120, 0x0000040c,
0x00009d00, 0x00000000, 0x009b0002, 0x00000000, 0x9d000261, 0x00000000, 0x00026100, 0x0000009c,
0x02610000, 0x0000040c, 0x00009f00, 0x00000000, 0x009b0002, 0x00000000, 0x9f000261, 0x00000000,
0x00026100, 0x0000009c, 0x02610000, 0x0000040c, 0x0000a100, 0x00000000, 0x009b0002, 0x00000000,
0xa1000261, 0x00000000, 0x00026100, 0x0000009c, 0x02610000, 0x0000040c, 0x0000a300, 0x00000000,
0x009b0002, 0x00000000, 0xa3000261, 0x00000000, 0x00026100, 0x0000009c, 0x02610000, 0x0000040c,
0x00009e00, 0x00000000, 0x009b0002, 0x00000000, 0x9e000261, 0x00000000, 0x00026100, 0x0000009c,
0x02610000, 0x0000040c, 0x0000a000, 0x00000000, 0x009b0002, 0x00000000, 0xa0000261, 0x00000000,
0x00026100, 0x0000009c, 0x02610000, 0x0000040c, 0x0000a200, 0x00000000, 0x009b0002, 0x00000000,
0xa2000261, 0x00000000, 0x00026100, 0x0000009c, 0x02610000, 0x0000040c, 0x0000a400, 0x00000000,
0x009b0002, 0x00000000, 0xa4000261, 0x00000000, 0x00026100, 0x0000009c, 0x02610000, 0x0000040c,
0x0000af00, 0x00000000, 0x009b0002, 0x00000000, 0x5f000261, 0x00000000, 0x00026100, 0x0000009c,
0x02610000, 0x0000040c, 0x0000b200, 0x00000000, 0x009b0002, 0x00000000, 0x61000261, 0x00000000,
0x00026100, 0x0000009c, 0x02610000, 0x0000040c, 0x0000b500, 0x00000000, 0x009b0002, 0x00000000,
0x63000261, 0x00000000, 0x00026100, 0x0000009c, 0x02610000, 0x0000040c, 0x0000b800, 0x00000000,
0x009b0002, 0x00000000, 0x65000261, 0x00000000, 0x00026100, 0x0000009c, 0x02610000, 0x0000040c,
0x0000a500, 0x00000000, 0x009b0002, 0x00000000, 0xa5000261, 0x00000000, 0x00026100, 0x0000009c,
0x02610000, 0x0000040c, 0x0000a700, 0x00000000, 0x009b0002, 0x00000000, 0xa7000261, 0x00000000,
0x00026100, 0x0000009c, 0x02610000, 0x0000040c, 0x0000a900, 0x00000000, 0x009b0002, 0x00000000,
0xa9000261, 0x00000000, 0x00026100, 0x0000009c, 0x02610000, 0x0000040c, 0x0000ab00, 0x00000000,
0x009b0002, 0x00000000, 0xab000261, 0x00000000, 0x00026100, 0x0000009c, 0x02610000, 0x0000040c,
0x0000a600, 0x00000000, 0x009b0002, 0x00000000, 0xa6000261, 0x00000000, 0x00026100, 0x0000009c,
0x02610000, 0x0000040c, 0x0000a800, 0x00000000, 0x009b0002, 0x00000000, 0xa8000261, 0x00000000,
0x00026100, 0x0000009c, 0x02610000, 0x0000040c, 0x0000aa00, 0x00000000, 0x009b0002, 0x00000000,
0xaa000261, 0x00000000, 0x00026100, 0x0000009c, 0x02610000, 0x0000040c, 0x0000ac00, 0x00000000,
0x009b0002, 0x00000000, 0xac000261, 0x00000000, 0x00026100, 0x0000009c, 0x02610000, 0x0000040c,
0x0000bb00, 0x00000000, 0x009b0002, 0x00000000, 0x6f000261, 0x00000000, 0x00026100, 0x0000009c,
0x02610000, 0x0000040c, 0x0000be00, 0x00000000, 0x009b0002, 0x00000000, 0x71000261, 0x00000000,
0x00026100, 0x0000009c, 0x02610000, 0x0000040c, 0x0000c100, 0x00000000, 0x009b0002, 0x00000000,
0x73000261, 0x00000000, 0x00026100, 0x0000009c, 0x02610000, 0x0000040c, 0x0000c400, 0x00000000,
0x009b0002, 0x00000000, 0x75000261, 0x00000000, 0x00026100, 0x0000009c, 0x02610000, 0x00000032,
0x0f310008, 0x01005200, 0x00290000, 0xc5000000, 0x06000000, 0x05020006, 0x86809d07, 0x0101523e,
0x00290000, 0xc5000000, 0x06000000, 0x05020007, 0x2d916807, 0x0102523f, 0x00290000, 0xc5000000,
0x07000000, 0x05020006, 0x72e48f07, 0x0103523d, 0x00320000, 0x00070000, 0x2c001031, 0x5c020000,
0x01670000, 0x06060000, 0x01050121, 0x00000002, 0x805c0032, 0xfb52000e, 0x29000000, 0x00000000,
0x000000c5, 0x02000606, 0x00000705, 0xfc523e80, 0x29000000, 0x00000000, 0x000000c5, 0x02000706,
0x00000705, 0xfd523f00, 0x29000000, 0x00000000, 0x000000c5, 0x02000607, 0x00000705, 0xfe523e80,
0x32000000, 0x07000000, 0x00113100, 0x0000c352, 0x00002900, 0x013e0000, 0x00000000, 0x07050200,
0x00000000, 0x0000c452, 0x00002900, 0x00810000, 0x01000000, 0x07050200, 0x3d00346e, 0x0000c552,
0x00002900, 0x013e0000, 0x01000000, 0x07050200, 0x3d00346e, 0x0000c652, 0x00000300, 0x013e0000,
0x05000000, 0xc5000200, 0x07000000, 0x05012107, 0x1c400007, 0x00c85246, 0x002c0000, 0x005d0202,
0x00007600, 0x21000000, 0x00770001, 0x00000000, 0x00320121, 0x0012005d, 0x0000c952, 0x00000300,
0x00810000, 0x02000000, 0xc5000200, 0x07000000, 0x05012107, 0x1c400007, 0x00cb5246, 0x00030000,
0x81000000, 0x00000000, 0x00020003, 0x000000c5, 0x01210707, 0x40000705, 0xcd52461c, 0x03000000,
0x00000000, 0x00000081, 0x02000400, 0x0000c500, 0x21070700, 0x00070501, 0x52461c40, 0x000000cf,
0x00000003, 0x00008100, 0x00050000, 0x00c50002, 0x07070000, 0x07050121, 0x461c4000, 0x0000d052,
0x00003200, 0x31000600, 0xd1520012, 0x03000000, 0x00000000, 0x00000081, 0x02000500, 0x0000c500,
0x21060700, 0x00070501, 0x52461c40, 0x000000d3, 0x00000010, 0x00013f00, 0x00000000, 0x00810002,
0x05000000, 0x07050121, 0x42000000, 0x00002152, 0x00002900, 0x01400000, 0x00000000, 0x3f000200,
0x00000001, 0x52012100, 0x00000022, 0x00000029, 0x00014100, 0x00000000, 0x01400002, 0x00000000,
0x002c0121, 0x005e0201, 0x00014100, 0x21000000, 0x013f0001, 0x00000000, 0x002a0121, 0x4200005e,
0x00000001, 0x05020000, 0x00000101, 0x00010500, 0x01000000, 0x00000000, 0x00000142, 0x02000000,
0x00014200, 0x21000000, 0x01400001, 0x00000000, 0xd3520121, 0x29000000, 0x00000000, 0x00000143,
0x02000000, 0x00014200, 0x21000000, 0x00001001, 0x00810000, 0x05000000, 0x43000200, 0x00000001,
0x05012100, 0x00000007, 0x00d5523d, 0x00010000, 0x44000000, 0x00000001, 0x00020000, 0x00000081,
0x01210500, 0x00008110, 0x21010000, 0x00000301, 0x01440000, 0x00000000, 0x44000200, 0x00000001,
0x05012100, 0xa0000007, 0x00000140, 0x00810000, 0x02000000, 0x81000200, 0x00000000, 0x00012101,
0x00000144, 0x01210000, 0x0000d652, 0x00000100, 0x01450000, 0x00000000, 0x81000200, 0x00000000,
0x10012105, 0x00000081, 0x01210100, 0x00000010, 0x00014500, 0x00000000, 0x01450002, 0x00000000,
0x07050121, 0x40000000, 0x00000003, 0x00014500, 0x00000000, 0x01450002, 0x00000000, 0x07050121,
0x40a00000, 0x00000001, 0x00008100, 0x00030000, 0x00810002, 0x01000000, 0x45000121, 0x00000001,
0x52012100, 0x000000d7, 0x00000001, 0x00014600, 0x00000000, 0x00810002, 0x05000000, 0x81100121,
0x00000000, 0x10012101, 0x00000000, 0x00000146, 0x02000000, 0x00014600, 0x21000000, 0x00070501,
0x03404000, 0x00000000, 0x00000146, 0x02000000, 0x00014600, 0x21000000, 0x00070501, 0x0140a000,
0x00000000, 0x00000081, 0x02000400, 0x00008100, 0x21010000, 0x01460001, 0x00000000, 0xda520121,
0x10000000, 0x00000000, 0x00000147, 0x02000000, 0x00008100, 0x21020000, 0x00070501, 0x52420000,
0x00000029, 0x00000029, 0x00014800, 0x00000000, 0x01470002, 0x00000000, 0xda520121, 0x29000000,
0x00000000, 0x00000149, 0x02000000, 0x00014800, 0x21000000, 0x00001001, 0x00810000, 0x02000000,
0x49000200, 0x00000001, 0x05012100, 0x00000007, 0x00db523d, 0x00100000, 0x4a000000, 0x00000001,
0x00020000, 0x00000081, 0x01210300, 0x00000705, 0x29524200, 0x29000000, 0x00000000, 0x0000014b,
0x02000000, 0x00014a00, 0x21000000, 0x00db5201, 0x00290000, 0x4c000000, 0x00000001, 0x00020000,
0x0000014b, 0x01210000, 0x00000010, 0x00008100, 0x00030000, 0x014c0002, 0x00000000, 0x07050121,
0x3d000000, 0x0000dc52, 0x00001000, 0x014d0000, 0x00000000, 0x81000200, 0x00000000, 0x05012104,
0x00000007, 0x00295242, 0x00290000, 0x4e000000, 0x00000001, 0x00020000, 0x0000014d, 0x01210000,
0x0000dc52, 0x00002900, 0x014f0000, 0x00000000, 0x4e000200, 0x00000001, 0x10012100, 0x00000000,
0x00000081, 0x02000400, 0x00014f00, 0x21000000, 0x00070501, 0x523d0000, 0x000000df, 0x00000010,
0x00013e00, 0x00040000, 0x013e0002, 0x05000000, 0x07050121, 0x3f733333, 0x0000e052, 0x02002c00,
0x00005f02, 0x0000013e, 0x01210400, 0x00008100, 0x21040000, 0x5f003201, 0x52001380, 0x000000e1,
0x00000029, 0x00013e00, 0x00040000, 0x00810002, 0x04000000, 0x13310121, 0x00e25200, 0x00010000,
0x50000000, 0x00000001, 0x00020000, 0x0000013e, 0x01210400, 0x00013e10, 0x21010000, 0x00002901,
0x01510000, 0x00000000, 0x07050200, 0x3f333333, 0x0000000c, 0x00013e00, 0x00020000, 0x01500002,
0x00000000, 0x51000121, 0x00000001, 0x00012100, 0x0000013e, 0x01210100, 0x0000e352, 0x02002c00,
0x00006002, 0x0000013e, 0x01210200, 0x00008100, 0x21020000, 0x60003201, 0x52001480, 0x000000e4,
0x00000029, 0x00013e00, 0x00020000, 0x00810002, 0x02000000, 0x14310121, 0x00e55200, 0x00010000,
0x52000000, 0x00000001, 0x00020000, 0x0000013e, 0x01210400, 0x00013e10, 0x21020000, 0x00000c01,
0x013e0000, 0x03000000, 0x52000200, 0x00000001, 0x00012100, 0x00000151, 0x01210000, 0x00013e00,
0x21020000, 0x00e65201, 0x002c0000, 0x00610202, 0x00013e00, 0x21030000, 0x00810001, 0x03000000,
0x00320121, 0x00158061, 0x0000e752, 0x00002900, 0x013e0000, 0x03000000, 0x81000200, 0x00000000,
0x31012103, 0xe9520015, 0x01000000, 0x00000000, 0x00000153, 0x02000000, 0x00008100, 0x21010000,
0x00811001, 0x00000000, 0x00290121, 0x54000000, 0x00000001, 0x05020000, 0x00000007, 0x02002c00,
0x00006202, 0x00000153, 0x01210000, 0x00000705, 0x00320000, 0x00168062, 0x00000001, 0x00015400,
0x00000000, 0x013e0002, 0x01000000, 0x3e100121, 0x00000001, 0x03012100, 0x00000000, 0x00000154,
0x02000000, 0x00015400, 0x21000000, 0x01530001, 0x00000000, 0x16310121, 0x00002900, 0x00820000,
0x00000000, 0x54000200, 0x00000001, 0x52012100, 0x000000ea, 0x00000001, 0x00015500, 0x00000000,
0x00810002, 0x02000000, 0x81100121, 0x00000000, 0x29012101, 0x00000000, 0x00000156, 0x02000000,
0x00000705, 0x002c0000, 0x00630202, 0x00015500, 0x21000000, 0x00070501, 0x32000000, 0x17806300,
0x00000100, 0x01560000, 0x00000000, 0x3e000200, 0x00000001, 0x10012102, 0x0000013e, 0x01210100,
0x00000003, 0x00015600, 0x00000000, 0x01560002, 0x00000000, 0x55000121, 0x00000001, 0x31012100,
0x00290017, 0x82000000, 0x00000000, 0x00020001, 0x00000156, 0x01210000, 0x0000eb52, 0x00000100,
0x01570000, 0x00000000, 0x81000200, 0x00000000, 0x10012103, 0x00000081, 0x01210200, 0x00000029,
0x00015800, 0x00000000, 0x00070502, 0x2c000000, 0x64020200, 0x01570000, 0x00000000, 0x07050121,
0x00000000, 0x80640032, 0x00010018, 0x58000000, 0x00000001, 0x00020000, 0x0000013e, 0x01210300,
0x00013e10, 0x21020000, 0x00000301, 0x01580000, 0x00000000, 0x58000200, 0x00000001, 0x00012100,
0x00000157, 0x01210000, 0x29001831, 0x00000000, 0x00000082, 0x02000200, 0x00015800, 0x21000000,
0x00ec5201, 0x00010000, 0x59000000, 0x00000001, 0x00020000, 0x00000081, 0x01210400, 0x00008110,
0x21030000, 0x00002901, 0x015a0000, 0x00000000, 0x07050200, 0x00000000, 0x0202002c, 0x59000065,
0x00000001, 0x05012100, 0x00000007, 0x65003200, 0x01001980, 0x00000000, 0x0000015a, 0x02000000,
0x00013e00, 0x21040000, 0x013e1001, 0x03000000, 0x00030121, 0x5a000000, 0x00000001, 0x00020000,
0x0000015a, 0x01210000, 0x00015900, 0x21000000, 0x00193101, 0x00000029, 0x00008200, 0x00030000,
0x015a0002, 0x00000000, 0xed520121, 0x01000000, 0x00000000, 0x0000015b, 0x02000000, 0x00008100,
0x21050000, 0x00811001, 0x04000000, 0x00290121, 0x5c000000, 0x00000001, 0x05020000, 0x00000007,
0x02002c00, 0x00006602, 0x0000015b, 0x01210000, 0x00000705, 0x00320000, 0x001a8066, 0x00000001,
0x00015c00, 0x00000000, 0x013e0002, 0x05000000, 0x3e100121, 0x00000001, 0x03012104, 0x00000000,
0x0000015c, 0x02000000, 0x00015c00, 0x21000000, 0x015b0001, 0x00000000, 0x1a310121, 0x00002900,
0x00820000, 0x04000000, 0x5c000200, 0x00000001, 0x52012100, 0x000000ee, 0x00000029, 0x00008200,
0x00050000, 0x00070502, 0x52000000, 0x000000f0, 0x0000000c, 0x00008300, 0x00000000, 0x00820002,
0x00000000, 0x81100121, 0x00000000, 0x00012100, 0x0000013e, 0x01210000, 0x0000f152, 0x00000c00,
0x00830000, 0x01000000, 0x82000200, 0x00000000, 0x10012101, 0x00000081, 0x01210100, 0x00013e00,
0x21010000, 0x00f25201, 0x000c0000, 0x83000000, 0x00000000, 0x00020002, 0x00000082, 0x01210200,
0x00008110, 0x21020000, 0x013e0001, 0x02000000, 0xf3520121, 0x0c000000, 0x00000000, 0x00000083,
0x02000300, 0x00008200, 0x21030000, 0x00811001, 0x03000000, 0x3e000121, 0x00000001, 0x52012103,
0x000000f4, 0x0000000c, 0x00008300, 0x00040000, 0x00820002, 0x04000000, 0x81100121, 0x00000000,
0x00012104, 0x0000013e, 0x01210400, 0x0000f552, 0x00000c00, 0x00830000, 0x05000000, 0x82000200,
0x00000000, 0x10012105, 0x00000081, 0x01210500, 0x00013e00, 0x21050000, 0x00003201, 0x05000600,
0x4c000000, 0x04402802, 0xff160000, 0x080fff0f, 0x4c000000, 0x04402c02, 0x0c160000, 0x05000c00,
0x4c000000, 0x2c204012, 0xff160000, 0x090fff0f, 0x28000000, 0x28204412, 0x041e0000, 0x09000400,
0x28000000, 0x40206012, 0x031e0000, 0x05000300, 0x28000000, 0x4420440a, 0xf00e0000, 0x050000ff,
0x28000000, 0x6028b40a, 0xf80e0000, 0x090000ff, 0x28000000, 0x4428b00a, 0x031e0000, 0x01000300,
0x2c006000, 0x0020804b, 0x00008d00, 0x01000000, 0x0c000000, 0x00208806, 0x1f000000, 0x01000300,
0x2c000000, 0xb020804b, 0x00000008, 0x01000000, 0x2c000000, 0xb420844b, 0x00000008, 0x40000000,
0x04000000, 0x20220002, 0x00060000, 0x31024900, 0x6c0c8000, 0x8020a04a, 0x00000000, 0x01000002,
0x08008000, 0xa0212043, 0x00008d00, 0x01000000, 0x08008000, 0xc0216043, 0x00008d00, 0x01000000,
0x08008000, 0xe021a043, 0x00008d00, 0x01000000, 0x08008000, 0x0021e043, 0x00008d01, 0x40000000,
0x28000000, 0xb028ac0a, 0x201e0008, 0x01002000, 0x2c000000, 0xac20804b, 0x00000008, 0x31000000,
0x6c0c8000, 0x8022204a, 0x00000000, 0x01000002, 0x08008000, 0x20214043, 0x00008d02, 0x01000000,
0x08008000, 0x40218043, 0x00008d02, 0x01000000, 0x08008000, 0x6021c043, 0x00008d02, 0x01000000,
0x08008000, 0x80220043, 0x00008d02, 0x40000000, 0x28000000, 0xb028a80a, 0x401e0008, 0x01004000,
0x2c000000, 0xa820804b, 0x00000008, 0x31000000, 0x6c0c8000, 0x8022a04a, 0x00000000, 0x01000002,
0x08008000, 0xa0204043, 0x00008d02, 0x01000000, 0x08008000, 0xc020a043, 0x00008d02, 0x01000000,
0x08008000, 0xe020e043, 0x00008d02, 0x01000000, 0x08008000, 0x00232043, 0x00008d03, 0x40000000,
0x28000000, 0xb028a40a, 0x601e0008, 0x01006000, 0x2c000000, 0xa420804b, 0x00000008, 0x31000000,
0x6c0c8000, 0x8023604a, 0x00000000, 0x01000002, 0x08008000, 0x60206043, 0x00008d03, 0x01000000,
0x08008000, 0x8020c043, 0x00008d03, 0x01000000, 0x08008000, 0xa0210043, 0x00008d03, 0x01000000,
0x08008000, 0xc0234043, 0x00008d03, 0x40000000, 0x28000000, 0xb428a00a, 0x041e0008, 0x01000400,
0x2c000000, 0xb020804b, 0x00000008, 0x01000000, 0x2c000000, 0xa020844b, 0x00000008, 0x31000000,
0x6c0c8000, 0x8022204a, 0x00000000, 0x01000002, 0x08008000, 0x2022a043, 0x00008d02, 0x01000000,
0x08008000, 0x4022e043, 0x00008d02, 0x01000000, 0x08008000, 0x6023e043, 0x00008d02, 0x01000000,
0x08008000, 0x80242043, 0x00008d02, 0x01000000, 0x2c000000, 0xac20804b, 0x00000008, 0x31000000,
0x6c0c8000, 0x8024604a, 0x00000000, 0x01000002, 0x08008000, 0x6022c043, 0x00008d04, 0x01000000,
0x08008000, 0x80230043, 0x00008d04, 0x01000000, 0x08008000, 0xa0240043, 0x00008d04, 0x01000000,
0x08008000, 0xc0244043, 0x00008d04, 0x01000000, 0x2c000000, 0xa820804b, 0x00000008, 0x31000000,
0x6c0c8000, 0x8023604a, 0x00000000, 0x01000002, 0x08008000, 0x6024e043, 0x00008d03, 0x01000000,
0x08008000, 0x80252043, 0x00008d03, 0x01000000, 0x08008000, 0xa0256043, 0x00008d03, 0x01000000,
0x08008000, 0xc0222043, 0x00008d03, 0x01000000, 0x2c000000, 0xa420804b, 0x00000008, 0x31000000,
0x6c0c8000, 0x8025a04a, 0x00000000, 0x01000002, 0x08008000, 0xa0250043, 0x00008d05, 0x01000000,
0x08008000, 0xc0254043, 0x00008d05, 0x01000000, 0x08008000, 0xe0258043, 0x00008d05, 0x01000000,
0x08008000, 0x00224043, 0x00008d06, 0x01000000, 0x48006000, 0x202a001a, 0x00006001, 0x01000000,
0x48006000, 0x402a101a, 0x00006000, 0x01000000, 0x48006000, 0x6027a01a, 0x00006001, 0x01000000,
0x48006000, 0xa027b01a, 0x00006000, 0x01000000, 0x48006000, 0xa029e01a, 0x00006001, 0x01000000,
0x48006000, 0xe029f01a, 0x00006000, 0x01000000, 0x48006000, 0xe029c01a, 0x00006001, 0x01000000,
0x48006000, 0x2029d01a, 0x00006003, 0x01000000, 0x48006000, 0xa022601a, 0x00006002, 0x01000000,
0x48006000, 0xe022701a, 0x00006004, 0x01000000, 0x48006000, 0xe022801a, 0x00006002, 0x01000000,
0x48006000, 0x2022901a, 0x00006005, 0x01000000, 0x48006000, 0xe023601a, 0x00006003, 0x01000000,
0x48006000, 0x6023701a, 0x00006005, 0x01000000, 0x48006000, 0x2023801a, 0x00006004, 0x01000000,
0x48006000, 0x2023901a, 0x00006002, 0x01000000, 0x48006000, 0x2223a01a, 0x00006001, 0x01000000,
0x48006000, 0x4223b01a, 0x00006000, 0x01000000, 0x48006000, 0x6223c01a, 0x00006001, 0x01000000,
0x48006000, 0xa223d01a, 0x00006000, 0x01000000, 0x48006000, 0xa224601a, 0x00006001, 0x01000000,
0x48006000, 0xe224701a, 0x00006000, 0x01000000, 0x48006000, 0xe224801a, 0x00006001, 0x01000000,
0x48006000, 0x2224901a, 0x00006003, 0x01000000, 0x48006000, 0xa224a01a, 0x00006002, 0x01000000,
0x48006000, 0xe224b01a, 0x00006004, 0x01000000, 0x48006000, 0xe224c01a, 0x00006002, 0x01000000,
0x48006000, 0x2224d01a, 0x00006005, 0x01000000, 0x48006000, 0xe225a01a, 0x00006003, 0x01000000,
0x48006000, 0x6225b01a, 0x00006005, 0x01000000, 0x48006000, 0x2225c01a, 0x00006004, 0x01000000,
0x48006000, 0x2225d01a, 0x00006002, 0x01000000, 0x48006000, 0x2425e01a, 0x00006001, 0x01000000,
0x48006000, 0x4425f01a, 0x00006000, 0x01000000, 0x48006000, 0x6426001a, 0x00006001, 0x01000000,
0x48006000, 0xa426101a, 0x00006000, 0x01000000, 0x48006000, 0xa426201a, 0x00006001, 0x01000000,
0x48006000, 0xe426301a, 0x00006000, 0x01000000, 0x48006000, 0xe426401a, 0x00006001, 0x01000000,
0x48006000, 0x2426501a, 0x00006003, 0x01000000, 0x48006000, 0xa426601a, 0x00006002, 0x01000000,
0x48006000, 0xe426701a, 0x00006004, 0x01000000, 0x48006000, 0xe426801a, 0x00006002, 0x01000000,
0x48006000, 0x2426901a, 0x00006005, 0x01000000, 0x48006000, 0xe421201a, 0x00006003, 0x01000000,
0x48006000, 0x6421301a, 0x00006005, 0x01000000, 0x48006000, 0x2420401a, 0x00006004, 0x01000000,
0x48006000, 0x2420501a, 0x00006002, 0x01000000, 0x28008000, 0x00242013, 0x00008d0a, 0x41000000,
0x28008000, 0x2024204b, 0x084e8d04, 0x01378020, 0x28008000, 0xa0232013, 0x00008d07, 0x41000000,
0x28008000, 0x2023204b, 0x084e8d03, 0x01378020, 0x28008000, 0xe022e013, 0x00008d09, 0x41000000,
0x28008000, 0xe022e04b, 0x084e8d02, 0x01378020, 0x28008000, 0xc022a013, 0x00008d09, 0x41000000,
0x28008000, 0xa022a04b, 0x084e8d02, 0x01378020, 0x28008000, 0xa023e013, 0x00008d03, 0x41000000,
0x28008000, 0xe023e04b, 0x084e8d03, 0x01378020, 0x28008000, 0xc024e013, 0x00008d03, 0x41000000,
0x28008000, 0xe024e04b, 0x084e8d04, 0x01378020, 0x28008000, 0x6023a013, 0x00008d04, 0x41000000,
0x28008000, 0xa023a04b, 0x084e8d03, 0x01378020, 0x28008000, 0x80246013, 0x00008d04, 0x41000000,
0x28008000, 0x6024604b, 0x084e8d04, 0x01378020, 0x28008000, 0xe0276013, 0x00008d05, 0x41000000,
0x28008000, 0x6027604b, 0x084e8d07, 0x01378020, 0x28008000, 0x00272013, 0x00008d06, 0x41000000,
0x28008000, 0x2027204b, 0x084e8d07, 0x01378020, 0x28008000, 0x2026e013, 0x00008d06, 0x41000000,
0x28008000, 0xe026e04b, 0x084e8d06, 0x01378020, 0x28008000, 0x4026a013, 0x00008d06, 0x41000000,
0x28008000, 0xa026a04b, 0x084e8d06, 0x01378020, 0x28008000, 0x6025e013, 0x00008d02, 0x41000000,
0x28008000, 0xe025e04b, 0x084e8d05, 0x01378020, 0x28008000, 0x80262013, 0x00008d02, 0x41000000,
0x28008000, 0x2026204b, 0x084e8d06, 0x01378020, 0x28008000, 0x6027e013, 0x00008d03, 0x41000000,
0x28008000, 0xe027e04b, 0x084e8d07, 0x01378020, 0x28008000, 0x80282013, 0x00008d03, 0x41000000,
0x28008000, 0x2028204b, 0x084e8d08, 0x01378020, 0x28008000, 0xa0286013, 0x00008d04, 0x41000000,
0x28008000, 0x6028604b, 0x084e8d08, 0x01378020, 0x28008000, 0xc024a013, 0x00008d04, 0x41000000,
0x28008000, 0xa024a04b, 0x084e8d04, 0x01378020, 0x28008000, 0xa028c013, 0x00008d05, 0x41000000,
0x28008000, 0xc028c04b, 0x084e8d08, 0x01378020, 0x28008000, 0xc025a013, 0x00008d05, 0x41000000,
0x28008000, 0xa025a04b, 0x084e8d05, 0x01378020, 0x28008000, 0x60298013, 0x00008d06, 0x41000000,
0x28008000, 0x8029804b, 0x084e8d09, 0x01378020, 0x28008000, 0x80236013, 0x00008d06, 0x41000000,
0x28008000, 0x6023604b, 0x084e8d03, 0x01378020, 0x28008000, 0x20294013, 0x00008d01, 0x41000000,
0x28008000, 0x4029404b, 0x084e8d09, 0x01378020, 0x28008000, 0x40266013, 0x00008d00, 0x41000000,
0x28008000, 0x6026604b, 0x084e8d06, 0x01378020, 0x0c000000, 0x00208806, 0x1f000000, 0x01000700,
0x0c000000, 0x00208016, 0x00000000, 0x01000000, 0x0c000000, 0x00208416, 0x00000000, 0x40000000,
0x04000000, 0x24220002, 0x00060000, 0x31028900, 0x2c0c6000, 0x8021804b, 0x00000000, 0x01000002,
0x28000000, 0x0021d84f, 0x00000000, 0x014196d0, 0x28000000, 0x0021f84f, 0x00000000, 0x01c19580,
0x28000000, 0x0022184f, 0x6b000000, 0x0140c8e0, 0x28000000, 0x0022384f, 0xac000000, 0x383c4fcd,
0x280a8000, 0x2024204b, 0x384a8d04, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x5b000000,
0x08008000, 0x01020040, 0x420720ec, 0x4003f004, 0x28008000, 0x2024204b, 0x004e8d04, 0x02bf5600,
0x28048000, 0x2024204b, 0x004e8d04, 0x38000000, 0x28098000, 0x2024204b, 0x404a8d04, 0x7e008d00,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x2024204b, 0x184a8d04, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x2023204b, 0x384a8d03, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x5b000000, 0x08008000, 0x01050040, 0x320720ec, 0x4003f004,
0x28008000, 0x2023204b, 0x004e8d03, 0x02bf5600, 0x28048000, 0x2023204b, 0x004e8d03, 0x38000000,
0x28098000, 0x2023204b, 0xa04a8d03, 0x7e008d00, 0x00000000, 0x00000000, 0x00000000, 0x38000000,
0x280a8000, 0x2023204b, 0x184a8d03, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x38000000,
0x280a8000, 0xe022e04b, 0x384a8d02, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x5b000000,
0x08008000, 0x01070040, 0x2e0720ec, 0x4003f004, 0x28008000, 0xe022e04b, 0x004e8d02, 0x02bf5600,
0x28048000, 0xe022e04b, 0x004e8d02, 0x38000000, 0x28098000, 0xe022e04b, 0xe04a8d02, 0x7e008d00,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0xe022e04b, 0x184a8d02, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0xa022a04b, 0x384a8d02, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x5b000000, 0x08008000, 0x01020040, 0x2a0720ec, 0x4003f004,
0x28008000, 0xa022a04b, 0x004e8d02, 0x02bf5600, 0x28048000, 0xa022a04b, 0x004e8d02, 0x38000000,
0x28098000, 0xa022a04b, 0x404a8d02, 0x7e008d00, 0x00000000, 0x00000000, 0x00000000, 0x38000000,
0x280a8000, 0xa022a04b, 0x184a8d02, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x38000000,
0x280a8000, 0xe023e04b, 0x384a8d03, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x5b000000,
0x08008000, 0x01040040, 0x3e0720ec, 0x4003f004, 0x28008000, 0xe023e04b, 0x004e8d03, 0x02bf5600,
0x28048000, 0xe023e04b, 0x004e8d03, 0x38000000, 0x28098000, 0xe023e04b, 0x804a8d03, 0x7e008d00,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0xe023e04b, 0x184a8d03, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0xe024e04b, 0x384a8d04, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x5b000000, 0x08008000, 0x01060040, 0x4e0720ec, 0x4003f004,
0x28008000, 0xe024e04b, 0x004e8d04, 0x02bf5600, 0x28048000, 0xe024e04b, 0x004e8d04, 0x38000000,
0x28098000, 0xe024e04b, 0xc04a8d04, 0x7e008d00, 0x00000000, 0x00000000, 0x00000000, 0x38000000,
0x280a8000, 0xe024e04b, 0x184a8d04, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x38000000,
0x280a8000, 0xa023a04b, 0x384a8d03, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x5b000000,
0x08008000, 0x01020040, 0x3a0720ec, 0x4003f004, 0x28008000, 0xa023a04b, 0x004e8d03, 0x02bf5600,
0x28048000, 0xa023a04b, 0x004e8d03, 0x38000000, 0x28098000, 0xa023a04b, 0x404a8d03, 0x7e008d00,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0xa023a04b, 0x184a8d03, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x6024604b, 0x384a8d04, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x5b000000, 0x08008000, 0x01040040, 0x460720ec, 0x4003f004,
0x28008000, 0x6024604b, 0x004e8d04, 0x02bf5600, 0x28048000, 0x6024604b, 0x004e8d04, 0x38000000,
0x28098000, 0x6024604b, 0x804a8d04, 0x7e008d00, 0x00000000, 0x00000000, 0x00000000, 0x38000000,
0x280a8000, 0x6024604b, 0x184a8d04, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x38000000,
0x280a8000, 0x6027604b, 0x384a8d07, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x5b000000,
0x08008000, 0x01060040, 0x760720ec, 0x4003f004, 0x28008000, 0x6027604b, 0x004e8d07, 0x02bf5600,
0x28048000, 0x6027604b, 0x004e8d07, 0x38000000, 0x28098000, 0x6027604b, 0xc04a8d07, 0x7e008d00,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x6027604b, 0x184a8d07, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x2027204b, 0x384a8d07, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x5b000000, 0x08008000, 0x01020040, 0x720720ec, 0x4003f004,
0x28008000, 0x2027204b, 0x004e8d07, 0x02bf5600, 0x28048000, 0x2027204b, 0x004e8d07, 0x38000000,
0x28098000, 0x2027204b, 0x404a8d07, 0x7e008d00, 0x00000000, 0x00000000, 0x00000000, 0x38000000,
0x280a8000, 0x2027204b, 0x184a8d07, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x38000000,
0x280a8000, 0xe026e04b, 0x384a8d06, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x5b000000,
0x08008000, 0x01040040, 0x6e0720ec, 0x4003f004, 0x28008000, 0xe026e04b, 0x004e8d06, 0x02bf5600,
0x28048000, 0xe026e04b, 0x004e8d06, 0x38000000, 0x28098000, 0xe026e04b, 0x804a8d06, 0x7e008d00,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0xe026e04b, 0x184a8d06, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0xa026a04b, 0x384a8d06, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x5b000000, 0x08008000, 0x01060040, 0x6a0720ec, 0x4003f004,
0x28008000, 0xa026a04b, 0x004e8d06, 0x02bf5600, 0x28048000, 0xa026a04b, 0x004e8d06, 0x38000000,
0x28098000, 0xa026a04b, 0xc04a8d06, 0x7e008d00, 0x00000000, 0x00000000, 0x00000000, 0x38000000,
0x280a8000, 0xa026a04b, 0x184a8d06, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x38000000,
0x280a8000, 0xe025e04b, 0x384a8d05, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x5b000000,
0x08008000, 0x01020040, 0x5e0720ec, 0x4003f004, 0x28008000, 0xe025e04b, 0x004e8d05, 0x02bf5600,
0x28048000, 0xe025e04b, 0x004e8d05, 0x38000000, 0x28098000, 0xe025e04b, 0x404a8d05, 0x7e008d00,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0xe025e04b, 0x184a8d05, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x2026204b, 0x384a8d06, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x5b000000, 0x08008000, 0x01040040, 0x620720ec, 0x4003f004,
0x28008000, 0x2026204b, 0x004e8d06, 0x02bf5600, 0x28048000, 0x2026204b, 0x004e8d06, 0x38000000,
0x28098000, 0x2026204b, 0x804a8d06, 0x7e008d00, 0x00000000, 0x00000000, 0x00000000, 0x38000000,
0x280a8000, 0x2026204b, 0x184a8d06, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x38000000,
0x280a8000, 0xe027e04b, 0x384a8d07, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x5b000000,
0x08008000, 0x01060040, 0x7e0720ec, 0x4003f004, 0x28008000, 0xe027e04b, 0x004e8d07, 0x02bf5600,
0x28048000, 0xe027e04b, 0x004e8d07, 0x38000000, 0x28098000, 0xe027e04b, 0xc04a8d07, 0x7e008d00,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0xe027e04b, 0x184a8d07, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x2028204b, 0x384a8d08, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x5b000000, 0x08008000, 0x01020040, 0x820720ec, 0x4003f004,
0x28008000, 0x2028204b, 0x004e8d08, 0x02bf5600, 0x28048000, 0x2028204b, 0x004e8d08, 0x38000000,
0x28098000, 0x2028204b, 0x404a8d08, 0x7e008d00, 0x00000000, 0x00000000, 0x00000000, 0x38000000,
0x280a8000, 0x2028204b, 0x184a8d08, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x38000000,
0x280a8000, 0x6028604b, 0x384a8d08, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x5b000000,
0x08008000, 0x01040040, 0x860720ec, 0x4003f004, 0x28008000, 0x6028604b, 0x004e8d08, 0x02bf5600,
0x28048000, 0x6028604b, 0x004e8d08, 0x38000000, 0x28098000, 0x6028604b, 0x804a8d08, 0x7e008d00,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x6028604b, 0x184a8d08, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0xa024a04b, 0x384a8d04, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x5b000000, 0x08008000, 0x01060040, 0x4a0720ec, 0x4003f004,
0x28008000, 0xa024a04b, 0x004e8d04, 0x02bf5600, 0x28048000, 0xa024a04b, 0x004e8d04, 0x38000000,
0x28098000, 0xa024a04b, 0xc04a8d04, 0x7e008d00, 0x00000000, 0x00000000, 0x00000000, 0x38000000,
0x280a8000, 0xa024a04b, 0x184a8d04, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x38000000,
0x280a8000, 0xc028c04b, 0x384a8d08, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x5b000000,
0x08008000, 0x01020040, 0x8c0720ec, 0x4003f004, 0x28008000, 0xc028c04b, 0x004e8d08, 0x02bf5600,
0x28048000, 0xc028c04b, 0x004e8d08, 0x38000000, 0x28098000, 0xc028c04b, 0x404a8d08, 0x7e008d00,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0xc028c04b, 0x184a8d08, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0xa025a04b, 0x384a8d05, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x5b000000, 0x08008000, 0x01040040, 0x5a0720ec, 0x4003f004,
0x28008000, 0xa025a04b, 0x004e8d05, 0x02bf5600, 0x28048000, 0xa025a04b, 0x004e8d05, 0x38000000,
0x28098000, 0xa025a04b, 0x804a8d05, 0x7e008d00, 0x00000000, 0x00000000, 0x00000000, 0x38000000,
0x280a8000, 0xa025a04b, 0x184a8d05, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x38000000,
0x280a8000, 0x8029804b, 0x384a8d09, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x5b000000,
0x08008000, 0x01060040, 0x980720ec, 0x4003f004, 0x28008000, 0x8029804b, 0x004e8d09, 0x02bf5600,
0x28048000, 0x8029804b, 0x004e8d09, 0x38000000, 0x28098000, 0x8029804b, 0xc04a8d09, 0x7e008d00,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x8029804b, 0x184a8d09, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x6023604b, 0x384a8d03, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x5b000000, 0x08008000, 0x01020040, 0x360720ec, 0x4003f004,
0x28008000, 0x6023604b, 0x004e8d03, 0x02bf5600, 0x28048000, 0x6023604b, 0x004e8d03, 0x38000000,
0x28098000, 0x6023604b, 0x404a8d03, 0x7e008d00, 0x00000000, 0x00000000, 0x00000000, 0x38000000,
0x280a8000, 0x6023604b, 0x184a8d03, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x38000000,
0x280a8000, 0x4029404b, 0x384a8d09, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x5b000000,
0x08008000, 0x01040040, 0x940720ec, 0x4003f004, 0x28008000, 0x4029404b, 0x004e8d09, 0x02bf5600,
0x28048000, 0x4029404b, 0x004e8d09, 0x38000000, 0x28098000, 0x4029404b, 0x804a8d09, 0x7e008d00,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x4029404b, 0x184a8d09, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x6026604b, 0x384a8d06, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x5b000000, 0x08008000, 0x01290040, 0x660720ec, 0x4003f004,
0x28008000, 0x6026604b, 0x004e8d06, 0x02bf5600, 0x28048000, 0x6026604b, 0x004e8d06, 0x38000000,
0x28098000, 0x6026604b, 0x204a8d06, 0x7e008d05, 0x00000000, 0x00000000, 0x00000000, 0x38000000,
0x280a8000, 0x6026604b, 0x184a8d06, 0x38000002, 0x28090000, 0x7820284b, 0x004e0002, 0x38461c40,
0x28090000, 0x7c20244b, 0x004e0002, 0x01461c40, 0x28000000, 0x002a004f, 0x00000000, 0x10000000,
0x20010000, 0x5c20000a, 0x011e0002, 0x20000100, 0x04001100, 0x00340000, 0xa00e0014, 0x01000043,
0x28030000, 0x002a044f, 0x00000000, 0x013d0000, 0x28000000, 0x002a084f, 0x00000000, 0x013dc000,
0x28000000, 0x002a0c4f, 0x00000000, 0x013e0000, 0x28000000, 0x002a104f, 0x00000000, 0x013e6000,
0x28000000, 0x002a144f, 0x00000000, 0x013ed000, 0x28000000, 0x0027a04f, 0x00000000, 0x01000000,
0x28000000, 0x0027a44f, 0x33000000, 0x013f3333, 0x28000000, 0x0027a84f, 0x66000000, 0x013f6666,
0x28000000, 0x0027ac4f, 0x33000000, 0x013f7333, 0x28000000, 0x0027b04f, 0xa4000000, 0x013f7d70,
0x28000000, 0x0027b44f, 0x00000000, 0x013f8000, 0x28000000, 0x0020244f, 0x00000000, 0x20000000,
0x04001100, 0x00340000, 0x100e0014, 0x38000000, 0x28090000, 0xa420244b, 0x044a0007, 0x0100000a,
0x28000000, 0x2429e04b, 0x00000000, 0x41000000, 0x28000000, 0xe027a44b, 0x044a0009, 0x4000000a,
0x28030000, 0x0820284b, 0x044a000a, 0x0100004a, 0x28000000, 0x0020244f, 0x00000000, 0x20000000,
0x04001100, 0x00340000, 0x200e0014, 0x40000000, 0x28000000, 0xa820244b, 0xa44a0007, 0x38000047,
0x28090000, 0x2420244b, 0x284a0000, 0x01000000, 0x28000000, 0x2429e44b, 0x00000000, 0x5b000000,
0x08000000, 0x013d4040, 0x028023d2, 0x4013c804, 0x28030000, 0x0c20244b, 0x084a000a, 0x0100004a,
0x28000000, 0x0020284f, 0x00000000, 0x20000000, 0x04001100, 0x00340000, 0x200e0014, 0x40000000,
0x28000000, 0xac20284b, 0xa84a0007, 0x38000047, 0x28090000, 0x2820284b, 0x244a0000, 0x01000000,
0x28000000, 0x2829e84b, 0x00000000, 0x5b000000, 0x0c000000, 0x01020040, 0x024023d4, 0x0113d004,
0x28000000, 0x4027ac4b, 0x00000000, 0x40000000, 0x28030000, 0x1020244b, 0x0c4a000a, 0x0100004a,
0x28000000, 0x0020284f, 0x00000000, 0x20000000, 0x04001100, 0x00340000, 0x200e0014, 0x40000000,
0x28000000, 0xb020284b, 0xac4a0007, 0x38000047, 0x28090000, 0x2820284b, 0x244a0000, 0x01000000,
0x28000000, 0x2829ec4b, 0x00000000, 0x5b000000, 0x08000000, 0x013d8040, 0x024023d6, 0x4013d804,
0x28030000, 0x1420284b, 0x104a000a, 0x0100004a, 0x28000000, 0x0020244f, 0x00000000, 0x20000000,
0x04001100, 0x00340000, 0x200e0014, 0x40000000, 0x28000000, 0xb420244b, 0xb04a0007, 0x38000047,
0x28090000, 0x2420244b, 0x284a0000, 0x01000000, 0x28000000, 0x2429f04b, 0x00000000, 0x01000000,
0x28000000, 0x0029f44f, 0x00000000, 0x01000000, 0x28000000, 0x0029c04f, 0x00000000, 0x5b000000,
0x0c000000, 0x01020041, 0xa04023d2, 0x0113c804, 0x28000000, 0x4029c44b, 0x00000000, 0x5b000000,
0x08000000, 0x014e4041, 0xa08023d4, 0x5b13d004, 0x0c000000, 0x01030041, 0xa0c023d6, 0x0113d804,
0x28000000, 0x6029cc4b, 0x00000000, 0x5b000000, 0x08000000, 0x014e8041, 0xa10023d8, 0x0113e004,
0x28000000, 0x0029d44f, 0x00000000, 0x103f8000, 0x20050000, 0x5820000a, 0x031e0002, 0x20000300,
0x04000100, 0x00340000, 0xd00e0014, 0x1000003f, 0x20050000, 0x5820000a, 0x041e0002, 0x20000400,
0x04000100, 0x00340000, 0x700e0014, 0x1000003f, 0x20010000, 0x5820000a, 0x041e0002, 0x20000400,
0x04001100, 0x00340000, 0x400e0014, 0x0100003c, 0x28000000, 0x0022584f, 0xd0000000, 0x013e59b3,
0x28000000, 0x00225c4f, 0x59000000, 0x013f3717, 0x28000000, 0x0022784f, 0x98000000, 0x413d93dd,
0x28008000, 0x5c20404b, 0xe04a0002, 0x5b008d03, 0x08008000, 0x39020040, 0x42072020, 0x5b04b004,
0x08008000, 0x39020040, 0x76072020, 0x1004f004, 0x20038000, 0x4020004b, 0x044a8d00, 0x0200000a,
0x28008100, 0xe429004b, 0xe04a0009, 0x10000009, 0x21038000, 0x4020004b, 0x084a8d00, 0x0100000a,
0x4c000000, 0x02202810, 0x00000006, 0x02000000, 0x29008100, 0xe829004b, 0x004a0009, 0x10008d09,
0x23038000, 0x4020004b, 0x0c4a8d00, 0x0200000a, 0x2b008100, 0xec29004b, 0x004a0009, 0x10008d09,
0x22038000, 0x4020004b, 0x104a8d00, 0x0200000a, 0x2a008100, 0xf029004b, 0x004a0009, 0x10008d09,
0x21038000, 0x4020004b, 0x144a8d00, 0x0200000a, 0x29008100, 0xf429004b, 0x004a0009, 0x02008d09,
0x28008100, 0xc420804b, 0xc04a0009, 0x01000009, 0x44000000, 0x28260012, 0x00000000, 0x02000000,
0x28008100, 0xc820804b, 0x804a0009, 0x02008d00, 0x2b008100, 0xcc20804b, 0x804a0009, 0x02008d00,
0x2a008100, 0xd020804b, 0x804a0009, 0x02008d00, 0x29008100, 0xd420804b, 0x804a0009, 0x5b008d00,
0x08008000, 0x39480040, 0x90072040, 0x38008084, 0x28018000, 0x4020c04b, 0x00008d00, 0x41000000,
0x28008000, 0x0029004b, 0xc04a8d09, 0x10008d00, 0x20018000, 0x4020004b, 0x004e8d00, 0x02000000,
0x28009100, 0x0029004b, 0x004e8d09, 0x41000000, 0x28008000, 0x2024204b, 0x004a8d04, 0x02008d09,
0x28058000, 0x2024204b, 0x004e8d04, 0x413f8000, 0x28008000, 0x0023e04b, 0xe04a8d09, 0x02008d03,
0x28058000, 0xe023e04b, 0x004e8d03, 0x413f8000, 0x28008000, 0x0029004b, 0x604a8d09, 0x02008d07,
0x28058000, 0x0029004b, 0x004e8d09, 0x413f8000, 0x28008000, 0x5c21404b, 0xe04a0002, 0x5b008d04,
0x08008000, 0x390a0040, 0x320720a0, 0x5b04b004, 0x08008000, 0x390a0040, 0x720720a0, 0x1004f004,
0x20038000, 0x4020004b, 0x044a8d01, 0x0200000a, 0x28008100, 0xe427a04b, 0xe04a0009, 0x10000009,
0x21038000, 0x4020004b, 0x084a8d01, 0x0100000a, 0x4c000000, 0x02202810, 0x00000006, 0x02000000,
0x29008100, 0xe827a04b, 0xa04a0009, 0x10008d07, 0x22038000, 0x4020004b, 0x0c4a8d01, 0x0200000a,
0x2a008100, 0xec27a04b, 0xa04a0009, 0x10008d07, 0x21038000, 0x4020004b, 0x104a8d01, 0x0200000a,
0x29008100, 0xf027a04b, 0xa04a0009, 0x10008d07, 0x23038000, 0x4020004b, 0x144a8d01, 0x0100000a,
0x4c000000, 0x22202a10, 0x00000006, 0x02000000, 0x2b008100, 0xf427a04b, 0xa04a0009, 0x02008d07,
0x28008100, 0xc420404b, 0xc04a0009, 0x01000009, 0x44000000, 0x28260012, 0x00000000, 0x02000000,
0x28008100, 0xc820404b, 0x404a0009, 0x02008d00, 0x2a008100, 0xcc20404b, 0x404a0009, 0x02008d00,
0x29008100, 0xd020404b, 0x404a0009, 0x01008d00, 0x44000000, 0x2a260012, 0x00000000, 0x02000000,
0x28008100, 0xd420404b, 0x404a0009, 0x5b008d00, 0x08008000, 0x393d0040, 0x7a072020, 0x38028084,
0x28018000, 0x4020804b, 0x00008d01, 0x41000000, 0x28008000, 0xa027a04b, 0x804a8d07, 0x10008d00,
0x20018000, 0x4020004b, 0x004e8d01, 0x02000000, 0x28009100, 0xa027a04b, 0x004e8d07, 0x41000000,
0x28008000, 0x2023204b, 0xa04a8d03, 0x02008d07, 0x28058000, 0x2023204b, 0x004e8d03, 0x413f8000,
0x28008000, 0xa024e04b, 0xe04a8d07, 0x02008d04, 0x28058000, 0xe024e04b, 0x004e8d04, 0x413f8000,
0x28008000, 0xa027a04b, 0x204a8d07, 0x02008d07, 0x28058000, 0xa027a04b, 0x004e8d07, 0x413f8000,
0x28008000, 0x5c20c04b, 0xa04a0002, 0x5b008d03, 0x08008000, 0x39060040, 0x2e072060, 0x5b04b004,
0x08008000, 0x39060040, 0x6e072060, 0x1004f004, 0x22038000, 0xc020004b, 0x044a8d00, 0x0200000a,
0x2a008100, 0xe427604b, 0xe04a0009, 0x10000009, 0x21038000, 0xc020004b, 0x084a8d00, 0x0200000a,
0x29008100, 0xe827604b, 0x604a0009, 0x10008d07, 0x20038000, 0xc020004b, 0x0c4a8d00, 0x0200000a,
0x28008100, 0xec27604b, 0x604a0009, 0x10008d07, 0x23038000, 0xc020004b, 0x104a8d00, 0x0100000a,
0x4c000000, 0x22202810, 0x00000006, 0x02000000, 0x2b008100, 0xf027604b, 0x604a0009, 0x10008d07,
0x23038000, 0xc020004b, 0x144a8d00, 0x0100000a, 0x4c000000, 0x22202a10, 0x00000006, 0x02000000,
0x2b008100, 0xf427604b, 0x604a0009, 0x02008d07, 0x2a008100, 0xc420404b, 0xc04a0009, 0x02000009,
0x29008100, 0xc820404b, 0x404a0009, 0x02008d00, 0x28008100, 0xcc20404b, 0x404a0009, 0x01008d00,
0x44000000, 0x28260012, 0x00000000, 0x02000000, 0x28008100, 0xd020404b, 0x404a0009, 0x01008d00,
0x44000000, 0x2a260012, 0x00000000, 0x02000000, 0x28008100, 0xd420404b, 0x404a0009, 0x5b008d00,
0x08008000, 0x393b0040, 0x76072020, 0x38018084, 0x28018000, 0xc020804b, 0x00008d00, 0x41000000,
0x28008000, 0x6027604b, 0x804a8d07, 0x10008d00, 0x20018000, 0xc020004b, 0x004e8d00, 0x02000000,
0x28009100, 0x6027604b, 0x004e8d07, 0x41000000, 0x28008000, 0xe022e04b, 0x604a8d02, 0x02008d07,
0x28058000, 0xe022e04b, 0x004e8d02, 0x413f8000, 0x28008000, 0x6023a04b, 0xa04a8d07, 0x02008d03,
0x28058000, 0xa023a04b, 0x004e8d03, 0x413f8000, 0x28008000, 0x6027604b, 0xe04a8d07, 0x02008d06,
0x28058000, 0x6027604b, 0x004e8d07, 0x413f8000, 0x28008000, 0x5c21404b, 0x604a0002, 0x5b008d04,
0x08008000, 0x390a0040, 0x2a0720a0, 0x5b04b004, 0x08008000, 0x390a0040, 0x6a0720a0, 0x1004f004,
0x22038000, 0x4020004b, 0x044a8d01, 0x0200000a, 0x2a008100, 0xe427204b, 0xe04a0009, 0x10000009,
0x21038000, 0x4020004b, 0x084a8d01, 0x0200000a, 0x29008100, 0xe827204b, 0x204a0009, 0x10008d07,
0x20038000, 0x4020004b, 0x0c4a8d01, 0x0200000a, 0x28008100, 0xec27204b, 0x204a0009, 0x10008d07,
0x23038000, 0x4020004b, 0x104a8d01, 0x0100000a, 0x4c000000, 0x22202810, 0x00000006, 0x02000000,
0x2b008100, 0xf027204b, 0x204a0009, 0x10008d07, 0x23038000, 0x4020004b, 0x144a8d01, 0x0100000a,
0x4c000000, 0x22202a10, 0x00000006, 0x02000000, 0x2b008100, 0xf427204b, 0x204a0009, 0x02008d07,
0x2a008100, 0xc420404b, 0xc04a0009, 0x02000009, 0x29008100, 0xc820404b, 0x404a0009, 0x02008d00,
0x28008100, 0xcc20404b, 0x404a0009, 0x01008d00, 0x44000000, 0x28260012, 0x00000000, 0x02000000,
0x28008100, 0xd020404b, 0x404a0009, 0x01008d00, 0x44000000, 0x2a260012, 0x00000000, 0x02000000,
0x28008100, 0xd420404b, 0x404a0009, 0x5b008d00, 0x08008000, 0x39390040, 0x72072020, 0x38028084,
0x28018000, 0x4020804b, 0x00008d01, 0x41000000, 0x28008000, 0x2027204b, 0x804a8d07, 0x10008d00,
0x20018000, 0x4020004b, 0x004e8d01, 0x02000000, 0x28009100, 0x2027204b, 0x004e8d07, 0x41000000,
0x28008000, 0xa022a04b, 0x204a8d02, 0x02008d07, 0x28058000, 0xa022a04b, 0x004e8d02, 0x413f8000,
0x28008000, 0x2024604b, 0x604a8d07, 0x02008d04, 0x28058000, 0x6024604b, 0x004e8d04, 0x413f8000,
0x28008000, 0x2027204b, 0xa04a8d07, 0x02008d06, 0x28058000, 0x2027204b, 0x004e8d07, 0x413f8000,
0x28008000, 0x5c20c04b, 0x604a0002, 0x5b008d08, 0x08008000, 0x39060040, 0x5e072060, 0x5b04b004,
0x08008000, 0x39060040, 0x98072060, 0x1004f004, 0x21038000, 0xc020004b, 0x044a8d00, 0x0200000a,
0x29008100, 0xe426e04b, 0xe04a0009, 0x10000009, 0x20038000, 0xc020004b, 0x084a8d00, 0x0200000a,
0x28008100, 0xe826e04b, 0xe04a0009, 0x10008d06, 0x22038000, 0xc020004b, 0x0c4a8d00, 0x0100000a,
0x4c000000, 0x20202810, 0x00000006, 0x02000000, 0x2a008100, 0xec26e04b, 0xe04a0009, 0x10008d06,
0x22038000, 0xc020004b, 0x104a8d00, 0x0200000a, 0x2a008100, 0xf026e04b, 0xe04a0009, 0x10008d06,
0x23038000, 0xc020004b, 0x144a8d00, 0x0100000a, 0x4c000000, 0x22202a10, 0x00000006, 0x02000000,
0x2b008100, 0xf426e04b, 0xe04a0009, 0x02008d06, 0x29008100, 0xc420404b, 0xc04a0009, 0x02000009,
0x28008100, 0xc820404b, 0x404a0009, 0x01008d00, 0x44000000, 0x28260012, 0x00000000, 0x02000000,
0x28008100, 0xcc20404b, 0x404a0009, 0x02008d00, 0x2a008100, 0xd020404b, 0x404a0009, 0x01008d00,
0x44000000, 0x2a260012, 0x00000000, 0x02000000, 0x28008100, 0xd420404b, 0x404a0009, 0x5b008d00,
0x08008000, 0x39370040, 0x6e072020, 0x38018084, 0x28018000, 0xc020804b, 0x00008d00, 0x41000000,
0x28008000, 0xe026e04b, 0x804a8d06, 0x10008d00, 0x20018000, 0xc020004b, 0x004e8d00, 0x02000000,
0x28009100, 0xe026e04b, 0x004e8d06, 0x41000000, 0x28008000, 0xe025e04b, 0xe04a8d05, 0x02008d06,
0x28058000, 0xe025e04b, 0x004e8d05, 0x413f8000, 0x28008000, 0xe028604b, 0x604a8d06, 0x02008d08,
0x28058000, 0x6028604b, 0x004e8d08, 0x413f8000, 0x28008000, 0xe026e04b, 0x804a8d06, 0x02008d09,
0x28058000, 0xe026e04b, 0x004e8d06, 0x413f8000, 0x28008000, 0x5c21404b, 0xa04a0002, 0x5b008d04,
0x08008000, 0x390a0040, 0x620720a0, 0x5b04b004, 0x08008000, 0x390a0040, 0x360720a0, 0x1004f004,
0x20038000, 0x4020004b, 0x044a8d01, 0x0100000a, 0x4c000000, 0x00202810, 0x00000006, 0x02000000,
0x28008100, 0xe426a04b, 0xe04a0009, 0x10000009, 0x22038000, 0x4020004b, 0x084a8d01, 0x0200000a,
0x2a008100, 0xe826a04b, 0xa04a0009, 0x10008d06, 0x21038000, 0x4020004b, 0x0c4a8d01, 0x0200000a,
0x29008100, 0xec26a04b, 0xa04a0009, 0x10008d06, 0x20038000, 0x4020004b, 0x104a8d01, 0x0200000a,
0x28008100, 0xf026a04b, 0xa04a0009, 0x10008d06, 0x23038000, 0x4020004b, 0x144a8d01, 0x0100000a,
0x4c000000, 0x22202a10, 0x00000006, 0x02000000, 0x2b008100, 0xf426a04b, 0xa04a0009, 0x01008d06,
0x44000000, 0x28262212, 0x00000000, 0x02000000, 0x2b008100, 0xc420404b, 0xc04a0009, 0x02000009,
0x2a008100, 0xc820404b, 0x404a0009, 0x02008d00, 0x29008100, 0xcc20404b, 0x404a0009, 0x02008d00,
0x28008100, 0xd020404b, 0x404a0009, 0x01008d00, 0x44000000, 0x2a260012, 0x00000000, 0x02000000,
0x28008100, 0xd420404b, 0x404a0009, 0x5b008d00, 0x08008000, 0x39350040, 0x6a072020, 0x38028084,
0x28018000, 0x4020804b, 0x00008d01, 0x41000000, 0x28008000, 0xa026a04b, 0x804a8d06, 0x10008d00,
0x20018000, 0x4020004b, 0x004e8d01, 0x02000000, 0x28009100, 0xa026a04b, 0x004e8d06, 0x41000000,
0x28008000, 0x2026204b, 0xa04a8d06, 0x02008d06, 0x28058000, 0x2026204b, 0x004e8d06, 0x413f8000,
0x28008000, 0xa024a04b, 0xa04a8d06, 0x02008d04, 0x28058000, 0xa024a04b, 0x004e8d04, 0x413f8000,
0x28008000, 0xa026a04b, 0x604a8d06, 0x02008d03, 0x28058000, 0xa026a04b, 0x004e8d06, 0x413f8000,
0x28008000, 0x5c20c04b, 0xc04a0002, 0x5b008d08, 0x08008000, 0x39060040, 0x7e072060, 0x5b04b004,
0x08008000, 0x39060040, 0x94072060, 0x1004f004, 0x23038000, 0xc020004b, 0x044a8d00, 0x0200000a,
0x2b008100, 0xe423604b, 0xe04a0009, 0x10000009, 0x22038000, 0xc020004b, 0x084a8d00, 0x0200000a,
0x2a008100, 0xe823604b, 0x604a0009, 0x10008d03, 0x21038000, 0xc020004b, 0x0c4a8d00, 0x0200000a,
0x29008100, 0xec23604b, 0x604a0009, 0x10008d03, 0x20038000, 0xc020004b, 0x104a8d00, 0x0100000a,
0x4c000000, 0x00202810, 0x00000006, 0x02000000, 0x28008100, 0xf023604b, 0x604a0009, 0x10008d03,
0x20038000, 0xc020004b, 0x144a8d00, 0x0200000a, 0x28008100, 0xf423604b, 0x604a0009, 0x02008d03,
0x2b008100, 0xc420404b, 0xc04a0009, 0x02000009, 0x2a008100, 0xc820404b, 0x404a0009, 0x02008d00,
0x29008100, 0xcc20404b, 0x404a0009, 0x01008d00, 0x44000000, 0x28260212, 0x00000000, 0x02000000,
0x29008100, 0xd020404b, 0x404a0009, 0x02008d00, 0x28008100, 0xd420404b, 0x404a0009, 0x5b008d00,
0x08008000, 0x391b0040, 0x36072020, 0x38018084, 0x28018000, 0xc020804b, 0x00008d00, 0x41000000,
0x28008000, 0x6023604b, 0x804a8d03, 0x10008d00, 0x20018000, 0xc020004b, 0x004e8d00, 0x02000000,
0x28009100, 0x6023604b, 0x004e8d03, 0x41000000, 0x28008000, 0xe027e04b, 0x604a8d07, 0x02008d03,
0x28058000, 0xe027e04b, 0x004e8d07, 0x413f8000, 0x28008000, 0x6028c04b, 0xc04a8d03, 0x02008d08,
0x28058000, 0xc028c04b, 0x004e8d08, 0x413f8000, 0x28008000, 0x6023604b, 0x404a8d03, 0x02008d09,
0x28058000, 0x6023604b, 0x004e8d03, 0x413f8000, 0x28008000, 0x5c21004b, 0xa04a0002, 0x5b008d05,
0x08008000, 0x39080040, 0x82072080, 0x5b04b004, 0x08008000, 0x39080040, 0x66072080, 0x1004f004,
0x22038000, 0x0020004b, 0x044a8d01, 0x0200000a, 0x2a008100, 0xe425604b, 0xe04a0009, 0x10000009,
0x21038000, 0x0020004b, 0x084a8d01, 0x0200000a, 0x29008100, 0xe825604b, 0x604a0009, 0x10008d05,
0x20038000, 0x0020004b, 0x0c4a8d01, 0x0200000a, 0x28008100, 0xec25604b, 0x604a0009, 0x10008d05,
0x23038000, 0x0020004b, 0x104a8d01, 0x0100000a, 0x4c000000, 0x22202810, 0x00000006, 0x02000000,
0x2b008100, 0xf025604b, 0x604a0009, 0x10008d05, 0x23038000, 0x0020004b, 0x144a8d01, 0x0100000a,
0x4c000000, 0x22202a10, 0x00000006, 0x02000000, 0x2b008100, 0xf425604b, 0x604a0009, 0x02008d05,
0x2a008100, 0xc425204b, 0xc04a0009, 0x02000009, 0x29008100, 0xc825204b, 0x204a0009, 0x02008d05,
0x28008100, 0xcc25204b, 0x204a0009, 0x01008d05, 0x44000000, 0x28260012, 0x00000000, 0x02000000,
0x28008100, 0xd025204b, 0x204a0009, 0x01008d05, 0x44000000, 0x2a260012, 0x00000000, 0x02000000,
0x28008100, 0xd425204b, 0x204a0009, 0x5b008d05, 0x08008000, 0x39290040, 0x56072290, 0x38020084,
0x28018000, 0x0020404b, 0x00008d01, 0x41000000, 0x28008000, 0x2025204b, 0x404a8d05, 0x10008d00,
0x20018000, 0x0020004b, 0x004e8d01, 0x02000000, 0x28009100, 0x2025204b, 0x004e8d05, 0x41000000,
0x28008000, 0x2028204b, 0x204a8d08, 0x02008d05, 0x28058000, 0x2028204b, 0x004e8d08, 0x413f8000,
0x28008000, 0x2025a04b, 0xa04a8d05, 0x02008d05, 0x28058000, 0xa025a04b, 0x004e8d05, 0x413f8000,
0x28008000, 0x2025204b, 0x604a8d05, 0x02008d06, 0x28058000, 0x2025204b, 0x004e8d05, 0x5b3f8000,
0x08008000, 0x01040040, 0x420720e6, 0x5b038004, 0x08008000, 0x39040040, 0x3e072040, 0x5b038804,
0x08008000, 0x39040040, 0x90072040, 0x5b039004, 0x08008000, 0x012b0040, 0x1d0020f2, 0x5b084084,
0x08008000, 0x392b0040, 0x1d4022b0, 0x5b07c084, 0x08008000, 0x392b0040, 0x1e0022b0, 0x5b120084,
0x08008000, 0x01210040, 0x1e8020fa, 0x5b084084, 0x08008000, 0x391f0040, 0x1ec02210, 0x5b07c084,
0x08008000, 0x39480040, 0x1f0021f0, 0x5b120084, 0x08008000, 0x010a0040, 0x320720e6, 0x5b038004,
0x08008000, 0x390a0040, 0x4e0720a0, 0x5b038804, 0x08008000, 0x390a0040, 0x7a0720a0, 0x5b039004,
0x08008000, 0x011f0040, 0x1d0020f2, 0x5b064084, 0x08008000, 0x391f0040, 0x1d4021f0, 0x5b09c084,
0x08008000, 0x391f0040, 0x1e0021f0, 0x5b0f4084, 0x08008000, 0x01190040, 0x1e8020fa, 0x5b064084,
0x08008000, 0x39270040, 0x1ec02190, 0x5b09c084, 0x08008000, 0x393d0040, 0x1f002270, 0x5b0f4084,
0x08008000, 0x01500040, 0x2e0720e6, 0x5b038004, 0x08008000, 0x39500040, 0x3a072500, 0x5b038804,
0x08008000, 0x39500040, 0x76072500, 0x5b039004, 0x08008000, 0x01210040, 0x1d0020f2, 0x5b05c084,
0x08008000, 0x39210040, 0x1d402210, 0x5b074084, 0x08008000, 0x39210040, 0x1e002210, 0x5b0ec084,
0x08008000, 0x01170040, 0x1e8020fa, 0x5b05c084, 0x08008000, 0x391d0040, 0x1ec02170, 0x5b074084,
0x08008000, 0x393b0040, 0x1f0021d0, 0x5b0ec084, 0x08008000, 0x01520040, 0x2a0720e6, 0x5b038004,
0x08008000, 0x39520040, 0x46072520, 0x5b038804, 0x08008000, 0x39520040, 0x72072520, 0x5b039004,
0x08008000, 0x014e0040, 0x1d0020f2, 0x5b054084, 0x08008000, 0x394e0040, 0x1d4024e0, 0x5b08c084,
0x08008000, 0x394e0040, 0x1e0024e0, 0x5b0e4084, 0x08008000, 0x01150040, 0x1e8020fa, 0x5b054084,
0x08008000, 0x39230040, 0x1ec02150, 0x5b08c084, 0x08008000, 0x39390040, 0x1f002230, 0x5b0e4084,
0x08008000, 0x01180040, 0x5e0720e6, 0x5b038004, 0x08008000, 0x39180040, 0x86072180, 0x5b038804,
0x08008000, 0x39180040, 0x6e072180, 0x5b039004, 0x08008000, 0x01080040, 0x1d0020f2, 0x5b0bc084,
0x08008000, 0x39080040, 0x1d402080, 0x5b10c084, 0x08008000, 0x39080040, 0x1e002080, 0x5b0dc084,
0x08008000, 0x012f0040, 0x1e8020fa, 0x5b0bc084, 0x08008000, 0x39430040, 0x1ec022f0, 0x5b10c084,
0x08008000, 0x39370040, 0x1f002430, 0x5b0dc084, 0x08008000, 0x014a0040, 0x620720e6, 0x5b038004,
0x08008000, 0x394a0040, 0x4a0724a0, 0x5b038804, 0x08008000, 0x394a0040, 0x6a0724a0, 0x5b039004,
0x08008000, 0x01140040, 0x1d0020f2, 0x5b0c4084, 0x08008000, 0x39140040, 0x1d402140, 0x5b094084,
0x08008000, 0x39140040, 0x1e002140, 0x5b0d4084, 0x08008000, 0x01310040, 0x1e8020fa, 0x5b0c4084,
0x08008000, 0x39250040, 0x1ec02310, 0x5b094084, 0x08008000, 0x39350040, 0x1f002250, 0x5b0d4084,
0x08008000, 0x014c0040, 0x7e0720e6, 0x5b038004, 0x08008000, 0x394c0040, 0x8c0724c0, 0x5b038804,
0x08008000, 0x394c0040, 0x360724c0, 0x5b039004, 0x08008000, 0x01160040, 0x1d0020f2, 0x5b0fc084,
0x08008000, 0x39160040, 0x1d402160, 0x5b118084, 0x08008000, 0x39160040, 0x1e002160, 0x5b06c084,
0x08008000, 0x013f0040, 0x1e8020fa, 0x5b0fc084, 0x08008000, 0x39460040, 0x1ec023f0, 0x5b118084,
0x08008000, 0x391b0040, 0x1f002460, 0x5b06c084, 0x08008000, 0x01460040, 0x820720e6, 0x5b038004,
0x08008000, 0x39460040, 0x5a072460, 0x5b038804, 0x08008000, 0x39460040, 0x52072460, 0x5b039004,
0x08008000, 0x011d0040, 0x1d0020f2, 0x5b104084, 0x08008000, 0x391d0040, 0x1d4021d0, 0x5b0b4084,
0x08008000, 0x391d0040, 0x1e0021d0, 0x5b0a4084, 0x08008000, 0x01410040, 0x1e8020fa, 0x5b104084,
0x08008000, 0x392d0040, 0x1ec02410, 0x5b0b4084, 0x08008000, 0x39290040, 0x1f0022d0, 0x020a4084,
0x28048000, 0x8020804b, 0x004e8d00, 0x02000000, 0x28058000, 0x8020804b, 0x004e8d00, 0x023f8000,
0x28048000, 0x6025604b, 0x004e8d05, 0x02000000, 0x28058000, 0x6025604b, 0x004e8d05, 0x023f8000,
0x28048000, 0x0029004b, 0x004e8d09, 0x02000000, 0x28058000, 0x0029004b, 0x004e8d09, 0x023f8000,
0x28048000, 0x4021404b, 0x004e8d01, 0x02000000, 0x28058000, 0x4021404b, 0x004e8d01, 0x023f8000,
0x28048000, 0xe023e04b, 0x004e8d03, 0x02000000, 0x28058000, 0xe023e04b, 0x004e8d03, 0x023f8000,
0x28048000, 0xa027a04b, 0x004e8d07, 0x02000000, 0x28058000, 0xa027a04b, 0x004e8d07, 0x023f8000,
0x28048000, 0x002a004b, 0x004e8d0a, 0x02000000, 0x28058000, 0x002a004b, 0x004e8d0a, 0x023f8000,
0x28048000, 0x2024204b, 0x004e8d04, 0x02000000, 0x28058000, 0x2024204b, 0x004e8d04, 0x023f8000,
0x28048000, 0x6027604b, 0x004e8d07, 0x02000000, 0x28058000, 0x6027604b, 0x004e8d07, 0x023f8000,
0x28048000, 0x402a404b, 0x004e8d0a, 0x02000000, 0x28058000, 0x402a404b, 0x004e8d0a, 0x023f8000,
0x28048000, 0xc029c04b, 0x004e8d09, 0x02000000, 0x28058000, 0xc029c04b, 0x004e8d09, 0x023f8000,
0x28048000, 0x2027204b, 0x004e8d07, 0x02000000, 0x28058000, 0x2027204b, 0x004e8d07, 0x023f8000,
0x28048000, 0x0023004b, 0x004e8d03, 0x02000000, 0x28058000, 0x0023004b, 0x004e8d03, 0x023f8000,
0x28048000, 0x0021004b, 0x004e8d01, 0x02000000, 0x28058000, 0x0021004b, 0x004e8d01, 0x023f8000,
0x28048000, 0xe026e04b, 0x004e8d06, 0x02000000, 0x28058000, 0xe026e04b, 0x004e8d06, 0x023f8000,
0x28048000, 0x4029404b, 0x004e8d09, 0x02000000, 0x28058000, 0x4029404b, 0x004e8d09, 0x023f8000,
0x28048000, 0x8022804b, 0x004e8d02, 0x02000000, 0x28058000, 0x8022804b, 0x004e8d02, 0x023f8000,
0x28048000, 0xa026a04b, 0x004e8d06, 0x02000000, 0x28058000, 0xa026a04b, 0x004e8d06, 0x023f8000,
0x28048000, 0x8029804b, 0x004e8d09, 0x02000000, 0x28058000, 0x8029804b, 0x004e8d09, 0x023f8000,
0x28048000, 0xc022c04b, 0x004e8d02, 0x02000000, 0x28058000, 0xc022c04b, 0x004e8d02, 0x023f8000,
0x28048000, 0x6023604b, 0x004e8d03, 0x02000000, 0x28058000, 0x6023604b, 0x004e8d03, 0x023f8000,
0x28048000, 0xc028c04b, 0x004e8d08, 0x02000000, 0x28058000, 0xc028c04b, 0x004e8d08, 0x023f8000,
0x28048000, 0xa023a04b, 0x004e8d03, 0x02000000, 0x28058000, 0xa023a04b, 0x004e8d03, 0x023f8000,
0x28048000, 0x2025204b, 0x004e8d05, 0x02000000, 0x28058000, 0x2025204b, 0x004e8d05, 0x103f8000,
0x20050000, 0x9c20000a, 0x011e0001, 0x20000100, 0x04000100, 0x00340000, 0xb00e0014, 0x10000023,
0x20010000, 0x9c20000a, 0x011e0001, 0x20000100, 0x04001100, 0x00340000, 0x300e0014, 0x01000023,
0x28000000, 0x0021bc4f, 0x00000000, 0x013f5600, 0x28000000, 0x0021dc4f, 0x00000000, 0x014196d0,
0x28000000, 0x0021fc4f, 0x00000000, 0x01419580, 0x28000000, 0x00221c4f, 0x00000000, 0x013e2320,
0x28000000, 0x00223c4f, 0x00000000, 0x10429db0, 0x20010000, 0x9c20000a, 0x011e0001, 0x20000100,
0x04000100, 0x00340000, 0xc00e0014, 0x41000016, 0x28008000, 0x8025a04b, 0xdc4a8d00, 0x38000001,
0x280a8000, 0x8020404b, 0x3c4a8d00, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x5b000000,
0x08008000, 0x01020040, 0x0407210e, 0x1003f804, 0x20068000, 0x8020004b, 0xbc4a8d00, 0x02000001,
0x28008100, 0xa025a04b, 0x404a8d05, 0x41008d00, 0x28008000, 0x4024e04b, 0xdc4a8d01, 0x38000001,
0x280a8000, 0x4020c04b, 0x3c4a8d01, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x5b000000,
0x08008000, 0x01060040, 0x0c07210e, 0x1003f804, 0x20068000, 0x4020004b, 0xbc4a8d01, 0x02000001,
0x28008100, 0xe024e04b, 0xc04a8d04, 0x41008d00, 0x28008000, 0x0026604b, 0xdc4a8d0a, 0x38000001,
0x280a8000, 0x0021404b, 0x3c4a8d0a, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x5b000000,
0x08008000, 0x010a0040, 0x1407210e, 0x1003f804, 0x20068000, 0x0020004b, 0xbc4a8d0a, 0x02000001,
0x28008100, 0x6026604b, 0x404a8d06, 0x41008d01, 0x28008000, 0x4026204b, 0xdc4a8d0a, 0x38000001,
0x280a8000, 0x4020404b, 0x3c4a8d0a, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x5b000000,
0x08008000, 0x01020040, 0x0407210e, 0x1003f804, 0x20068000, 0x4020004b, 0xbc4a8d0a, 0x02000001,
0x28008100, 0x2026204b, 0x404a8d06, 0x41008d00, 0x28008000, 0x6025e04b, 0xdc4a8d05, 0x38000001,
0x280a8000, 0x6020c04b, 0x3c4a8d05, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x5b000000,
0x08008000, 0x01060040, 0x0c07210e, 0x1003f804, 0x20068000, 0x6020004b, 0xbc4a8d05, 0x02000001,
0x28008100, 0xe025e04b, 0xc04a8d05, 0x41008d00, 0x28008000, 0xe024a04b, 0xdc4a8d03, 0x38000001,
0x280a8000, 0xe021404b, 0x3c4a8d03, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x5b000000,
0x08008000, 0x010a0040, 0x1407210e, 0x1003f804, 0x20068000, 0xe020004b, 0xbc4a8d03, 0x02000001,
0x28008100, 0xa024a04b, 0x404a8d04, 0x41008d01, 0x28008000, 0x2027e04b, 0xdc4a8d04, 0x38000001,
0x280a8000, 0x2020404b, 0x3c4a8d04, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x5b000000,
0x08008000, 0x01020040, 0x0407210e, 0x1003f804, 0x20068000, 0x2020004b, 0xbc4a8d04, 0x02000001,
0x28008100, 0xe027e04b, 0x404a8d07, 0x41008d00, 0x28008000, 0xc028204b, 0xdc4a8d09, 0x38000001,
0x280a8000, 0xc020c04b, 0x3c4a8d09, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x5b000000,
0x08008000, 0x01060040, 0x0c07210e, 0x1003f804, 0x20068000, 0xc020004b, 0xbc4a8d09, 0x02000001,
0x28008100, 0x2028204b, 0xc04a8d08, 0x41008d00, 0x28008000, 0x0024604b, 0xdc4a8d09, 0x38000001,
0x280a8000, 0x0021404b, 0x3c4a8d09, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x5b000000,
0x08008000, 0x010a0040, 0x1407210e, 0x1003f804, 0x20068000, 0x0020004b, 0xbc4a8d09, 0x02000001,
0x28008100, 0x6024604b, 0x404a8d04, 0x41008d01, 0x28008000, 0xa028604b, 0xdc4a8d07, 0x38000001,
0x280a8000, 0xa020404b, 0x3c4a8d07, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x5b000000,
0x08008000, 0x01020040, 0x0407210e, 0x1003f804, 0x20068000, 0xa020004b, 0xbc4a8d07, 0x02000001,
0x28008100, 0x6028604b, 0x404a8d08, 0x41008d00, 0x28008000, 0x6024204b, 0xdc4a8d07, 0x38000001,
0x280a8000, 0x6020c04b, 0x3c4a8d07, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x5b000000,
0x08008000, 0x01060040, 0x0c07210e, 0x1003f804, 0x20068000, 0x6020004b, 0xbc4a8d07, 0x02000001,
0x28008100, 0x2024204b, 0xc04a8d04, 0x41008d00, 0x28008000, 0x2027604b, 0xdc4a8d07, 0x38000001,
0x280a8000, 0x2021404b, 0x3c4a8d07, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x5b000000,
0x08008000, 0x010a0040, 0x1407210e, 0x1003f804, 0x20068000, 0x2020004b, 0xbc4a8d07, 0x02000001,
0x28008100, 0x6027604b, 0x404a8d07, 0x41008d01, 0x28008000, 0x0023e04b, 0xdc4a8d03, 0x38000001,
0x280a8000, 0x0020404b, 0x3c4a8d03, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x5b000000,
0x08008000, 0x01020040, 0x0407210e, 0x1003f804, 0x20068000, 0x0020004b, 0xbc4a8d03, 0x02000001,
0x28008100, 0xe023e04b, 0x404a8d03, 0x41008d00, 0x28008000, 0x4027204b, 0xdc4a8d09, 0x38000001,
0x280a8000, 0x4020c04b, 0x3c4a8d09, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x5b000000,
0x08008000, 0x01060040, 0x0c07210e, 0x1003f804, 0x20068000, 0x4020004b, 0xbc4a8d09, 0x02000001,
0x28008100, 0x2027204b, 0xc04a8d07, 0x41008d00, 0x28008000, 0x8023204b, 0xdc4a8d09, 0x38000001,
0x280a8000, 0x8021404b, 0x3c4a8d09, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x5b000000,
0x08008000, 0x010a0040, 0x1407210e, 0x1003f804, 0x20068000, 0x8020004b, 0xbc4a8d09, 0x02000001,
0x28008100, 0x2023204b, 0x404a8d03, 0x41008d01, 0x28008000, 0xc027a04b, 0xdc4a8d08, 0x38000001,
0x280a8000, 0xc020404b, 0x3c4a8d08, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x5b000000,
0x08008000, 0x01020040, 0x0407210e, 0x1003f804, 0x20068000, 0xc020004b, 0xbc4a8d08, 0x02000001,
0x28008100, 0xa027a04b, 0x404a8d07, 0x41008d00, 0x28008000, 0x0025604b, 0xdc4a8d01, 0x38000001,
0x280a8000, 0x0020c04b, 0x3c4a8d01, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x5b000000,
0x08008000, 0x01060040, 0x0c07210e, 0x1003f804, 0x20068000, 0x0020004b, 0xbc4a8d01, 0x02000001,
0x28008100, 0x6025604b, 0xc04a8d05, 0x41008d00, 0x28008000, 0x8028c04b, 0xdc4a8d02, 0x38000001,
0x280a8000, 0x8021404b, 0x3c4a8d02, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x5b000000,
0x08008000, 0x010a0040, 0x1407210e, 0x1003f804, 0x20068000, 0x8020004b, 0xbc4a8d02, 0x02000001,
0x28008100, 0xc028c04b, 0x404a8d08, 0x41008d01, 0x28008000, 0xc022804b, 0xdc4a8d02, 0x38000001,
0x280a8000, 0xc020404b, 0x3c4a8d02, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x5b000000,
0x08008000, 0x01020040, 0x0407210e, 0x1003f804, 0x20068000, 0xc020004b, 0xbc4a8d02, 0x02000001,
0x28008100, 0x8022804b, 0x404a8d02, 0x41008d00, 0x28008000, 0xa022c04b, 0xdc4a8d03, 0x38000001,
0x280a8000, 0xa020c04b, 0x3c4a8d03, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x5b000000,
0x08008000, 0x01060040, 0x0c07210e, 0x1003f804, 0x20068000, 0xa020004b, 0xbc4a8d03, 0x02000001,
0x28008100, 0xc022c04b, 0xc04a8d02, 0x41008d00, 0x28008000, 0xe023a04b, 0xdc4a8d06, 0x38000001,
0x280a8000, 0xe021404b, 0x3c4a8d06, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x5b000000,
0x08008000, 0x010a0040, 0x1407210e, 0x1003f804, 0x20068000, 0xe020004b, 0xbc4a8d06, 0x02000001,
0x28008100, 0xa023a04b, 0x404a8d03, 0x41008d01, 0x28008000, 0xa026e04b, 0xdc4a8d06, 0x38000001,
0x280a8000, 0xa020404b, 0x3c4a8d06, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x5b000000,
0x08008000, 0x01020040, 0x0407210e, 0x1003f804, 0x20068000, 0xa020004b, 0xbc4a8d06, 0x02000001,
0x28008100, 0xe026e04b, 0x404a8d06, 0x41008d00, 0x28008000, 0x6021004b, 0xdc4a8d03, 0x38000001,
0x280a8000, 0x6020c04b, 0x3c4a8d03, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x5b000000,
0x08008000, 0x01060040, 0x0c07210e, 0x1003f804, 0x20068000, 0x6020004b, 0xbc4a8d03, 0x02000001,
0x28008100, 0x0021004b, 0xc04a8d01, 0x41008d00, 0x28008000, 0x2020604b, 0xdc4a8d05, 0x38000001,
0x280a8000, 0x2021404b, 0x3c4a8d05, 0x7e000002, 0x00000000, 0x00000000, 0x00000000, 0x5b000000,
0x08008000, 0x010a0040, 0x1407210e, 0x1003f804, 0x20068000, 0x2020004b, 0xbc4a8d05, 0x02000001,
0x28008100, 0x6020604b, 0x404a8d00, 0x01008d01, 0x28000000, 0x0020404f, 0x00000000, 0x01477fff,
0x28000000, 0x0020284f, 0x00000000, 0x5b3f0000, 0x08008000, 0x01030040, 0x04002014, 0x0100c084,
0x48808000, 0x6040604a, 0x00008d00, 0x01000000, 0x08008000, 0x6020a043, 0x00004000, 0x5b000000,
0x08008000, 0x01080040, 0x04002014, 0x01020084, 0x48808000, 0x0040c04a, 0x00008d01, 0x01000000,
0x08008000, 0xc0210043, 0x00004000, 0x5b000000, 0x08008000, 0x01370040, 0x04002014, 0x010dc084,
0x48808000, 0xe041204a, 0x00008d06, 0x01000000, 0x08008000, 0x20216043, 0x00004001, 0x5b000000,
0x08008000, 0x011d0040, 0x04002014, 0x01074084, 0x48808000, 0xa041804a, 0x00008d03, 0x01000000,
0x08008000, 0x8021c043, 0x00004001, 0x5b000000, 0x08008000, 0x01160040, 0x04002014, 0x01058084,
0x48808000, 0xc041e04a, 0x00008d02, 0x01000000, 0x08008000, 0xe0206043, 0x00004001, 0x5b000000,
0x08008000, 0x01140040, 0x04002014, 0x01050084, 0x48808000, 0x8042204a, 0x00008d02, 0x01000000,
0x08008000, 0x20208043, 0x00004002, 0x5b000000, 0x08008000, 0x01460040, 0x04002014, 0x01118084,
0x48808000, 0xc040c04a, 0x00008d08, 0x01000000, 0x08008000, 0xc0212043, 0x00004000, 0x5b000000,
0x08008000, 0x012b0040, 0x04002014, 0x010ac084, 0x48808000, 0x6042604a, 0x00008d05, 0x01000000,
0x08008000, 0x60214043, 0x00004002, 0x5b000000, 0x08008000, 0x010c0040, 0x04002014, 0x010f4084,
0x48808000, 0x8042a04a, 0x00008d01, 0x01000000, 0x08008000, 0xa021e043, 0x00004002, 0x5b000000,
0x08008000, 0x01170040, 0x04002014, 0x01064084, 0x48808000, 0xe043204a, 0x00008d02, 0x01000000,
0x08008000, 0x20220043, 0x00004003, 0x5b000000, 0x08008000, 0x01110040, 0x04002014, 0x010e4084,
0x48808000, 0x2043604a, 0x00008d02, 0x01000000, 0x08008000, 0x6020c043, 0x00004003, 0x5b000000,
0x08008000, 0x011d0040, 0x04002014, 0x0107c084, 0x48808000, 0xa043e04a, 0x00008d03, 0x01000000,
0x08008000, 0xe020e043, 0x00004003, 0x5b000000, 0x08008000, 0x01130040, 0x04002014, 0x010ec084,
0x48808000, 0x6041804a, 0x00008d02, 0x01000000, 0x08008000, 0x8022a043, 0x00004001, 0x5b000000,
0x08008000, 0x01210040, 0x04002014, 0x01084084, 0x48808000, 0x2042c04a, 0x00008d04, 0x01000000,
0x08008000, 0xc0230043, 0x00004002, 0x5b000000, 0x08008000, 0x01190040, 0x04002014, 0x0110c084,
0x48808000, 0x2042204a, 0x00008d03, 0x01000000, 0x08008000, 0x20236043, 0x00004002, 0x5b000000,
0x08008000, 0x01230040, 0x04002014, 0x0108c084, 0x48808000, 0x6043804a, 0x00008d04, 0x01000000,
0x08008000, 0x8023c043, 0x00004003, 0x5b000000, 0x08008000, 0x011f0040, 0x04002014, 0x01104084,
0x48808000, 0xe042604a, 0x00008d03, 0x01000000, 0x08008000, 0x60254043, 0x00004002, 0x5b000000,
0x08008000, 0x010c0040, 0x04002014, 0x010fc084, 0x48808000, 0x8044204a, 0x00008d01, 0x01000000,
0x08008000, 0x20252043, 0x00004004, 0x5b000000, 0x08008000, 0x01160040, 0x04002014, 0x01094084,
0x48808000, 0xc043204a, 0x00008d02, 0x01000000, 0x08008000, 0x20258043, 0x00004003, 0x5b000000,
0x08008000, 0x01110040, 0x04002014, 0x010bc084, 0x48808000, 0x2044604a, 0x00008d02, 0x01000000,
0x08008000, 0x60256043, 0x00004004, 0x5b000000, 0x08008000, 0x011c0040, 0x04002014, 0x010c4084,
0x48808000, 0x8043e04a, 0x00008d03, 0x01000000, 0x08008000, 0xe0226043, 0x00004003, 0x5b000000,
0x08008000, 0x01250040, 0x04002014, 0x010cc084, 0x48808000, 0xa041804a, 0x00008d04, 0x01000000,
0x08008000, 0x80228043, 0x00004001, 0x5b000000, 0x08008000, 0x01210040, 0x04002014, 0x0109c084,
0x48808000, 0x2042c04a, 0x00008d04, 0x01000000, 0x08008000, 0xc0232043, 0x00004002, 0x5b000000,
0x08008000, 0x01270040, 0x04002014, 0x010b4084, 0x48808000, 0xe042204a, 0x00008d04, 0x01000000,
0x08008000, 0x20234043, 0x00004002, 0x01000000, 0x68006000, 0x4065a012, 0x00008d03, 0x01000000,
0x68006000, 0x5064e012, 0x00008d03, 0x01000000, 0x68006000, 0x20666012, 0x00008d03, 0x01000000,
0x68006000, 0x30662012, 0x00008d03, 0x01000000, 0x68006000, 0x8065e012, 0x00008d02, 0x01000000,
0x68006000, 0x9064a012, 0x00008d02, 0x01000000, 0x68006000, 0x6067e012, 0x00008d02, 0x01000000,
0x68006000, 0x70682012, 0x00008d02, 0x01000000, 0x68006000, 0xe0646012, 0x00008d00, 0x01000000,
0x68006000, 0xf0686012, 0x00008d00, 0x01000000, 0x68006000, 0xc0642012, 0x00008d00, 0x01000000,
0x68006000, 0xd0676012, 0x00008d00, 0x01000000, 0x68006000, 0x0063e012, 0x00008d02, 0x01000000,
0x68006000, 0x10672012, 0x00008d02, 0x01000000, 0x68006000, 0xe0632012, 0x00008d01, 0x01000000,
0x68006000, 0xf067a012, 0x00008d01, 0x01000000, 0x68006000, 0x6065a212, 0x00008d05, 0x01000000,
0x68006000, 0x7064e212, 0x00008d05, 0x01000000, 0x68006000, 0x80666212, 0x00008d05, 0x01000000,
0x68006000, 0x90662212, 0x00008d05, 0x01000000, 0x68006000, 0x2065e212, 0x00008d05, 0x01000000,
0x68006000, 0x3064a212, 0x00008d05, 0x01000000, 0x68006000, 0x4067e212, 0x00008d05, 0x01000000,
0x68006000, 0x50682212, 0x00008d05, 0x01000000, 0x68006000, 0x40646212, 0x00008d01, 0x01000000,
0x68006000, 0x50686212, 0x00008d01, 0x01000000, 0x68006000, 0x20642212, 0x00008d01, 0x01000000,
0x68006000, 0x30676212, 0x00008d01, 0x01000000, 0x68006000, 0x8063e212, 0x00008d00, 0x01000000,
0x68006000, 0x90672212, 0x00008d00, 0x01000000, 0x68006000, 0x60632212, 0x00008d00, 0x01000000,
0x68006000, 0x7067a212, 0x00008d00, 0x01000000, 0x68006000, 0xc065a412, 0x00008d03, 0x01000000,
0x68006000, 0xd064e412, 0x00008d03, 0x01000000, 0x68006000, 0x60666412, 0x00008d03, 0x01000000,
0x68006000, 0x70662412, 0x00008d03, 0x01000000, 0x68006000, 0x0065e412, 0x00008d03, 0x01000000,
0x68006000, 0x1064a412, 0x00008d03, 0x01000000, 0x68006000, 0xa067e412, 0x00008d02, 0x01000000,
0x68006000, 0xb0682412, 0x00008d02, 0x01000000, 0x68006000, 0xc0646412, 0x00008d01, 0x01000000,
0x68006000, 0xd0686412, 0x00008d01, 0x01000000, 0x68006000, 0x60642412, 0x00008d01, 0x01000000,
0x68006000, 0x70676412, 0x00008d01, 0x01000000, 0x68006000, 0x0063e412, 0x00008d01, 0x01000000,
0x68006000, 0x10672412, 0x00008d01, 0x01000000, 0x68006000, 0xa0632412, 0x00008d00, 0x01000000,
0x68006000, 0xb067a412, 0x00008d00, 0x01000000, 0x68006000, 0x0065a61e, 0x00000000, 0x01000000,
0x68006000, 0x0064e61e, 0x00000000, 0x01000000, 0x68006000, 0x0066661e, 0x00000000, 0x01000000,
0x68006000, 0x0066261e, 0x00000000, 0x01000000, 0x68006000, 0x0065e61e, 0x00000000, 0x01000000,
0x68006000, 0x0064a61e, 0x00000000, 0x01000000, 0x68006000, 0x0067e61e, 0x00000000, 0x01000000,
0x68006000, 0x0068261e, 0x00000000, 0x01000000, 0x68006000, 0x0064661e, 0x00000000, 0x01000000,
0x68006000, 0x0068661e, 0x00000000, 0x01000000, 0x68006000, 0x0064261e, 0x00000000, 0x01000000,
0x68006000, 0x0067661e, 0x00000000, 0x01000000, 0x68006000, 0x0063e61e, 0x00000000, 0x01000000,
0x68006000, 0x0067261e, 0x00000000, 0x01000000, 0x68006000, 0x0063261e, 0x00000000, 0x01000000,
0x68006000, 0x0067a61e, 0x00000000, 0x01000000, 0x08008000, 0xa0204043, 0x00008d05, 0x01000000,
0x08008000, 0x60206043, 0x00008d06, 0x01000000, 0x08008000, 0xe0208043, 0x00008d05, 0x01000000,
0x08008000, 0xe020a043, 0x00008d07, 0x01000000, 0x2c006000, 0x0020c04b, 0x00008d00, 0x01000000,
0x0c000000, 0x0020c806, 0x1f000000, 0x01000300, 0x2c000000, 0xb020c04b, 0x00000008, 0x01000000,
0x2c000000, 0xb420c44b, 0x00000008, 0x40000000, 0x04000000, 0x20220002, 0x00060000, 0x33020a80,
0x140c6000, 0xc4000020, 0x00000020, 0x01000000, 0x08008000, 0xc020e043, 0x00008d05, 0x01000000,
0x08008000, 0x80210043, 0x00008d06, 0x01000000, 0x08008000, 0x00212043, 0x00008d06, 0x01000000,
0x08008000, 0x00214043, 0x00008d08, 0x01000000, 0x2c006000, 0x0021604b, 0x00008d00, 0x01000000,
0x0c000000, 0x00216806, 0x1f000000, 0x01000300, 0x2c000000, 0xac21604b, 0x00000008, 0x01000000,
0x2c000000, 0xb421644b, 0x00000008, 0x40000000, 0x04000000, 0x20220002, 0x00060000, 0x33020a80,
0x140c6000, 0x64000070, 0x00000021, 0x01000000, 0x08008000, 0xe0218043, 0x00008d04, 0x01000000,
0x08008000, 0x2021a043, 0x00008d06, 0x01000000, 0x08008000, 0xa021c043, 0x00008d04, 0x01000000,
0x08008000, 0x2021e043, 0x00008d08, 0x01000000, 0x2c006000, 0x0020404b, 0x00008d00, 0x01000000,
0x0c000000, 0x00204806, 0x1f000000, 0x01000300, 0x2c000000, 0xa820404b, 0x00000008, 0x01000000,
0x2c000000, 0xb420444b, 0x00000008, 0x40000000, 0x04000000, 0x20220002, 0x00060000, 0x33020a80,
0x140c6000, 0x440000c0, 0x00000020, 0x01000000, 0x08008000, 0x00206043, 0x00008d05, 0x01000000,
0x08008000, 0x40208043, 0x00008d06, 0x01000000, 0x08008000, 0xc020a043, 0x00008d04, 0x01000000,
0x08008000, 0x4020c043, 0x00008d08, 0x01000000, 0x2c006000, 0x0020e04b, 0x00008d00, 0x01000000,
0x0c000000, 0x0020e806, 0x1f000000, 0x01000300, 0x2c000000, 0xa420e04b, 0x00000008, 0x01000000,
0x2c000000, 0xb420e44b, 0x00000008, 0x40000000, 0x04000000, 0x20220002, 0x00060000, 0x33020a80,
0x140c6000, 0xe4000030, 0x00000020, 0x01000000, 0x08008000, 0x60210043, 0x00008d04, 0x01000000,
0x08008000, 0x20212043, 0x00008d04, 0x01000000, 0x08008000, 0xe0214043, 0x00008d03, 0x01000000,
0x08008000, 0x20216043, 0x00008d03, 0x01000000, 0x2c006000, 0x0020404b, 0x00008d00, 0x01000000,
0x0c000000, 0x00204806, 0x1f000000, 0x01000300, 0x2c000000, 0xb020404b, 0x00000008, 0x01000000,
0x2c000000, 0xa020444b, 0x00000008, 0x40000000, 0x04000000, 0x20220002, 0x00060000, 0x33020a80,
0x140c6000, 0x44000080, 0x00000020, 0x01000000, 0x08008000, 0x80218043, 0x00008d04, 0x01000000,
0x08008000, 0x4021a043, 0x00008d04, 0x01000000, 0x08008000, 0x0021c043, 0x00008d04, 0x01000000,
0x08008000, 0x4021e043, 0x00008d03, 0x01000000, 0x2c006000, 0x0020604b, 0x00008d00, 0x01000000,
0x0c000000, 0x00206806, 0x1f000000, 0x01000300, 0x2c000000, 0xac20604b, 0x00000008, 0x01000000,
0x2c000000, 0xa020644b, 0x00000008, 0x40000000, 0x04000000, 0x20220002, 0x00060000, 0x33020a80,
0x140c6000, 0x640000c0, 0x00000020, 0x01000000, 0x08008000, 0x60208043, 0x00008d08, 0x01000000,
0x08008000, 0x6020a043, 0x00008d07, 0x01000000, 0x08008000, 0x2020c043, 0x00008d07, 0x01000000,
0x08008000, 0xa020e043, 0x00008d07, 0x01000000, 0x2c006000, 0x0020404b, 0x00008d00, 0x01000000,
0x0c000000, 0x00204806, 0x1f000000, 0x01000300, 0x2c000000, 0xa820404b, 0x00000008, 0x01000000,
0x2c000000, 0xa020444b, 0x00000008, 0x40000000, 0x04000000, 0x20220002, 0x00060000, 0x33020a80,
0x140c6000, 0x44000040, 0x00000020, 0x01000000, 0x08008000, 0x80210043, 0x00008d08, 0x01000000,
0x08008000, 0x80212043, 0x00008d07, 0x01000000, 0x08008000, 0x40214043, 0x00008d07, 0x01000000,
0x08008000, 0xc0216043, 0x00008d07, 0x01000000, 0x2c006000, 0x0020604b, 0x00008d00, 0x01000000,
0x0c000000, 0x00206806, 0x1f000000, 0x01000300, 0x2c000000, 0xa420604b, 0x00000008, 0x01000000,
0x2c000000, 0xa020644b, 0x00000008, 0x40000000, 0x04000000, 0x20220002, 0x00060000, 0x33020a80,
0x140c6000, 0x64000080, 0x00000020, 0x01000000, 0x2c006000, 0x002fe04b, 0x00008d00, 0x31000000,
0x00070000, 0xe020004a, 0x1006000f, 0x38820000, 0x280a8000, 0x8020804b, 0x1c4a8d00, 0x01000002,
0x28000000, 0x0020284f, 0x00000000, 0x5b3f8000, 0x08008000, 0x01020040, 0x08072014, 0x5b03f804,
0x08008000, 0x01040040, 0x1dc020de, 0x38010084, 0x28098000, 0x8020804b, 0x404a8d00, 0x7e008d00,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x8025a04b, 0x3c4a8d00, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x4021404b, 0x1c4a8d01, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x5b000000, 0x08008000, 0x01040040, 0x14072014, 0x5b03f804,
0x08008000, 0x010a0040, 0x1dc020de, 0x38028084, 0x28098000, 0x4021404b, 0x804a8d01, 0x7e008d00,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x4024e04b, 0x3c4a8d01, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x002a004b, 0x1c4a8d0a, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x5b000000, 0x08008000, 0x01060040, 0xa0072014, 0x5b03f804,
0x08008000, 0x01500040, 0x1dc020de, 0x38140084, 0x28098000, 0x002a004b, 0xc04a8d0a, 0x7e008d00,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x0026604b, 0x3c4a8d0a, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x402a404b, 0x1c4a8d0a, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x5b000000, 0x08008000, 0x01020040, 0xa4072014, 0x5b03f804,
0x08008000, 0x01520040, 0x1dc020de, 0x38148084, 0x28098000, 0x402a404b, 0x404a8d0a, 0x7e008d00,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x4026204b, 0x3c4a8d0a, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x6025604b, 0x1c4a8d05, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x5b000000, 0x08008000, 0x01040040, 0x56072014, 0x5b03f804,
0x08008000, 0x012b0040, 0x1dc020de, 0x380ac084, 0x28098000, 0x6025604b, 0x804a8d05, 0x7e008d00,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x6025e04b, 0x3c4a8d05, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0xe023e04b, 0x1c4a8d03, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x5b000000, 0x08008000, 0x01060040, 0x3e072014, 0x5b03f804,
0x08008000, 0x011f0040, 0x1dc020de, 0x3807c084, 0x28098000, 0xe023e04b, 0xc04a8d03, 0x7e008d00,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0xe024a04b, 0x3c4a8d03, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x2024204b, 0x1c4a8d04, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x5b000000, 0x08008000, 0x01020040, 0x42072014, 0x5b03f804,
0x08008000, 0x01210040, 0x1dc020de, 0x38084084, 0x28098000, 0x2024204b, 0x404a8d04, 0x7e008d00,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x2027e04b, 0x3c4a8d04, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0xc029c04b, 0x1c4a8d09, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x5b000000, 0x08008000, 0x01040040, 0x9c072014, 0x5b03f804,
0x08008000, 0x014e0040, 0x1dc020de, 0x38138084, 0x28098000, 0xc029c04b, 0x804a8d09, 0x7e008d00,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0xc028204b, 0x3c4a8d09, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x0029004b, 0x1c4a8d09, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x5b000000, 0x08008000, 0x01060040, 0x90072014, 0x5b03f804,
0x08008000, 0x01480040, 0x1dc020de, 0x38120084, 0x28098000, 0x0029004b, 0xc04a8d09, 0x7e008d00,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x0024604b, 0x3c4a8d09, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0xa027a04b, 0x1c4a8d07, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x5b000000, 0x08008000, 0x01020040, 0x7a072014, 0x5b03f804,
0x08008000, 0x013d0040, 0x1dc020de, 0x380f4084, 0x28098000, 0xa027a04b, 0x404a8d07, 0x7e008d00,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0xa028604b, 0x3c4a8d07, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x6027604b, 0x1c4a8d07, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x5b000000, 0x08008000, 0x01040040, 0x76072014, 0x5b03f804,
0x08008000, 0x013b0040, 0x1dc020de, 0x380ec084, 0x28098000, 0x6027604b, 0x804a8d07, 0x7e008d00,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x6024204b, 0x3c4a8d07, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x2027204b, 0x1c4a8d07, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x5b000000, 0x08008000, 0x01060040, 0x72072014, 0x5b03f804,
0x08008000, 0x01390040, 0x1dc020de, 0x380e4084, 0x28098000, 0x2027204b, 0xc04a8d07, 0x7e008d00,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x2027604b, 0x3c4a8d07, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x0023004b, 0x1c4a8d03, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x5b000000, 0x08008000, 0x01020040, 0x30072014, 0x5b03f804,
0x08008000, 0x01180040, 0x1dc020de, 0x38060084, 0x28098000, 0x0023004b, 0x404a8d03, 0x7e008d00,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x0023e04b, 0x3c4a8d03, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x4029404b, 0x1c4a8d09, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x5b000000, 0x08008000, 0x01040040, 0x94072014, 0x5b03f804,
0x08008000, 0x014a0040, 0x1dc020de, 0x38128084, 0x28098000, 0x4029404b, 0x804a8d09, 0x7e008d00,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x4027204b, 0x3c4a8d09, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x8029804b, 0x1c4a8d09, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x5b000000, 0x08008000, 0x01060040, 0x98072014, 0x5b03f804,
0x08008000, 0x014c0040, 0x1dc020de, 0x38130084, 0x28098000, 0x8029804b, 0xc04a8d09, 0x7e008d00,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x8023204b, 0x3c4a8d09, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0xc028c04b, 0x1c4a8d08, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x5b000000, 0x08008000, 0x01020040, 0x8c072014, 0x5b03f804,
0x08008000, 0x01460040, 0x1dc020de, 0x38118084, 0x28098000, 0xc028c04b, 0x404a8d08, 0x7e008d00,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0xc027a04b, 0x3c4a8d08, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x0021004b, 0x1c4a8d01, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x5b000000, 0x08008000, 0x01040040, 0x10072014, 0x5b03f804,
0x08008000, 0x01080040, 0x1dc020de, 0x38020084, 0x28098000, 0x0021004b, 0x804a8d01, 0x7e008d00,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x0025604b, 0x3c4a8d01, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x8022804b, 0x1c4a8d02, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x5b000000, 0x08008000, 0x01060040, 0x28072014, 0x5b03f804,
0x08008000, 0x01140040, 0x1dc020de, 0x38050084, 0x28098000, 0x8022804b, 0xc04a8d02, 0x7e008d00,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x8028c04b, 0x3c4a8d02, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0xc022c04b, 0x1c4a8d02, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x5b000000, 0x08008000, 0x01020040, 0x2c072014, 0x5b03f804,
0x08008000, 0x01160040, 0x1dc020de, 0x38058084, 0x28098000, 0xc022c04b, 0x404a8d02, 0x7e008d00,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0xc022804b, 0x3c4a8d02, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0xa023a04b, 0x1c4a8d03, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x5b000000, 0x08008000, 0x01040040, 0x3a072014, 0x5b03f804,
0x08008000, 0x011d0040, 0x1dc020de, 0x38074084, 0x28098000, 0xa023a04b, 0x804a8d03, 0x7e008d00,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0xa022c04b, 0x3c4a8d03, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0xe026e04b, 0x1c4a8d06, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x5b000000, 0x08008000, 0x01060040, 0x6e072014, 0x5b03f804,
0x08008000, 0x01370040, 0x1dc020de, 0x380dc084, 0x28098000, 0xe026e04b, 0xc04a8d06, 0x7e008d00,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0xe023a04b, 0x3c4a8d06, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0xa026a04b, 0x1c4a8d06, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x5b000000, 0x08008000, 0x01020040, 0x6a072014, 0x5b03f804,
0x08008000, 0x01350040, 0x1dc020de, 0x380d4084, 0x28098000, 0xa026a04b, 0x404a8d06, 0x7e008d00,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0xa026e04b, 0x3c4a8d06, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x6023604b, 0x1c4a8d03, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x5b000000, 0x08008000, 0x01040040, 0x36072014, 0x5b03f804,
0x08008000, 0x011b0040, 0x1dc020de, 0x3806c084, 0x28098000, 0x6023604b, 0x804a8d03, 0x7e008d00,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x6021004b, 0x3c4a8d03, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x2025204b, 0x1c4a8d05, 0x7e000002,
0x00000000, 0x00000000, 0x00000000, 0x5b000000, 0x08008000, 0x01060040, 0x52072014, 0x5b03f804,
0x08008000, 0x01290040, 0x1dc020de, 0x380a4084, 0x28098000, 0x2025204b, 0xc04a8d05, 0x7e008d00,
0x00000000, 0x00000000, 0x00000000, 0x38000000, 0x280a8000, 0x2020604b, 0x3c4a8d05, 0x20000002,
0x04100000, 0x00340000, 0x400e0014, 0x01ffffe6, 0x28000000, 0x0021bc4f, 0xb0000000, 0x013b4d20,
0x28000000, 0x0021dc4f, 0x52000000, 0x01414eb8, 0x28000000, 0x0021fc4f, 0x3d000000, 0x013f870a,
0x28000000, 0x00221c4f, 0xae000000, 0x01bd6147, 0x28000000, 0x00223c4f, 0xc5000000, 0x203ed555,
0x04100000, 0x00340000, 0xc00e0014, 0x10ffffdc, 0x20010000, 0x9c20000a, 0x001e0001, 0x20000000,
0x04101100, 0x00340000, 0x800e0014, 0x01ffffff, 0x28000000, 0x0021bc4f, 0xfb000000, 0x013c93e5,
0x28000000, 0x0021dc4f, 0x00000000, 0x01409000, 0x28000000, 0x0021fc4f, 0xc4000000, 0x013f8cb5,
0x28000000, 0x00221c4f, 0x3a000000, 0x01bdcb5c, 0x28000000, 0x00223c4f, 0x66000000, 0x203ee666,
0x04100000, 0x00340000, 0x400e0014, 0x10ffffdc, 0x20010000, 0x5820000a, 0x011e0002, 0x01000100,
0x28000000, 0x0022584f, 0x00000000, 0x013e8000, 0x28000000, 0x00225c4f, 0x00000000, 0x013f2000,
0x28000000, 0x0022784f, 0x00000000, 0x203e0000, 0x04101100, 0x00340000, 0xa00e0014, 0x10ffffc3,
0x22038000, 0x2020004b, 0x044a8d05, 0x0200000a, 0x2a008100, 0xe425604b, 0xe04a0009, 0x10000009,
0x21038000, 0x2020004b, 0x084a8d05, 0x0200000a, 0x29008100, 0xe825604b, 0x604a0009, 0x10008d05,
0x20038000, 0x2020004b, 0x0c4a8d05, 0x0200000a, 0x28008100, 0xec25604b, 0x604a0009, 0x10008d05,
0x23038000, 0x2020004b, 0x104a8d05, 0x0100000a, 0x4c000000, 0x22202810, 0x00000006, 0x02000000,
0x2b008100, 0xf025604b, 0x604a0009, 0x10008d05, 0x23038000, 0x2020004b, 0x144a8d05, 0x0100000a,
0x4c000000, 0x22202a10, 0x00000006, 0x02000000, 0x2b008100, 0xf425604b, 0x604a0009, 0x02008d05,
0x2a008100, 0xc425204b, 0xc04a0009, 0x02000009, 0x29008100, 0xc825204b, 0x204a0009, 0x02008d05,
0x28008100, 0xcc25204b, 0x204a0009, 0x01008d05, 0x44000000, 0x28260012, 0x00000000, 0x02000000,
0x28008100, 0xd025204b, 0x204a0009, 0x01008d05, 0x44000000, 0x2a260012, 0x00000000, 0x02000000,
0x28008100, 0xd425204b, 0x204a0009, 0x5b008d05, 0x08008000, 0x39210040, 0x42072290, 0x5b0ac084,
0x08008000, 0x39190040, 0x32072290, 0x5b0ac084, 0x08008000, 0x39170040, 0x2e072290, 0x5b0ac084,
0x08008000, 0x39150040, 0x2a072290, 0x5b0ac084, 0x08008000, 0x391f0040, 0x3e072290, 0x5b0ac084,
0x08008000, 0x39270040, 0x4e072290, 0x5b0ac084, 0x08008000, 0x391d0040, 0x3a072290, 0x5b0ac084,
0x08008000, 0x39230040, 0x46072290, 0x5b0ac084, 0x08008000, 0x39480040, 0x76072290, 0x5b0ac084,
0x08008000, 0x393d0040, 0x72072290, 0x5b0ac084, 0x08008000, 0x393b0040, 0x6e072290, 0x5b0ac084,
0x08008000, 0x39390040, 0x6a072290, 0x5b0ac084, 0x08008000, 0x392f0040, 0x5e072290, 0x5b0ac084,
0x08008000, 0x39310040, 0x62072290, 0x5b0ac084, 0x08008000, 0x393f0040, 0x7e072290, 0x5b0ac084,
0x08008000, 0x39410040, 0x82072290, 0x5b0ac084, 0x08008000, 0x39430040, 0x86072290, 0x5b0ac084,
0x08008000, 0x39250040, 0x4a072290, 0x5b0ac084, 0x08008000, 0x39460040, 0x8c072290, 0x5b0ac084,
0x08008000, 0x392d0040, 0x5a072290, 0x5b0ac084, 0x08008000, 0x39370040, 0x98072290, 0x5b0ac084,
0x08008000, 0x39350040, 0x36072290, 0x5b0ac084, 0x08008000, 0x391b0040, 0x94072290, 0x5b0ac084,
0x08008000, 0x39290040, 0x66072290, 0x200ac084, 0x04100000, 0x00340000, 0x200e0014, 0x01ffffd1,
0x28000000, 0x0022584f, 0x9d000000, 0x013e8680, 0x28000000, 0x00225c4f, 0x68000000, 0x013f2d91,
0x28000000, 0x0022784f, 0x8f000000, 0x203d72e4, 0x04100000, 0x00340000, 0xa00e0014, 0x10ffffc0,
0x20010000, 0x5820000a, 0x021e0002, 0x20000200, 0x04101100, 0x00340000, 0x900e0014, 0x01fffffc,
0x28000000, 0x0022584f, 0x00000000, 0x013e8000, 0x28000000, 0x00225c4f, 0x00000000, 0x013f0000,
0x28000000, 0x0022784f, 0x00000000, 0x203e8000, 0x04100000, 0x00340000, 0x400e0014, 0x01ffffc0,
0x28000000, 0x0027a04f, 0x00000000, 0x01000000, 0x28000000, 0x002a044f, 0x6e000000, 0x013d0034,
0x28000000, 0x0027a44f, 0x6e000000, 0x383d0034, 0x28090000, 0x7c27b44b, 0x004e0002, 0x10461c40,
0x20030000, 0x2820004b, 0x244a0000, 0x20000000, 0x04000100, 0x00340000, 0x500e0014, 0x38000000,
0x28090000, 0x7c2a084b, 0x004e0002, 0x38461c40, 0x28090000, 0x7c2a0c4b, 0x004e0002, 0x38461c40,
0x28090000, 0x7c2a104b, 0x004e0002, 0x38461c40, 0x28090000, 0x7c2a144b, 0x004e0002, 0x20461c40,
0x04100000, 0x00340000, 0x000e0014, 0x38ffffbf, 0x28090000, 0x782a144b, 0x004e0002, 0x41461c40,
0x28000000, 0x1420284b, 0x004e000a, 0x01420000, 0x28000000, 0x28202c4a, 0x00000000, 0x01000000,
0x28000000, 0x2c20300b, 0x00000000, 0x10000000, 0x20020000, 0x3020004b, 0x284a0000, 0x01000000,
0x68000000, 0x0020401e, 0x01000000, 0x02000100, 0x28000100, 0x4020601a, 0x001e0000, 0x40000000,
0x28000000, 0x6020600a, 0x2c0a0000, 0x01000000, 0x28000000, 0x6020800b, 0x00000000, 0x41000000,
0x28000000, 0x802a144b, 0x004e0000, 0x403d0000, 0x28000000, 0x1420a04b, 0x044a000a, 0x3800004a,
0x28090000, 0xa020a04b, 0x004e0000, 0x4040a000, 0x28000000, 0x042a084b, 0xa04a000a, 0x40000000,
0x28000000, 0x1420c04b, 0x044a000a, 0x4100004a, 0x28000000, 0xc020c04b, 0x004e0000, 0x38400000,
0x28090000, 0xc020c04b, 0x004e0000, 0x4040a000, 0x28000000, 0x042a0c4b, 0xc04a000a, 0x40000000,
0x28000000, 0x1420e04b, 0x044a000a, 0x4100004a, 0x28000000, 0xe020e04b, 0x004e0000, 0x38404000,
0x28090000, 0xe020e04b, 0x004e0000, 0x4040a000, 0x28000000, 0x042a104b, 0xe04a000a, 0x41000000,
0x28000000, 0x0820284b, 0x004e000a, 0x01420000, 0x28000000, 0x2820404a, 0x00000000, 0x01000000,
0x28000000, 0x4020600b, 0x00000000, 0x41000000, 0x28000000, 0x602a084b, 0x004e0000, 0x413d0000,
0x28000000, 0x0c20804b, 0x004e000a, 0x01420000, 0x28000000, 0x8020a04a, 0x00000000, 0x01000000,
0x28000000, 0xa021000b, 0x00000000, 0x41000000, 0x28000000, 0x002a0c4b, 0x004e0001, 0x413d0000,
0x28000000, 0x1020c04b, 0x004e000a, 0x01420000, 0x28000000, 0xc021204a, 0x00000000, 0x01000000,
0x28000000, 0x2021400b, 0x00000001, 0x41000000, 0x28000000, 0x402a104b, 0x004e0001, 0x413d0000,
0x28000000, 0xb427b04b, 0x334e0007, 0x103f7333, 0x20030000, 0xb020004b, 0x104a0007, 0x2000000a,
0x04001100, 0x00340000, 0x100e0014, 0x01000000, 0x28000000, 0x1027b04b, 0x0000000a, 0x40000000,
0x28000000, 0xb020284b, 0xa44a0007, 0x01000047, 0x28000000, 0x0028b84f, 0x33000000, 0x5b3f3333,
0x08000000, 0x013d4040, 0x8b8023d2, 0x10005004, 0x20030000, 0xa820004b, 0x084a0007, 0x2000000a,
0x04001100, 0x00340000, 0x100e0014, 0x01000000, 0x28000000, 0x0827a84b, 0x0000000a, 0x40000000,
0x28000000, 0xb020284b, 0xa84a0007, 0x5b000047, 0x0c000000, 0x01020040, 0x8b8023d4, 0x01005004,
0x28000000, 0x4027ac4b, 0x00000000, 0x10000000, 0x20030000, 0xac20004b, 0x0c4a0007, 0x2000000a,
0x04001100, 0x00340000, 0x100e0014, 0x01000000, 0x28000000, 0x0c27ac4b, 0x0000000a, 0x40000000,
0x28030000, 0x0420284b, 0x004a000a, 0x0100004a, 0x28000000, 0x0020244f, 0x00000000, 0x20000000,
0x04001100, 0x00340000, 0x200e0014, 0x40000000, 0x28000000, 0xa420244b, 0xa04a0007, 0x38000047,
0x28090000, 0x2420244b, 0x284a0000, 0x01000000, 0x28000000, 0x2429e04b, 0x00000000, 0x40000000,
0x28030000, 0x0820284b, 0x044a000a, 0x0100004a, 0x28000000, 0x0020244f, 0x00000000, 0x20000000,
0x04001100, 0x00340000, 0x200e0014, 0x40000000, 0x28000000, 0xa820244b, 0xa44a0007, 0x38000047,
0x28090000, 0x2420244b, 0x284a0000, 0x01000000, 0x28000000, 0x2429e44b, 0x00000000, 0x40000000,
0x28030000, 0x0c20284b, 0x084a000a, 0x0100004a, 0x28000000, 0x0020244f, 0x00000000, 0x20000000,
0x04001100, 0x00340000, 0x200e0014, 0x40000000, 0x28000000, 0xac20244b, 0xa84a0007, 0x38000047,
0x28090000, 0x2420244b, 0x284a0000, 0x01000000, 0x28000000, 0x2429e84b, 0x00000000, 0x40000000,
0x28030000, 0x1020284b, 0x0c4a000a, 0x0100004a, 0x28000000, 0x0020244f, 0x00000000, 0x20000000,
0x04001100, 0x00340000, 0x200e0014, 0x40000000, 0x28000000, 0xb020244b, 0xac4a0007, 0x38000047,
0x28090000, 0x2420244b, 0x284a0000, 0x01000000, 0x28000000, 0x2429ec4b, 0x00000000, 0x40000000,
0x28030000, 0x1420284b, 0x104a000a, 0x0100004a, 0x28000000, 0x0020244f, 0x00000000, 0x20000000,
0x04001100, 0x00340000, 0x200e0014, 0x40000000, 0x28000000, 0xb420244b, 0xb04a0007, 0x38000047,
0x28090000, 0x2420244b, 0x284a0000, 0x01000000, 0x28000000, 0x2429f04b, 0x00000000, 0x01000000,
0x28000000, 0x0029f44f, 0x00000000, 0x5b000000, 0x08000000, 0x014e0041, 0xa00023d0, 0x5b13c004,
0x0c000000, 0x01020041, 0xa04023d2, 0x0113c804, 0x28000000, 0x4029c44b, 0x00000000, 0x5b000000,
0x08000000, 0x014e4041, 0xa08023d4, 0x5b13d004, 0x0c000000, 0x01030041, 0xa0c023d6, 0x0113d804,
0x28000000, 0x6029cc4b, 0x00000000, 0x5b000000, 0x08000000, 0x014e8041, 0xa10023d8, 0x5b13e004,
0x0c000000, 0x01040041, 0xa14023da, 0x0113e804, 0x28000000, 0x8029d44b, 0x00000000, 0x20000000,
0x04100000, 0x00340000, 0x600e0014, 0x00ffffb9
};
#else
extern const unsigned int IGVP3DLUT_GENERATION_G11_ICLLP_SIZE = 216;
extern const unsigned int IGVP3DLUT_GENERATION_G11_ICLLP[] =
{
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
};
#endif
|
the_stack_data/1070063.c | #include <stdio.h>
#define max(a,b) a>b?a:b
#define min(a,b) a<b?a:b
int main()
{
int n,k,a[20000]={0},i,N=0,M=1,H,l,r;
scanf("%d%d",&n,&k);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
while(k--){
N=0,M=1;
scanf("%d%d",&l,&r);
for(i=l;i<=r;i++){
N+=a[i]%n;
N%=n;
M*=a[i]%n;
M%=n;
}
l=min(N,M),r=max(N,M);
H=a[l];
for(i=l+1;i<=r;i++)
H=H^a[i];
printf("%d\n",H);
}
return 0;
} |
the_stack_data/788835.c | int main() {
int matrix_reloaded[3][4] = {{1, 2, 3, 4},
{5, 6, 7, 8},
{9,10,11,12} };
int a = matrix_reloaded[1][1]; // a=6
int b = matrix_reloaded[2][0]; // b=9
return 0;
}
|
the_stack_data/28130.c | #include <stdio.h>
#include <stdlib.h>
int main(void) {
printf("%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n%d=>%c %d %c\n", 1, '\x01', (int)('\x01'), (char)(1), 2, '\x02', (int)('\x02'), (char)(2), 3, '\x03', (int)('\x03'), (char)(3), 4, '\x04', (int)('\x04'), (char)(4), 5, '\x05', (int)('\x05'), (char)(5), 6, '\x06', (int)('\x06'), (char)(6), 7, '\x07', (int)('\x07'), (char)(7), 8, '\b', (int)('\b'), (char)(8), 9, '\t', (int)('\t'), (char)(9), 10, '\n', (int)('\n'), (char)(10), 11, '\x0b', (int)('\x0b'), (char)(11), 12, '\x0c', (int)('\x0c'), (char)(12), 13, '\r', (int)('\r'), (char)(13), 14, '\x0e', (int)('\x0e'), (char)(14), 15, '\x0f', (int)('\x0f'), (char)(15), 16, '\x10', (int)('\x10'), (char)(16), 17, '\x11', (int)('\x11'), (char)(17), 18, '\x12', (int)('\x12'), (char)(18), 19, '\x13', (int)('\x13'), (char)(19), 20, '\x14', (int)('\x14'), (char)(20), 21, '\x15', (int)('\x15'), (char)(21), 22, '\x16', (int)('\x16'), (char)(22), 23, '\x17', (int)('\x17'), (char)(23), 24, '\x18', (int)('\x18'), (char)(24), 25, '\x19', (int)('\x19'), (char)(25), 26, '\x1a', (int)('\x1a'), (char)(26), 27, '\x1b', (int)('\x1b'), (char)(27), 28, '\x1c', (int)('\x1c'), (char)(28), 29, '\x1d', (int)('\x1d'), (char)(29), 30, '\x1e', (int)('\x1e'), (char)(30), 31, '\x1f', (int)('\x1f'), (char)(31), 32, ' ', (int)(' '), (char)(32), 33, '!', (int)('!'), (char)(33), 34, '"', (int)('"'), (char)(34), 35, '#', (int)('#'), (char)(35), 36, '$', (int)('$'), (char)(36), 37, '%', (int)('%'), (char)(37), 38, '&', (int)('&'), (char)(38), 39, '\'', (int)('\''), (char)(39), 40, '(', (int)('('), (char)(40), 41, ')', (int)(')'), (char)(41), 42, '*', (int)('*'), (char)(42), 43, '+', (int)('+'), (char)(43), 44, ',', (int)(','), (char)(44), 45, '-', (int)('-'), (char)(45), 46, '.', (int)('.'), (char)(46), 47, '/', (int)('/'), (char)(47), 48, '0', (int)('0'), (char)(48), 49, '1', (int)('1'), (char)(49), 50, '2', (int)('2'), (char)(50), 51, '3', (int)('3'), (char)(51), 52, '4', (int)('4'), (char)(52), 53, '5', (int)('5'), (char)(53), 54, '6', (int)('6'), (char)(54), 55, '7', (int)('7'), (char)(55), 56, '8', (int)('8'), (char)(56), 57, '9', (int)('9'), (char)(57), 58, ':', (int)(':'), (char)(58), 59, ';', (int)(';'), (char)(59), 60, '<', (int)('<'), (char)(60), 61, '=', (int)('='), (char)(61), 62, '>', (int)('>'), (char)(62), 63, '?', (int)('?'), (char)(63), 64, '@', (int)('@'), (char)(64), 65, 'A', (int)('A'), (char)(65), 66, 'B', (int)('B'), (char)(66), 67, 'C', (int)('C'), (char)(67), 68, 'D', (int)('D'), (char)(68), 69, 'E', (int)('E'), (char)(69), 70, 'F', (int)('F'), (char)(70), 71, 'G', (int)('G'), (char)(71), 72, 'H', (int)('H'), (char)(72), 73, 'I', (int)('I'), (char)(73), 74, 'J', (int)('J'), (char)(74), 75, 'K', (int)('K'), (char)(75), 76, 'L', (int)('L'), (char)(76), 77, 'M', (int)('M'), (char)(77), 78, 'N', (int)('N'), (char)(78), 79, 'O', (int)('O'), (char)(79), 80, 'P', (int)('P'), (char)(80), 81, 'Q', (int)('Q'), (char)(81), 82, 'R', (int)('R'), (char)(82), 83, 'S', (int)('S'), (char)(83), 84, 'T', (int)('T'), (char)(84), 85, 'U', (int)('U'), (char)(85), 86, 'V', (int)('V'), (char)(86), 87, 'W', (int)('W'), (char)(87), 88, 'X', (int)('X'), (char)(88), 89, 'Y', (int)('Y'), (char)(89), 90, 'Z', (int)('Z'), (char)(90), 91, '[', (int)('['), (char)(91), 92, '\\', (int)('\\'), (char)(92), 93, ']', (int)(']'), (char)(93), 94, '^', (int)('^'), (char)(94), 95, '_', (int)('_'), (char)(95), 96, '`', (int)('`'), (char)(96), 97, 'a', (int)('a'), (char)(97), 98, 'b', (int)('b'), (char)(98), 99, 'c', (int)('c'), (char)(99), 100, 'd', (int)('d'), (char)(100), 101, 'e', (int)('e'), (char)(101), 102, 'f', (int)('f'), (char)(102), 103, 'g', (int)('g'), (char)(103), 104, 'h', (int)('h'), (char)(104), 105, 'i', (int)('i'), (char)(105), 106, 'j', (int)('j'), (char)(106), 107, 'k', (int)('k'), (char)(107), 108, 'l', (int)('l'), (char)(108), 109, 'm', (int)('m'), (char)(109), 110, 'n', (int)('n'), (char)(110), 111, 'o', (int)('o'), (char)(111), 112, 'p', (int)('p'), (char)(112), 113, 'q', (int)('q'), (char)(113), 114, 'r', (int)('r'), (char)(114), 115, 's', (int)('s'), (char)(115), 116, 't', (int)('t'), (char)(116), 117, 'u', (int)('u'), (char)(117), 118, 'v', (int)('v'), (char)(118), 119, 'w', (int)('w'), (char)(119), 120, 'x', (int)('x'), (char)(120), 121, 'y', (int)('y'), (char)(121), 122, 'z', (int)('z'), (char)(122), 123, '{', (int)('{'), (char)(123), 124, '|', (int)('|'), (char)(124), 125, '}', (int)('}'), (char)(125), 126, '~', (int)('~'), (char)(126), 127, '\x7f', (int)('\x7f'), (char)(127));
return 0;
}
|
the_stack_data/87972.c | // this source is derived from CHILL AST originally from file '/uufs/chpc.utah.edu/common/home/u1142914/lib/ytopt_vinu/polybench/polybench-code/stencils/heat-3d/kernel.c' as parsed by frontend compiler rose
void kernel_heat_3d(int tsteps, int n, double A[120 + 0][120 + 0][120 + 0], double B[120 + 0][120 + 0][120 + 0]) {
int t12;
int t10;
int t8;
int t6;
int t4;
int t2;
for (t2 = 1; t2 <= 500; t2 += 1) {
#pragma omp parallel for private(t4,t8,t10,t12,t14)
for (t4 = 1; t4 <= n - 2; t4 += 8)
for (t6 = t4; t6 <= (t4 + 7 < n - 2 ? t4 + 7 : n - 2); t6 += 1)
for (t8 = 1; t8 <= n - 2; t8 += 16)
for (t10 = t8; t10 <= (t8 + 15 < n - 2 ? t8 + 15 : n - 2); t10 += 1)
for (t12 = 1; t12 <= n - 2; t12 += 1)
B[t6][t10][t12] = 0.125 * (A[t6 + 1][t10][t12] - 2 * A[t6][t10][t12] + A[t6 - 1][t10][t12]) + 0.125 * (A[t6][t10 + 1][t12] - 2 * A[t6][t10][t12] + A[t6][t10 - 1][t12]) + 0.125 * (A[t6][t10][t12 + 1] - 2 * A[t6][t10][t12] + A[t6][t10][t12 - 1]) + A[t6][t10][t12];
#pragma omp parallel for private(t4,t8,t10,t12,t14)
for (t4 = 1; t4 <= n - 2; t4 += 8)
for (t6 = t4; t6 <= (t4 + 7 < n - 2 ? t4 + 7 : n - 2); t6 += 1)
for (t8 = 1; t8 <= n - 2; t8 += 16)
for (t10 = t8; t10 <= (t8 + 15 < n - 2 ? t8 + 15 : n - 2); t10 += 1)
for (t12 = 1; t12 <= n - 2; t12 += 1)
A[t6][t10][t12] = 0.125 * (B[t6 + 1][t10][t12] - 2 * B[t6][t10][t12] + B[t6 - 1][t10][t12]) + 0.125 * (B[t6][t10 + 1][t12] - 2 * B[t6][t10][t12] + B[t6][t10 - 1][t12]) + 0.125 * (B[t6][t10][t12 + 1] - 2 * B[t6][t10][t12] + B[t6][t10][t12 - 1]) + B[t6][t10][t12];
}
}
|
the_stack_data/95449489.c | #include <stdio.h>
int main(void)
{
int n;
long long a = 0;
scanf("%d", &n);
while (--n) {
long long w;
scanf("%*d%*d%lld", &w);
a += w;
}
printf("%lld\n", a);
return 0;
}
|
the_stack_data/120481.c | #include <stdio.h>
#include <stdlib.h>
int main(void)
{
FILE *fp;
if(NULL == (fp = fopen("source.txt", "w"))){
printf("打开文件失败\n");
exit(EXIT_FAILURE);
}
fputc('K', fp);
printf("%ld\n",ftell(fp));
fputs("iss\n", fp);
printf("%ld\n",ftell(fp));
fprintf(fp, "%s", "keep it simple stupid\n");
printf("%ld\n", ftell(fp));
fclose(fp);
return 0;
}
|
the_stack_data/32949172.c | #include <stdio.h>
int print_hash_value = 1;
static void platform_main_begin(void)
{
}
static unsigned crc32_tab[256];
static unsigned crc32_context = 0xFFFFFFFFUL;
static void
crc32_gentab (void)
{
unsigned crc;
unsigned poly = 0xEDB88320UL;
int i, j;
for (i = 0; i < 256; i++) {
crc = i;
for (j = 8; j > 0; j--) {
if (crc & 1) {
crc = (crc >> 1) ^ poly;
} else {
crc >>= 1;
}
}
crc32_tab[i] = crc;
}
}
static void
crc32_byte (unsigned char b) {
crc32_context =
((crc32_context >> 8) & 0x00FFFFFF) ^
crc32_tab[(crc32_context ^ b) & 0xFF];
}
extern int strcmp ( char *, char *);
static void
crc32_8bytes (unsigned val)
{
crc32_byte ((val>>0) & 0xff);
crc32_byte ((val>>8) & 0xff);
crc32_byte ((val>>16) & 0xff);
crc32_byte ((val>>24) & 0xff);
}
static void
transparent_crc (unsigned val, char* vname, int flag)
{
crc32_8bytes(val);
if (flag) {
printf("...checksum after hashing %s : %X\n", vname, crc32_context ^ 0xFFFFFFFFU);
}
}
static void
platform_main_end (int x, int flag)
{
if (!flag) printf ("checksum = %x\n", x);
}
static long __undefined;
void csmith_compute_hash(void);
void step_hash(int stmt_id);
static unsigned g_2 = 1UL;
static signed char g_3 = 0xDBL;
static int g_6 = (-1L);
static int g_13 = 4L;
static int g_16 = 0x7E813A3DL;
static int g_75 = 0x8177C418L;
static unsigned g_76 = 0x34605DD8L;
static int g_80 = 0L;
static int *g_156 = &g_75;
static int **g_155 = &g_156;
static int g_202 = 9L;
static int g_211 = (-2L);
static unsigned g_369 = 0UL;
static unsigned short g_463 = 1UL;
static int *g_468 = &g_202;
static unsigned short func_1(void);
static int func_17(unsigned p_18, int * p_19, int * p_20);
static short func_25(int p_26, int * p_27, int * p_28, int * p_29);
static int func_30(int * p_31, int * p_32, unsigned p_33, int * p_34);
static int * func_35(unsigned p_36, unsigned p_37, int * p_38, int * p_39, short p_40);
static unsigned func_43(unsigned short p_44, short p_45);
static unsigned short func_46(int * p_47, unsigned p_48, unsigned p_49, int * p_50, int * p_51);
static int * func_52(int * p_53, unsigned p_54, unsigned short p_55);
static int * func_56(int * p_57, int * p_58);
static int * func_59(signed char p_60, short p_61, unsigned p_62);
static unsigned short func_1(void)
{
int *l_4 = (void*)0;
int *l_5 = &g_6;
step_hash(1);
g_3 = g_2;
step_hash(2);
(*l_5) = 4L;
step_hash(387);
for (g_3 = (-4); (g_3 > 18); g_3++)
{
int *l_21 = (void*)0;
step_hash(385);
for (g_6 = 28; (g_6 != (-7)); g_6--)
{
step_hash(384);
for (g_2 = 0; (g_2 <= 33); ++g_2)
{
int *l_678 = &g_13;
step_hash(382);
for (g_13 = 0; (g_13 != 29); ++g_13)
{
step_hash(380);
if ((&g_6 == &g_6))
{
unsigned char l_677 = 0UL;
step_hash(16);
g_16 = (-4L);
step_hash(376);
l_677 = func_17((&g_13 != l_21), &g_13, &g_13);
}
else
{
step_hash(378);
(*g_155) = l_678;
step_hash(379);
(*g_155) = (*g_155);
}
step_hash(381);
return g_6;
}
step_hash(383);
(*g_156) = ((signed char)g_369 >> (signed char)2);
}
}
step_hash(386);
(*g_468) &= (g_75 && (-1L));
}
step_hash(388);
return g_76;
}
static int func_17(unsigned p_18, int * p_19, int * p_20)
{
unsigned char l_24 = 9UL;
int *l_370 = &g_13;
int ***l_560 = (void*)0;
int *l_579 = (void*)0;
int l_580 = 1L;
int l_675 = 0x54F31D19L;
step_hash(373);
if ((((short)(l_24 == func_25(func_30(func_35((((short)(-5L) << (short)13) != func_43(func_46(func_52(func_56(p_20, func_59(((void*)0 == p_20), ((unsigned char)1UL >> (unsigned char)2), ((((short)((short)((int)(((signed char)l_24 << (signed char)l_24) >= g_6) / (int)l_24) << (short)p_18) * (short)g_2) < l_24) & 0x05CE4EC6L))), g_202, g_202), p_18, l_24, p_20, &g_6), l_24)), g_3, l_370, p_20, g_6), p_20, p_18, p_19), l_370, p_19, &g_6)) << (short)(*l_370)) ^ 0x9FB1L))
{
int *l_433 = (void*)0;
short l_444 = 0x7E55L;
signed char l_470 = (-4L);
int l_502 = (-1L);
unsigned short l_542 = 0xCCAEL;
int ***l_588 = (void*)0;
int *l_649 = (void*)0;
step_hash(326);
if ((p_18 || (p_18 | ((&g_156 == (void*)0) > p_18))))
{
int l_460 = 0L;
int *l_469 = &g_202;
signed char l_471 = 0xD6L;
step_hash(245);
for (g_80 = 0; (g_80 == 21); g_80++)
{
unsigned char l_445 = 7UL;
int l_462 = (-1L);
step_hash(244);
if (((unsigned char)((signed char)((unsigned short)func_43(func_46(func_35(func_46((*g_155), p_18, (p_18 <= (l_444 < 0x05L)), func_35(g_202, g_2, l_433, l_370, p_18), p_20), p_18, p_19, p_19, l_445), p_18, g_80, &g_6, p_20), g_16) / (unsigned short)l_445) - (signed char)1L) * (unsigned char)p_18))
{
short l_454 = (-1L);
int *l_461 = (void*)0;
step_hash(237);
g_463 = (((signed char)(((signed char)g_13 * (signed char)((+(+((func_30(func_35(g_369, g_13, func_35((((int)(1UL != 0UL) + (int)((unsigned char)l_454 + (unsigned char)((**g_155) && ((int)((~(g_2 | (((signed char)(-(int)func_46((*g_155), g_3, l_454, (*g_155), p_20)) % (signed char)g_211) > p_18))) | 0xC1L) - (int)l_460)))) < 6UL), p_18, p_19, p_19, g_13), &g_202, g_2), l_461, p_18, &g_13) || l_460) <= 0x6FF626B8L))) || 0xBD86L)) < l_462) % (signed char)g_76) || 0xC0L);
step_hash(238);
return (**g_155);
}
else
{
step_hash(240);
(*g_156) &= (&l_433 == &g_156);
step_hash(241);
if (l_460)
break;
step_hash(242);
(*g_156) = (*g_156);
step_hash(243);
if (l_462)
continue;
}
}
step_hash(273);
if (((unsigned short)((g_211 > (((p_18 ^ g_202) != func_46(func_35((*l_370), ((-2L) || ((p_18 != ((unsigned short)(0xF20776D3L != (+func_46(g_468, (((((+0x7CFBFAACL) > (*l_370)) == 4294967295UL) && p_18) <= g_211), p_18, p_20, p_19))) * (unsigned short)1UL)) ^ g_3)), l_469, p_20, p_18), g_369, p_18, p_20, l_469)) < l_470)) & g_6) + (unsigned short)1L))
{
step_hash(247);
(**g_155) = (*l_469);
step_hash(248);
l_471 &= (func_43(p_18, ((**g_155) > (*l_469))) >= (~g_463));
step_hash(249);
return (*p_20);
}
else
{
int *l_472 = &g_6;
step_hash(251);
(*g_468) |= (g_369 & ((((+g_75) <= p_18) == p_18) > (g_211 != 65535UL)));
step_hash(252);
(*g_155) = p_20;
step_hash(253);
(*g_155) = l_472;
step_hash(272);
if ((g_6 > g_202))
{
int *l_473 = &g_6;
int ***l_494 = &g_155;
step_hash(255);
(*g_155) = l_473;
step_hash(262);
if ((((short)(-4L) * (short)((unsigned)((((((unsigned short)g_202 * (unsigned short)(6L | (l_473 == (void*)0))) || (((unsigned short)((short)((int)((*l_370) | (((unsigned short)((&g_156 != &g_468) <= ((p_18 ^ 0xDCL) <= (*l_473))) >> (unsigned short)6) || (*l_473))) - (int)0x4172FA32L) - (short)(*l_473)) / (unsigned short)g_16) | g_2)) || 0x3C011F43L) ^ p_18) <= g_76) + (unsigned)(*g_156))) | g_2))
{
int *l_495 = &g_202;
step_hash(257);
(*l_469) = (~((short)g_202 % (short)(((signed char)((signed char)(func_46(l_469, func_46(l_469, p_18, g_75, (*g_155), (*g_155)), (l_494 == (void*)0), p_19, l_469) && g_211) + (signed char)0L) / (signed char)p_18) ^ 0x8D2DL)));
step_hash(258);
(*l_495) = ((g_3 && 65529UL) == func_25(p_18, l_495, p_20, l_370));
step_hash(259);
(*g_468) |= ((unsigned char)0x01L >> (unsigned char)(***l_494));
}
else
{
step_hash(261);
return (*l_472);
}
step_hash(263);
return (*l_469);
}
else
{
unsigned short l_509 = 65532UL;
int *l_510 = &l_502;
step_hash(265);
(*g_155) = (*g_155);
step_hash(270);
for (g_202 = 6; (g_202 == (-25)); g_202 -= 4)
{
step_hash(269);
l_502 = (g_75 ^ g_3);
}
step_hash(271);
(*l_510) ^= ((*l_472) <= (((signed char)((unsigned)func_43(p_18, ((func_46(p_19, (*l_472), ((unsigned short)func_30(p_20, p_19, (g_369 >= (*l_370)), l_472) << (unsigned short)6), &l_502, l_469) && (*l_370)) | l_509)) - (unsigned)l_509) + (signed char)g_369) && 0UL));
}
}
}
else
{
unsigned l_513 = 0x2F1BECB8L;
int ***l_525 = &g_155;
step_hash(279);
for (g_75 = 0; (g_75 < 17); g_75++)
{
step_hash(278);
l_513 = (*p_19);
}
step_hash(284);
for (g_463 = (-22); (g_463 == 36); g_463 += 1)
{
unsigned short l_520 = 65535UL;
step_hash(283);
(***l_525) = ((unsigned)(p_19 != p_19) % (unsigned)((unsigned)(((p_18 || (l_520 != ((short)(*l_370) / (short)((unsigned short)(l_525 != (void*)0) + (unsigned short)((*g_155) == (void*)0))))) > 0xAFL) ^ p_18) + (unsigned)0x4915FEB5L));
}
step_hash(285);
(**g_155) = (**g_155);
step_hash(325);
for (g_76 = 0; (g_76 == 56); g_76 += 9)
{
unsigned l_530 = 4294967295UL;
int **l_538 = &l_370;
short l_562 = (-6L);
step_hash(289);
(**l_525) = (*g_155);
step_hash(300);
for (g_16 = 0; (g_16 <= 29); g_16 += 1)
{
int ***l_535 = &g_155;
step_hash(293);
(*g_156) &= ((*l_370) == g_2);
step_hash(294);
if ((**g_155))
continue;
step_hash(299);
if ((4294967292UL && (l_530 || ((***l_525) < (p_18 == (***l_525))))))
{
step_hash(296);
(**l_535) = func_35(((short)g_369 * (short)g_463), ((signed char)p_18 - (signed char)(l_535 == &g_155)), (**l_535), (*g_155), g_13);
}
else
{
step_hash(298);
(***l_535) = (*p_19);
}
}
step_hash(323);
for (g_16 = 24; (g_16 >= (-12)); g_16--)
{
int l_549 = 0xEEA455B8L;
step_hash(310);
if (((void*)0 == l_538))
{
int l_539 = (-1L);
int *l_543 = &l_502;
step_hash(305);
(*l_543) ^= (func_30(p_20, func_35(g_6, l_539, p_20, (*g_155), ((unsigned char)g_2 << (unsigned char)6)), g_202, func_35(l_542, p_18, p_20, &l_502, g_76)) ^ 0xE2E7167FL);
}
else
{
step_hash(307);
(*g_155) = (*g_155);
step_hash(308);
if ((*p_20))
continue;
step_hash(309);
(*g_468) &= (*g_156);
}
}
step_hash(324);
l_562 = (((*g_155) == (*g_155)) && g_202);
}
}
step_hash(367);
for (g_369 = 0; (g_369 <= 21); g_369 += 1)
{
unsigned char l_565 = 0UL;
signed char l_576 = 1L;
int ***l_587 = &g_155;
int l_641 = 0L;
step_hash(330);
if (l_565)
break;
step_hash(331);
(*g_468) = func_43(l_444, (p_18 && (((signed char)0x26L << (signed char)4) & ((unsigned)p_18 % (unsigned)(((short)((unsigned char)func_30((*g_155), func_59(l_565, ((unsigned short)l_576 / (unsigned short)((short)0x6319L << (short)g_80)), g_202), p_18, l_579) / (unsigned char)l_576) >> (short)10) & l_580)))));
step_hash(332);
if ((*g_156))
break;
step_hash(366);
if (((unsigned short)g_80 * (unsigned short)((((unsigned short)65535UL - (unsigned short)(p_18 || (l_587 == &g_155))) < (&g_155 != l_588)) == (-9L))))
{
unsigned l_595 = 0x2E711793L;
step_hash(334);
(*g_468) = (((((unsigned char)(((int)((void*)0 == &g_155) - (int)((unsigned char)p_18 / (unsigned char)4UL)) > ((-5L) && (l_560 != &g_155))) / (unsigned char)(***l_587)) <= (((p_18 && 0xC5C3L) ^ g_369) >= (***l_587))) <= p_18) ^ l_595);
step_hash(335);
(**l_587) = (*g_155);
}
else
{
unsigned short l_602 = 0xD097L;
int *l_624 = &l_502;
int ***l_633 = &g_155;
step_hash(363);
if (((short)g_369 + (short)(g_369 == ((signed char)(func_46(func_35((g_3 > (~((!g_3) < p_18))), ((short)(&g_468 == &p_20) / (short)((-1L) ^ g_3)), p_20, (*g_155), p_18), g_80, l_602, (*g_155), (*g_155)) | p_18) / (signed char)g_463))))
{
int *l_617 = &g_13;
step_hash(345);
if (((unsigned)((int)(((*g_468) ^ (((void*)0 != (*g_155)) > (g_202 > ((signed char)p_18 + (signed char)((unsigned char)g_80 >> (unsigned char)7))))) & ((((void*)0 != p_19) | (((short)(l_602 == p_18) % (short)1UL) <= 0xEFAEA218L)) >= 4294967294UL)) + (int)g_211) / (unsigned)g_2))
{
step_hash(339);
(*g_155) = func_35((((unsigned short)((((((signed char)(func_30((**l_587), func_35(p_18, p_18, l_617, p_20, ((unsigned char)((int)(((~((p_19 == p_20) < 1UL)) < (((unsigned short)(***l_587) * (unsigned short)g_211) || 3UL)) & p_18) % (int)0xC8C507F8L) << (unsigned char)1)), g_13, p_19) >= g_13) << (signed char)g_6) < (*p_20)) & 7L) != p_18) >= g_369) - (unsigned short)1UL) != g_369), g_13, l_624, p_19, (*l_617));
step_hash(340);
l_641 |= ((unsigned char)((unsigned short)(*l_370) >> (unsigned short)11) - (unsigned char)((signed char)(((void*)0 == l_633) | (65535UL != ((signed char)(((unsigned short)g_80 % (unsigned short)((unsigned char)(***l_587) >> (unsigned char)7)) | ((-(signed char)(*l_370)) == ((*g_155) != p_20))) - (signed char)1L))) + (signed char)p_18));
step_hash(341);
(***l_633) = (**g_155);
step_hash(342);
return (*p_19);
}
else
{
step_hash(344);
if ((*l_617))
break;
}
step_hash(346);
(*g_155) = (*g_155);
step_hash(351);
for (l_580 = 0; (l_580 < 2); l_580 += 1)
{
step_hash(350);
return (*p_20);
}
}
else
{
int ***l_646 = &g_155;
step_hash(353);
(*l_624) ^= (**g_155);
step_hash(354);
(*g_468) |= (*p_20);
step_hash(361);
for (p_18 = 0; (p_18 != 40); ++p_18)
{
step_hash(358);
(**l_633) = (*g_155);
step_hash(359);
(*g_468) = (((void*)0 != (*l_646)) > (+p_18));
step_hash(360);
(**l_646) = l_649;
}
step_hash(362);
(*g_468) = ((int)(*p_19) / (int)0x1F95334AL);
}
step_hash(364);
(**l_633) = p_19;
step_hash(365);
(*l_624) = (g_13 || ((((unsigned char)((unsigned short)(!(***l_587)) >> (unsigned short)(((unsigned char)g_6 * (unsigned char)(&p_19 == &g_156)) >= (((int)(***l_587) + (int)(((signed char)((p_18 <= (!(g_13 == (((signed char)p_18 % (signed char)p_18) < 0UL)))) ^ (*g_156)) / (signed char)p_18) && (***l_633))) <= (-1L)))) % (unsigned char)0x39L) > g_463) < g_6));
}
}
}
else
{
unsigned l_674 = 1UL;
int l_676 = 0x3066CB41L;
step_hash(369);
l_675 = (((unsigned char)func_43((((-9L) <= (0x4AL != g_211)) || ((short)(((signed char)0L >> (signed char)func_30(p_19, func_59(p_18, (((unsigned char)((signed char)p_18 + (signed char)(p_18 >= g_6)) << (unsigned char)7) <= p_18), g_6), l_674, (*g_155))) && g_76) << (short)l_674)), p_18) - (unsigned char)g_6) ^ l_674);
step_hash(370);
(*g_155) = func_52((*g_155), g_75, p_18);
step_hash(371);
(*g_468) = (0L > ((*g_155) == (*g_155)));
step_hash(372);
l_676 = ((void*)0 == &g_156);
}
step_hash(374);
(*g_155) = (*g_155);
step_hash(375);
return (*g_468);
}
static short func_25(int p_26, int * p_27, int * p_28, int * p_29)
{
int **l_409 = &g_156;
int *l_410 = &g_6;
int *l_431 = (void*)0;
int *l_432 = &g_211;
step_hash(227);
for (g_80 = 0; (g_80 == (-13)); g_80--)
{
int *l_411 = &g_202;
int *l_412 = &g_202;
step_hash(219);
(*l_411) = ((func_30(p_29, p_27, func_46(func_35(p_26, (p_26 || ((((int)((short)((signed char)g_202 << (signed char)((short)((short)(-3L) + (short)1UL) >> (short)(l_409 == &g_156))) + (short)g_13) + (int)p_26) != g_3) >= 0UL)), l_410, l_411, g_13), p_26, g_3, l_412, l_411), p_28) & p_26) != p_26);
step_hash(226);
for (g_202 = (-19); (g_202 == 27); ++g_202)
{
int *l_415 = &g_75;
step_hash(223);
g_211 = (*l_410);
step_hash(224);
if ((*p_29))
continue;
step_hash(225);
(*l_415) |= (*p_28);
}
}
step_hash(228);
(*l_409) = &g_75;
step_hash(229);
(*l_432) = ((unsigned char)(((((signed char)(-(unsigned short)(((unsigned char)((signed char)func_43(g_2, g_3) << (signed char)7) << (unsigned char)2) <= (0L != p_26))) % (signed char)0x2AL) == ((unsigned short)((int)((unsigned short)g_2 / (unsigned short)0x5BCDL) / (int)p_26) << (unsigned short)1)) == g_16) & 0L) * (unsigned char)(*l_410));
step_hash(230);
return g_80;
}
static int func_30(int * p_31, int * p_32, unsigned p_33, int * p_34)
{
int l_377 = 0x6AA6A8A0L;
int *l_396 = &g_202;
step_hash(213);
(*l_396) = ((signed char)((unsigned short)(l_377 == (((unsigned)(((short)((g_13 <= func_43((+((short)g_76 - (short)((unsigned short)((unsigned short)(p_33 < ((unsigned short)(((short)(((unsigned short)((int)(*p_31) + (int)(+((*p_31) ^ l_377))) % (unsigned short)(p_33 & l_377)) & g_13) << (short)l_377) && l_377) - (unsigned short)65535UL)) >> (unsigned short)0) / (unsigned short)g_2))), p_33)) == l_377) << (short)p_33) <= p_33) / (unsigned)g_16) >= 0L)) - (unsigned short)l_377) / (signed char)0xAFL);
step_hash(214);
return g_16;
}
static int * func_35(unsigned p_36, unsigned p_37, int * p_38, int * p_39, short p_40)
{
step_hash(211);
return p_38;
}
static unsigned func_43(unsigned short p_44, short p_45)
{
int *l_360 = &g_75;
int *l_363 = &g_202;
int ***l_366 = &g_155;
step_hash(206);
(*l_363) &= ((unsigned short)((short)((((unsigned short)g_2 % (unsigned short)(g_76 || ((unsigned short)((-4L) ^ (p_45 && (((((((short)((func_46(l_360, ((unsigned short)((*l_360) && (&l_360 == (void*)0)) << (unsigned short)p_44), g_2, l_360, l_360) <= g_3) < p_45) / (short)(-1L)) | 0x6AFEL) < 0xE676L) && p_44) <= 0xF3L) > p_44))) >> (unsigned short)5))) || (*l_360)) | p_44) % (short)0xE91EL) * (unsigned short)g_76);
step_hash(207);
(*l_360) = ((signed char)g_211 * (signed char)(g_80 && ((l_366 == (void*)0) >= (-1L))));
step_hash(208);
(*l_360) ^= (0xD6L > ((*l_363) <= 65531UL));
step_hash(209);
return g_369;
}
static unsigned short func_46(int * p_47, unsigned p_48, unsigned p_49, int * p_50, int * p_51)
{
unsigned l_344 = 1UL;
int *l_345 = &g_75;
step_hash(196);
(*l_345) &= l_344;
step_hash(201);
for (l_344 = 0; (l_344 != 13); ++l_344)
{
step_hash(200);
return g_16;
}
step_hash(202);
(*g_155) = l_345;
step_hash(203);
(*g_156) = ((signed char)p_48 << (signed char)g_80);
step_hash(204);
return p_49;
}
static int * func_52(int * p_53, unsigned p_54, unsigned short p_55)
{
unsigned char l_222 = 0x73L;
int ***l_226 = &g_155;
signed char l_233 = 1L;
unsigned char l_237 = 0x81L;
int *l_258 = (void*)0;
int l_291 = 0x252602BCL;
step_hash(185);
if ((**g_155))
{
int ***l_225 = &g_155;
int *l_229 = (void*)0;
int *l_230 = &g_211;
int *l_238 = (void*)0;
step_hash(105);
for (g_202 = 21; (g_202 < (-13)); g_202 -= 2)
{
step_hash(104);
(*g_155) = func_59(l_222, l_222, (p_54 > ((signed char)0x8DL >> (signed char)3)));
}
step_hash(106);
(*l_230) = ((-4L) || ((l_225 != l_226) ^ ((unsigned char)p_54 >> (unsigned char)g_3)));
step_hash(112);
for (g_76 = 0; (g_76 != 10); g_76 += 9)
{
step_hash(110);
if ((*p_53))
break;
step_hash(111);
(*l_230) |= 0xCD7A3E1DL;
}
step_hash(134);
if ((*g_156))
{
unsigned char l_234 = 255UL;
step_hash(114);
(*l_230) = 0L;
step_hash(115);
(**l_225) = func_59(l_233, (l_234 >= (*p_53)), l_234);
step_hash(116);
(*l_230) |= (**g_155);
step_hash(128);
for (g_202 = 0; (g_202 < (-21)); g_202 -= 9)
{
unsigned char l_245 = 0xD4L;
step_hash(120);
(*l_230) = l_237;
step_hash(121);
(*l_230) &= ((void*)0 != (*g_155));
step_hash(122);
(*g_155) = (*g_155);
step_hash(127);
if (((unsigned char)((unsigned short)((unsigned)(l_245 <= 0x75L) / (unsigned)((int)(0xF07E3ED9L < ((short)p_55 >> (short)6)) - (int)(1UL && ((0L <= ((g_202 < l_245) == (*p_53))) <= (-1L))))) << (unsigned short)15) << (unsigned char)p_54))
{
step_hash(124);
return (*g_155);
}
else
{
step_hash(126);
(*l_230) = 0L;
}
}
}
else
{
step_hash(130);
(**l_226) = (*g_155);
step_hash(131);
(*l_230) &= ((unsigned char)p_54 / (unsigned char)p_55);
step_hash(132);
g_80 = ((***l_225) ^ 0L);
step_hash(133);
(*l_230) = (**g_155);
}
}
else
{
int l_256 = 0xDEFA42DBL;
int **l_257 = &g_156;
signed char l_285 = (-1L);
int *l_330 = &l_256;
step_hash(136);
(*g_156) = ((((*g_155) != (*g_155)) && (255UL | g_6)) | ((((signed char)(((***l_226) || (g_13 ^ (0xF8BBF318L < g_13))) <= 0L) + (signed char)g_16) || l_256) >= 0x9B1839ECL));
step_hash(183);
if ((l_257 != (void*)0))
{
int *l_259 = &g_211;
step_hash(138);
(**l_226) = l_258;
step_hash(139);
return l_259;
}
else
{
int l_262 = (-2L);
int l_293 = (-4L);
step_hash(141);
(**l_257) = (*p_53);
step_hash(170);
for (g_80 = 0; (g_80 <= (-19)); g_80 -= 1)
{
unsigned char l_263 = 1UL;
int l_312 = 0L;
}
step_hash(181);
if (((*l_257) != &l_293))
{
short l_315 = 0xA142L;
unsigned l_320 = 0xA7CE9A38L;
step_hash(172);
(***l_226) = ((int)l_315 % (int)((unsigned short)p_55 + (unsigned short)p_54));
step_hash(173);
(**g_155) &= 0x1F6031B5L;
step_hash(174);
(**l_257) = (g_202 > (((((int)(*g_156) / (int)l_293) <= 249UL) == (g_80 == l_320)) <= ((unsigned)g_75 - (unsigned)0x3DB380C5L)));
step_hash(175);
(*l_257) = (*g_155);
}
else
{
int l_327 = (-3L);
step_hash(177);
(**l_257) = ((l_262 < (p_54 & p_54)) | (-1L));
step_hash(178);
(**l_226) = (**l_226);
step_hash(179);
(*g_156) |= (((unsigned char)g_80 / (unsigned char)((unsigned short)(7L || l_327) + (unsigned short)p_54)) >= g_76);
step_hash(180);
(*l_257) = &l_293;
}
step_hash(182);
g_202 ^= (**g_155);
}
step_hash(184);
(*l_330) = (0x6CE235BBL < (((signed char)0x7BL << (signed char)4) ^ g_202));
}
step_hash(193);
if ((((0L & ((unsigned short)p_54 << (unsigned short)7)) != (((signed char)(&g_155 == l_226) + (signed char)p_54) ^ (0xC489A983L & p_55))) || p_55))
{
int **l_339 = &l_258;
signed char l_340 = 0x35L;
int *l_341 = (void*)0;
int *l_342 = &g_80;
step_hash(187);
l_340 &= (((unsigned short)g_3 + (unsigned short)g_202) || (l_339 != l_339));
step_hash(188);
(*l_342) = 0xAC64C0F7L;
step_hash(189);
return p_53;
}
else
{
int *l_343 = &g_75;
step_hash(191);
(*l_343) &= (l_343 == l_343);
step_hash(192);
(**l_226) = &g_6;
}
step_hash(194);
return p_53;
}
static int * func_56(int * p_57, int * p_58)
{
short l_88 = 0x90AEL;
int *l_91 = &g_75;
signed char l_195 = (-1L);
int **l_214 = &l_91;
step_hash(95);
if (g_3)
{
unsigned char l_84 = 0x82L;
int *l_85 = &g_80;
int *l_144 = &g_80;
short l_157 = 0xEE03L;
step_hash(30);
(*l_85) = l_84;
step_hash(58);
if (((short)l_88 * (short)((short)(l_91 != (void*)0) >> (short)(&g_6 != (void*)0))))
{
int l_106 = 0xBB87E338L;
step_hash(32);
(*l_91) = (((signed char)((int)((signed char)((unsigned char)((signed char)((signed char)((unsigned short)(p_57 == (void*)0) * (unsigned short)2UL) % (signed char)l_106) + (signed char)g_13) - (unsigned char)(g_2 != l_106)) >> (signed char)((*l_85) >= ((unsigned short)0xF7FCL + (unsigned short)l_106))) - (int)0x628D16E9L) >> (signed char)g_76) < 0x27A4L);
}
else
{
unsigned char l_109 = 8UL;
unsigned l_118 = 1UL;
int **l_139 = (void*)0;
step_hash(34);
(*l_91) = ((p_57 == &g_75) == (((g_76 <= g_13) ^ l_109) || (((unsigned short)g_6 * (unsigned short)(((short)(4L | ((signed char)((((unsigned short)((*p_57) >= g_16) * (unsigned short)g_3) & (*l_91)) && g_80) - (signed char)0xCBL)) >> (short)0) || (*l_91))) && l_118)));
step_hash(39);
if ((((signed char)(((short)l_109 << (short)9) ^ ((short)(((l_109 > (l_109 >= (*l_91))) == (*l_85)) == ((int)(&p_57 != &p_57) + (int)((unsigned char)((unsigned short)(l_118 != (((*l_91) & l_109) || 4UL)) << (unsigned short)11) * (unsigned char)0x4CL))) >> (short)(*l_91))) + (signed char)l_109) & (*l_91)))
{
step_hash(36);
(*l_85) = (-1L);
}
else
{
int **l_131 = &l_91;
step_hash(38);
(*l_131) = p_58;
}
step_hash(57);
for (g_76 = 0; (g_76 < 16); g_76 += 5)
{
int **l_134 = &l_85;
step_hash(43);
(*l_134) = &g_13;
step_hash(55);
for (l_88 = 0; (l_88 != 6); l_88++)
{
step_hash(53);
for (g_75 = 4; (g_75 >= (-3)); g_75 -= 4)
{
step_hash(50);
if ((*p_58))
break;
step_hash(51);
(*l_134) = p_57;
step_hash(52);
g_80 &= (*p_57);
}
step_hash(54);
(*l_134) = p_58;
}
step_hash(56);
g_75 ^= ((**l_134) < (l_139 == (void*)0));
}
}
step_hash(59);
(*l_144) = (((unsigned char)(*l_91) * (unsigned char)(*l_91)) <= ((((~((g_76 && ((unsigned)(((*p_58) ^ ((*l_91) && g_6)) != (*l_91)) % (unsigned)(+(&g_6 != (void*)0)))) | 0x14738E28L)) < (*l_85)) ^ (*l_85)) ^ (*l_85)));
step_hash(60);
(*g_156) = ((short)((unsigned short)((unsigned short)(((signed char)(-1L) / (signed char)(*l_91)) ^ ((unsigned char)(g_6 ^ (*l_91)) * (unsigned char)((g_75 <= ((*l_91) & ((*l_91) < (g_155 == &g_156)))) ^ (*l_85)))) + (unsigned short)l_157) + (unsigned short)0x6D70L) / (short)65530UL);
}
else
{
unsigned l_169 = 0x679535C3L;
int *l_188 = &g_75;
step_hash(85);
for (g_80 = 3; (g_80 >= (-15)); g_80 -= 1)
{
short l_164 = 0x69B9L;
short l_174 = 0xCF24L;
int *l_203 = &g_6;
int *l_210 = &g_211;
step_hash(65);
(**g_155) = ((short)((unsigned)(l_164 || (((*l_91) > ((*l_91) > ((*g_156) == (((short)((signed char)l_169 / (signed char)0xF4L) - (short)((short)((unsigned char)l_164 >> (unsigned char)4) % (short)l_174)) <= ((short)(((g_3 && 0xF0L) == l_174) < (*l_91)) << (short)7))))) || l_174)) / (unsigned)l_174) - (short)l_169);
step_hash(82);
if ((*g_156))
{
int *l_179 = &g_13;
int l_186 = 0xBB3B7CC6L;
step_hash(77);
for (l_88 = 0; (l_88 != 15); l_88 += 6)
{
signed char l_187 = 0x40L;
int *l_197 = &g_80;
signed char l_198 = (-3L);
int *l_201 = &g_202;
step_hash(70);
p_58 = l_179;
}
step_hash(78);
if ((*p_58))
continue;
step_hash(79);
if ((**g_155))
break;
}
else
{
step_hash(81);
return l_203;
}
step_hash(83);
if ((**g_155))
continue;
step_hash(84);
(*l_210) ^= ((7L <= 9UL) > (g_2 == ((unsigned short)65535UL - (unsigned short)((unsigned short)(((((unsigned)(p_57 == (void*)0) - (unsigned)((*l_91) | g_2)) == (((*l_91) ^ g_202) > (*l_203))) != 0x8CAFD7A6L) | (*l_203)) << (unsigned short)g_3))));
}
step_hash(92);
for (g_80 = (-8); (g_80 > 18); ++g_80)
{
int ***l_215 = &l_214;
step_hash(89);
(*l_215) = l_214;
step_hash(90);
(*l_215) = &l_91;
step_hash(91);
(*l_91) |= (*p_57);
}
step_hash(93);
(*l_214) = func_59((((short)(&p_58 == &p_58) >> (short)0) == (**g_155)), (**l_214), (*l_188));
step_hash(94);
return (*g_155);
}
step_hash(96);
(*l_214) = func_59(g_16, (*l_91), ((**l_214) ^ ((unsigned char)0xF3L >> (unsigned char)3)));
step_hash(97);
p_57 = (void*)0;
step_hash(98);
return (*g_155);
}
static int * func_59(signed char p_60, short p_61, unsigned p_62)
{
int l_73 = 1L;
int *l_74 = &g_75;
int *l_77 = (void*)0;
int *l_78 = (void*)0;
int *l_79 = &g_80;
step_hash(19);
(*l_74) = l_73;
step_hash(20);
g_76 |= (*l_74);
step_hash(21);
(*l_79) &= (*l_74);
step_hash(26);
for (g_16 = 2; (g_16 > 28); g_16 += 7)
{
int **l_83 = &l_77;
step_hash(25);
(*l_83) = l_78;
}
step_hash(27);
return &g_13;
}
void csmith_compute_hash(void)
{
transparent_crc(g_2, "g_2", print_hash_value);
transparent_crc(g_3, "g_3", print_hash_value);
transparent_crc(g_6, "g_6", print_hash_value);
transparent_crc(g_13, "g_13", print_hash_value);
transparent_crc(g_16, "g_16", print_hash_value);
transparent_crc(g_75, "g_75", print_hash_value);
transparent_crc(g_76, "g_76", print_hash_value);
transparent_crc(g_80, "g_80", print_hash_value);
transparent_crc(g_202, "g_202", print_hash_value);
transparent_crc(g_211, "g_211", print_hash_value);
transparent_crc(g_369, "g_369", print_hash_value);
transparent_crc(g_463, "g_463", print_hash_value);
}
void step_hash(int stmt_id)
{
int i = 0;
csmith_compute_hash();
printf("before stmt(%d): checksum = %X\n", stmt_id, crc32_context ^ 0xFFFFFFFFUL);
crc32_context = 0xFFFFFFFFUL;
for (i = 0; i < 256; i++) {
crc32_tab[i] = 0;
}
crc32_gentab();
}
int main (void)
{
int print_hash_value = 0;
platform_main_begin();
crc32_gentab();
func_1();
csmith_compute_hash();
platform_main_end(crc32_context ^ 0xFFFFFFFFUL, print_hash_value);
return 0;
}
|
the_stack_data/119103.c | #include <stdio.h>
#include <stdlib.h>
#define tam 10
void inverter(int vetorA[], int vetorB[], int vetorC[]);
int main()
{
int vetorA[tam], vetorB[tam], vetorC[20], vetorAux[20], i, z=0;
printf("Preencher vetor A: \n");
for(i=0;i<tam;i++)
{
printf("Digite um valor: ");
scanf("%d", &vetorA[i]);
}
printf("\nPreencher o vetor B: \n");
for(i=0;i<tam;i++)
{
printf("Digite um valor: ");
scanf("%d", &vetorB[i]);
}
for(i=0;i<10;i++)
{
vetorAux[i]=vetorA[i];
}
z=10;
for(i=0;i<10;i++)
{
vetorAux[z]=vetorB[i];
z++;
}
inverter(vetorA, vetorB, vetorC);
for(i=0; i<20; i++)
{
printf("%d | ", vetorC[i]);
}
return 0;
}
void inverter(int vetorA[], int vetorB[], int vetorC[])
{
int i, j, z=0, menor, auxiliar;
int tamanho=20;
int vetor[20];
for(i=0;i<10;i++)
{
vetor[i]=vetorA[i];
}
z=20;
for(i=0; i<20; i++)
{
z--;
vetor[z]=vetorB[i];
}
for(i=0;i<tamanho-1;i++){
menor=i;
for(int j=i+1 ; j<tamanho ; j++){
if(vetor[menor] > vetor[j])
menor=j;
}
if(i!=menor){
auxiliar=vetor[i];
vetor[i]=vetor[menor];
vetor[menor]=auxiliar;
}
}
z=20;
for(i=0; i<20; i++)
{
z--;
vetorC[z]=vetor[i];
}
}
|
the_stack_data/904222.c | /** Convert the domain name into a list of ip addresses
* Look up the domain name from an ip address.
*/
#include <stdio.h>
#include <stdlib.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/socket.h>
#ifndef NI_MAXHOST
#define NI_MAXHOST 1025
#endif
int main(int argc, char *argv[]) {
if (argc != 3) {
fprintf(stderr, "Usage: getaddrinfo domain port\n");
return 1;
}
struct addrinfo *result;
struct addrinfo *res;
int error;
/* resolve the domain name into a list of addresses */
error = getaddrinfo(argv[1], argv[2], NULL, &result);
if (error != 0) {
if (error == EAI_SYSTEM) {
perror("getaddrinfo");
} else {
fprintf(stderr, "error in getaddrinfo: %s\n", gai_strerror(error));
}
exit(EXIT_FAILURE);
}
/* loop over all returned results and do inverse lookup */
for (res = result; res != NULL; res = res->ai_next) {
char hostname[NI_MAXHOST];
char servicename[NI_MAXHOST];
char ipaddress[INET6_ADDRSTRLEN];
error = getnameinfo(res->ai_addr, res->ai_addrlen, hostname, NI_MAXHOST, servicename, NI_MAXHOST, 0);
if (error != 0) {
fprintf(stderr, "error in getnameinfo: %s\n", gai_strerror(error));
continue;
}
/* convert the sockaddr to ip string */
switch(res->ai_addr->sa_family) {
case AF_INET: {
struct sockaddr_in *addr_in = (struct sockaddr_in *)res->ai_addr;
inet_ntop(AF_INET, &(addr_in->sin_addr), ipaddress, INET6_ADDRSTRLEN);
break;
}
case AF_INET6: {
struct sockaddr_in6 *addr_in = (struct sockaddr_in6 *)res->ai_addr;
inet_ntop(AF_INET6, &(addr_in->sin6_addr), ipaddress, INET6_ADDRSTRLEN);
break;
}
default: break;
}
if (*hostname != '\0')
printf("hostname: %s, servicename: %s, ip: %s\n", hostname, servicename, ipaddress);
}
freeaddrinfo(result);
return 0;
}
|
the_stack_data/97012331.c | #include <stdio.h>
#include <unistd.h>
#include <assert.h>
#include <fcntl.h>
#include <sys/types.h>
int main()
{
int fd = open("/tmp/file", O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU);
assert(fd > -1);
int rc = write(fd, "hello world\n", 13);
assert(rc == 13);
close(fd);
return 0;
}
|
the_stack_data/18103.c | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define BUF_SIZE 32
void win(char * password) {
printf("you win: %s\n", password);
}
void lose(int where) {
printf("you lose: %d\n", where);
exit(1);
}
void start(char *password) {
if(password[4] != 'A') {
lose(1);
}
if(strlen(password) != 8) {
lose(2);
}
if(strncmp(password, "easy", 4) != 0) {
lose(3);
}
if(strstr(password, "pie") == NULL) {
lose(4);
}
win(password);
return;
}
int main(int argc, char *argv[]){
if(argc != 2) {
printf("usage: %s PASSWORD\n", argv[0]);
exit(1);
}
char password[BUF_SIZE] = {0};
strncpy(password, argv[1], BUF_SIZE);
password[BUF_SIZE-1] = '\0';
start(password);
return 0;
}
|
the_stack_data/1268840.c | /*
* esercizio-C-2020-04-06.c
*
* Created on: Apr 2, 2020
* Author: marco
*/
|
the_stack_data/218891955.c | /*
* CGA ROM data
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdint.h>
const uint8_t ff_cga_font[2048] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0xbd, 0x99, 0x81, 0x7e,
0x7e, 0xff, 0xdb, 0xff, 0xc3, 0xe7, 0xff, 0x7e, 0x6c, 0xfe, 0xfe, 0xfe, 0x7c, 0x38, 0x10, 0x00,
0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x10, 0x00, 0x38, 0x7c, 0x38, 0xfe, 0xfe, 0x7c, 0x38, 0x7c,
0x10, 0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x7c, 0x00, 0x00, 0x18, 0x3c, 0x3c, 0x18, 0x00, 0x00,
0xff, 0xff, 0xe7, 0xc3, 0xc3, 0xe7, 0xff, 0xff, 0x00, 0x3c, 0x66, 0x42, 0x42, 0x66, 0x3c, 0x00,
0xff, 0xc3, 0x99, 0xbd, 0xbd, 0x99, 0xc3, 0xff, 0x0f, 0x07, 0x0f, 0x7d, 0xcc, 0xcc, 0xcc, 0x78,
0x3c, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x18, 0x3f, 0x33, 0x3f, 0x30, 0x30, 0x70, 0xf0, 0xe0,
0x7f, 0x63, 0x7f, 0x63, 0x63, 0x67, 0xe6, 0xc0, 0x99, 0x5a, 0x3c, 0xe7, 0xe7, 0x3c, 0x5a, 0x99,
0x80, 0xe0, 0xf8, 0xfe, 0xf8, 0xe0, 0x80, 0x00, 0x02, 0x0e, 0x3e, 0xfe, 0x3e, 0x0e, 0x02, 0x00,
0x18, 0x3c, 0x7e, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x00,
0x7f, 0xdb, 0xdb, 0x7b, 0x1b, 0x1b, 0x1b, 0x00, 0x3e, 0x63, 0x38, 0x6c, 0x6c, 0x38, 0xcc, 0x78,
0x00, 0x00, 0x00, 0x00, 0x7e, 0x7e, 0x7e, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x7e, 0x3c, 0x18, 0xff,
0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00,
0x00, 0x18, 0x0c, 0xfe, 0x0c, 0x18, 0x00, 0x00, 0x00, 0x30, 0x60, 0xfe, 0x60, 0x30, 0x00, 0x00,
0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xfe, 0x00, 0x00, 0x00, 0x24, 0x66, 0xff, 0x66, 0x24, 0x00, 0x00,
0x00, 0x18, 0x3c, 0x7e, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7e, 0x3c, 0x18, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x78, 0x78, 0x30, 0x30, 0x00, 0x30, 0x00,
0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x6c, 0xfe, 0x6c, 0xfe, 0x6c, 0x6c, 0x00,
0x30, 0x7c, 0xc0, 0x78, 0x0c, 0xf8, 0x30, 0x00, 0x00, 0xc6, 0xcc, 0x18, 0x30, 0x66, 0xc6, 0x00,
0x38, 0x6c, 0x38, 0x76, 0xdc, 0xcc, 0x76, 0x00, 0x60, 0x60, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00,
0x18, 0x30, 0x60, 0x60, 0x60, 0x30, 0x18, 0x00, 0x60, 0x30, 0x18, 0x18, 0x18, 0x30, 0x60, 0x00,
0x00, 0x66, 0x3c, 0xff, 0x3c, 0x66, 0x00, 0x00, 0x00, 0x30, 0x30, 0xfc, 0x30, 0x30, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x60, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0x80, 0x00,
0x7c, 0xc6, 0xce, 0xde, 0xf6, 0xe6, 0x7c, 0x00, 0x30, 0x70, 0x30, 0x30, 0x30, 0x30, 0xfc, 0x00,
0x78, 0xcc, 0x0c, 0x38, 0x60, 0xcc, 0xfc, 0x00, 0x78, 0xcc, 0x0c, 0x38, 0x0c, 0xcc, 0x78, 0x00,
0x1c, 0x3c, 0x6c, 0xcc, 0xfe, 0x0c, 0x1e, 0x00, 0xfc, 0xc0, 0xf8, 0x0c, 0x0c, 0xcc, 0x78, 0x00,
0x38, 0x60, 0xc0, 0xf8, 0xcc, 0xcc, 0x78, 0x00, 0xfc, 0xcc, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x00,
0x78, 0xcc, 0xcc, 0x78, 0xcc, 0xcc, 0x78, 0x00, 0x78, 0xcc, 0xcc, 0x7c, 0x0c, 0x18, 0x70, 0x00,
0x00, 0x30, 0x30, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x30, 0x30, 0x60,
0x18, 0x30, 0x60, 0xc0, 0x60, 0x30, 0x18, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0xfc, 0x00, 0x00,
0x60, 0x30, 0x18, 0x0c, 0x18, 0x30, 0x60, 0x00, 0x78, 0xcc, 0x0c, 0x18, 0x30, 0x00, 0x30, 0x00,
0x7c, 0xc6, 0xde, 0xde, 0xde, 0xc0, 0x78, 0x00, 0x30, 0x78, 0xcc, 0xcc, 0xfc, 0xcc, 0xcc, 0x00,
0xfc, 0x66, 0x66, 0x7c, 0x66, 0x66, 0xfc, 0x00, 0x3c, 0x66, 0xc0, 0xc0, 0xc0, 0x66, 0x3c, 0x00,
0xf8, 0x6c, 0x66, 0x66, 0x66, 0x6c, 0xf8, 0x00, 0xfe, 0x62, 0x68, 0x78, 0x68, 0x62, 0xfe, 0x00,
0xfe, 0x62, 0x68, 0x78, 0x68, 0x60, 0xf0, 0x00, 0x3c, 0x66, 0xc0, 0xc0, 0xce, 0x66, 0x3e, 0x00,
0xcc, 0xcc, 0xcc, 0xfc, 0xcc, 0xcc, 0xcc, 0x00, 0x78, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00,
0x1e, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0x78, 0x00, 0xe6, 0x66, 0x6c, 0x78, 0x6c, 0x66, 0xe6, 0x00,
0xf0, 0x60, 0x60, 0x60, 0x62, 0x66, 0xfe, 0x00, 0xc6, 0xee, 0xfe, 0xfe, 0xd6, 0xc6, 0xc6, 0x00,
0xc6, 0xe6, 0xf6, 0xde, 0xce, 0xc6, 0xc6, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, 0x00,
0xfc, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xf0, 0x00, 0x78, 0xcc, 0xcc, 0xcc, 0xdc, 0x78, 0x1c, 0x00,
0xfc, 0x66, 0x66, 0x7c, 0x6c, 0x66, 0xe6, 0x00, 0x78, 0xcc, 0xe0, 0x70, 0x1c, 0xcc, 0x78, 0x00,
0xfc, 0xb4, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xfc, 0x00,
0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0x30, 0x00, 0xc6, 0xc6, 0xc6, 0xd6, 0xfe, 0xee, 0xc6, 0x00,
0xc6, 0xc6, 0x6c, 0x38, 0x38, 0x6c, 0xc6, 0x00, 0xcc, 0xcc, 0xcc, 0x78, 0x30, 0x30, 0x78, 0x00,
0xfe, 0xc6, 0x8c, 0x18, 0x32, 0x66, 0xfe, 0x00, 0x78, 0x60, 0x60, 0x60, 0x60, 0x60, 0x78, 0x00,
0xc0, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x02, 0x00, 0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x78, 0x00,
0x10, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
0x30, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00,
0xe0, 0x60, 0x60, 0x7c, 0x66, 0x66, 0xdc, 0x00, 0x00, 0x00, 0x78, 0xcc, 0xc0, 0xcc, 0x78, 0x00,
0x1c, 0x0c, 0x0c, 0x7c, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0x78, 0x00,
0x38, 0x6c, 0x60, 0xf0, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x76, 0xcc, 0xcc, 0x7c, 0x0c, 0xf8,
0xe0, 0x60, 0x6c, 0x76, 0x66, 0x66, 0xe6, 0x00, 0x30, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00,
0x0c, 0x00, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0x78, 0xe0, 0x60, 0x66, 0x6c, 0x78, 0x6c, 0xe6, 0x00,
0x70, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00, 0x00, 0x00, 0xcc, 0xfe, 0xfe, 0xd6, 0xc6, 0x00,
0x00, 0x00, 0xf8, 0xcc, 0xcc, 0xcc, 0xcc, 0x00, 0x00, 0x00, 0x78, 0xcc, 0xcc, 0xcc, 0x78, 0x00,
0x00, 0x00, 0xdc, 0x66, 0x66, 0x7c, 0x60, 0xf0, 0x00, 0x00, 0x76, 0xcc, 0xcc, 0x7c, 0x0c, 0x1e,
0x00, 0x00, 0xdc, 0x76, 0x66, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x7c, 0xc0, 0x78, 0x0c, 0xf8, 0x00,
0x10, 0x30, 0x7c, 0x30, 0x30, 0x34, 0x18, 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00,
0x00, 0x00, 0xcc, 0xcc, 0xcc, 0x78, 0x30, 0x00, 0x00, 0x00, 0xc6, 0xd6, 0xfe, 0xfe, 0x6c, 0x00,
0x00, 0x00, 0xc6, 0x6c, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0xf8,
0x00, 0x00, 0xfc, 0x98, 0x30, 0x64, 0xfc, 0x00, 0x1c, 0x30, 0x30, 0xe0, 0x30, 0x30, 0x1c, 0x00,
0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00, 0xe0, 0x30, 0x30, 0x1c, 0x30, 0x30, 0xe0, 0x00,
0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0x00,
0x78, 0xcc, 0xc0, 0xcc, 0x78, 0x18, 0x0c, 0x78, 0x00, 0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0x7e, 0x00,
0x1c, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0x78, 0x00, 0x7e, 0xc3, 0x3c, 0x06, 0x3e, 0x66, 0x3f, 0x00,
0xcc, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x7e, 0x00, 0xe0, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x7e, 0x00,
0x30, 0x30, 0x78, 0x0c, 0x7c, 0xcc, 0x7e, 0x00, 0x00, 0x00, 0x78, 0xc0, 0xc0, 0x78, 0x0c, 0x38,
0x7e, 0xc3, 0x3c, 0x66, 0x7e, 0x60, 0x3c, 0x00, 0xcc, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0x78, 0x00,
0xe0, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0x78, 0x00, 0xcc, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00,
0x7c, 0xc6, 0x38, 0x18, 0x18, 0x18, 0x3c, 0x00, 0xe0, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00,
0xc6, 0x38, 0x6c, 0xc6, 0xfe, 0xc6, 0xc6, 0x00, 0x30, 0x30, 0x00, 0x78, 0xcc, 0xfc, 0xcc, 0x00,
0x1c, 0x00, 0xfc, 0x60, 0x78, 0x60, 0xfc, 0x00, 0x00, 0x00, 0x7f, 0x0c, 0x7f, 0xcc, 0x7f, 0x00,
0x3e, 0x6c, 0xcc, 0xfe, 0xcc, 0xcc, 0xce, 0x00, 0x78, 0xcc, 0x00, 0x78, 0xcc, 0xcc, 0x78, 0x00,
0x00, 0xcc, 0x00, 0x78, 0xcc, 0xcc, 0x78, 0x00, 0x00, 0xe0, 0x00, 0x78, 0xcc, 0xcc, 0x78, 0x00,
0x78, 0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0x7e, 0x00, 0x00, 0xe0, 0x00, 0xcc, 0xcc, 0xcc, 0x7e, 0x00,
0x00, 0xcc, 0x00, 0xcc, 0xcc, 0x7c, 0x0c, 0xf8, 0xc3, 0x18, 0x3c, 0x66, 0x66, 0x3c, 0x18, 0x00,
0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0x00, 0x18, 0x18, 0x7e, 0xc0, 0xc0, 0x7e, 0x18, 0x18,
0x38, 0x6c, 0x64, 0xf0, 0x60, 0xe6, 0xfc, 0x00, 0xcc, 0xcc, 0x78, 0xfc, 0x30, 0xfc, 0x30, 0x30,
0xf8, 0xcc, 0xcc, 0xfa, 0xc6, 0xcf, 0xc6, 0xc7, 0x0e, 0x1b, 0x18, 0x3c, 0x18, 0x18, 0xd8, 0x70,
0x1c, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x7e, 0x00, 0x38, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00,
0x00, 0x1c, 0x00, 0x78, 0xcc, 0xcc, 0x78, 0x00, 0x00, 0x1c, 0x00, 0xcc, 0xcc, 0xcc, 0x7e, 0x00,
0x00, 0xf8, 0x00, 0xf8, 0xcc, 0xcc, 0xcc, 0x00, 0xfc, 0x00, 0xcc, 0xec, 0xfc, 0xdc, 0xcc, 0x00,
0x3c, 0x6c, 0x6c, 0x3e, 0x00, 0x7e, 0x00, 0x00, 0x38, 0x6c, 0x6c, 0x38, 0x00, 0x7c, 0x00, 0x00,
0x30, 0x00, 0x30, 0x60, 0xc0, 0xcc, 0x78, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xc0, 0xc0, 0x00, 0x00,
0x00, 0x00, 0x00, 0xfc, 0x0c, 0x0c, 0x00, 0x00, 0xc3, 0xc6, 0xcc, 0xde, 0x33, 0x66, 0xcc, 0x0f,
0xc3, 0xc6, 0xcc, 0xdb, 0x37, 0x6f, 0xcf, 0x03, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00,
0x00, 0x33, 0x66, 0xcc, 0x66, 0x33, 0x00, 0x00, 0x00, 0xcc, 0x66, 0x33, 0x66, 0xcc, 0x00, 0x00,
0x22, 0x88, 0x22, 0x88, 0x22, 0x88, 0x22, 0x88, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa,
0xdb, 0x77, 0xdb, 0xee, 0xdb, 0x77, 0xdb, 0xee, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0xf8, 0x18, 0x18, 0x18,
0x36, 0x36, 0x36, 0x36, 0xf6, 0x36, 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x36, 0x36, 0x36,
0x00, 0x00, 0xf8, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x36, 0x36, 0xf6, 0x06, 0xf6, 0x36, 0x36, 0x36,
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00, 0xfe, 0x06, 0xf6, 0x36, 0x36, 0x36,
0x36, 0x36, 0xf6, 0x06, 0xfe, 0x00, 0x00, 0x00, 0x36, 0x36, 0x36, 0x36, 0xfe, 0x00, 0x00, 0x00,
0x18, 0x18, 0xf8, 0x18, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x1f, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0xff, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x18, 0x18,
0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0xff, 0x18, 0x18, 0x18,
0x18, 0x18, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x36, 0x36, 0x36, 0x36, 0x37, 0x36, 0x36, 0x36,
0x36, 0x36, 0x37, 0x30, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x30, 0x37, 0x36, 0x36, 0x36,
0x36, 0x36, 0xf7, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xf7, 0x36, 0x36, 0x36,
0x36, 0x36, 0x37, 0x30, 0x37, 0x36, 0x36, 0x36, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00,
0x36, 0x36, 0xf7, 0x00, 0xf7, 0x36, 0x36, 0x36, 0x18, 0x18, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00,
0x36, 0x36, 0x36, 0x36, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x18, 0x18, 0x18,
0x00, 0x00, 0x00, 0x00, 0xff, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x3f, 0x00, 0x00, 0x00,
0x18, 0x18, 0x1f, 0x18, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18,
0x00, 0x00, 0x00, 0x00, 0x3f, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xff, 0x36, 0x36, 0x36,
0x18, 0x18, 0xff, 0x18, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x1f, 0x18, 0x18, 0x18, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x76, 0xdc, 0xc8, 0xdc, 0x76, 0x00, 0x00, 0x78, 0xcc, 0xf8, 0xcc, 0xf8, 0xc0, 0xc0,
0x00, 0xfc, 0xcc, 0xc0, 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0xfe, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x00,
0xfc, 0xcc, 0x60, 0x30, 0x60, 0xcc, 0xfc, 0x00, 0x00, 0x00, 0x7e, 0xd8, 0xd8, 0xd8, 0x70, 0x00,
0x00, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x60, 0xc0, 0x00, 0x76, 0xdc, 0x18, 0x18, 0x18, 0x18, 0x00,
0xfc, 0x30, 0x78, 0xcc, 0xcc, 0x78, 0x30, 0xfc, 0x38, 0x6c, 0xc6, 0xfe, 0xc6, 0x6c, 0x38, 0x00,
0x38, 0x6c, 0xc6, 0xc6, 0x6c, 0x6c, 0xee, 0x00, 0x1c, 0x30, 0x18, 0x7c, 0xcc, 0xcc, 0x78, 0x00,
0x00, 0x00, 0x7e, 0xdb, 0xdb, 0x7e, 0x00, 0x00, 0x06, 0x0c, 0x7e, 0xdb, 0xdb, 0x7e, 0x60, 0xc0,
0x38, 0x60, 0xc0, 0xf8, 0xc0, 0x60, 0x38, 0x00, 0x78, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x00,
0x00, 0xfc, 0x00, 0xfc, 0x00, 0xfc, 0x00, 0x00, 0x30, 0x30, 0xfc, 0x30, 0x30, 0x00, 0xfc, 0x00,
0x60, 0x30, 0x18, 0x30, 0x60, 0x00, 0xfc, 0x00, 0x18, 0x30, 0x60, 0x30, 0x18, 0x00, 0xfc, 0x00,
0x0e, 0x1b, 0x1b, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xd8, 0xd8, 0x70,
0x30, 0x30, 0x00, 0xfc, 0x00, 0x30, 0x30, 0x00, 0x00, 0x76, 0xdc, 0x00, 0x76, 0xdc, 0x00, 0x00,
0x38, 0x6c, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x0f, 0x0c, 0x0c, 0x0c, 0xec, 0x6c, 0x3c, 0x1c,
0x78, 0x6c, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x70, 0x18, 0x30, 0x60, 0x78, 0x00, 0x00, 0x00,
0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
const uint32_t ff_cga_palette[16] = {
0x000000, 0x0000AA, 0x00AA00, 0x00AAAA, 0xAA0000, 0xAA00AA, 0xAA5500, 0xAAAAAA,
0x555555, 0x5555FF, 0x55FF55, 0x55FFFF, 0xFF5555, 0xFF55FF, 0xFFFF55, 0xFFFFFF,
};
const uint32_t ff_ega_palette[64] = {
0x000000, 0x0000AA, 0x00AA00, 0x00AAAA, 0xAA0000, 0xAA00AA, 0xAAAA00, 0xAAAAAA,
0x000055, 0x0000FF, 0x00AA55, 0x00AAFF, 0xAA0055, 0xAA00FF, 0xAAAA55, 0xAAAAFF,
0x005500, 0x0055AA, 0x00FF00, 0x00FFAA, 0xAA5500, 0xAA55AA, 0xAAFF00, 0xAAFFAA,
0x005555, 0x0055FF, 0x00FF55, 0x00FFFF, 0xAA5555, 0xAA55FF, 0xAAFF55, 0xAAFFFF,
0x550000, 0x5500AA, 0x55AA00, 0x55AAAA, 0xFF0000, 0xFF00AA, 0xFFAA00, 0xFFAAAA,
0x550055, 0x5500FF, 0x55AA55, 0x55AAFF, 0xFF0055, 0xFF00FF, 0xFFAA55, 0xFFAAFF,
0x555500, 0x5555AA, 0x55FF00, 0x55FFAA, 0xFF5500, 0xFF55AA, 0xFFFF00, 0xFFFFAA,
0x555555, 0x5555FF, 0x55FF55, 0x55FFFF, 0xFF5555, 0xFF55FF, 0xFFFF55, 0xFFFFFF
};
|
the_stack_data/215766978.c | #include <stdio.h>
#include <stdlib.h>
char *ft_strdup(char *src);
int main(void)
{
char abc[20] = "What is your name?";
char *output;
output = ft_strdup(abc);
printf("Output: %s\n", output);
free(output);
return (0);
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.