LLVMFuzzerTestOneInput:
    8|    210|extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
    9|    210|  FuzzedDataProvider fuzzed_data(data, size);
   10|    210|  u_int16_t i, num_iteration;
   11|    210|  struct ndpi_ses_struct s;
   12|    210|  struct ndpi_des_struct d;
   13|    210|  int rc_ses, rc_des;
   14|    210|  double forecast, confidence_band, *values, value;
   15|    210|  float significance, alpha_ses, alpha_des, beta;
   16|       |
   17|       |  /* Just to have some data */
   18|    210|  if(fuzzed_data.remaining_bytes() < 2048)
  ------------------
  |  Branch (18:6): [True: 20, False: 190]
  ------------------
   19|     20|    return -1;
   20|       |
   21|       |  /* To allow memory allocation failures */
   22|    190|  fuzz_set_alloc_callbacks_and_seed(size);
   23|       |
   24|       |  /* Training */
   25|    190|  num_iteration = fuzzed_data.ConsumeIntegral<u_int8_t>();
   26|    190|  values = (double *)ndpi_malloc(sizeof(double) * num_iteration);
   27|    190|  if (!values)
  ------------------
  |  Branch (27:7): [True: 3, False: 187]
  ------------------
   28|      3|    return 0;
   29|  11.0k|  for (i = 0; i < num_iteration; i++)
  ------------------
  |  Branch (29:15): [True: 10.8k, False: 187]
  ------------------
   30|  10.8k|    values[i] = fuzzed_data.ConsumeFloatingPoint<double>();
   31|    187|  ndpi_ses_fitting(values, num_iteration, &alpha_ses);
   32|    187|  ndpi_des_fitting(values, num_iteration, &alpha_des, &beta);
   33|    187|  ndpi_free(values);
   34|       |
   35|    187|  significance = fuzzed_data.ConsumeFloatingPointInRange<float>(0, 1.1);
   36|    187|  rc_ses = ndpi_ses_init(fuzzed_data.ConsumeBool() ? &s : NULL, alpha_ses, significance);
  ------------------
  |  Branch (36:26): [True: 76, False: 111]
  ------------------
   37|    187|  rc_des = ndpi_des_init(fuzzed_data.ConsumeBool() ? &d : NULL, alpha_des, beta, significance);
  ------------------
  |  Branch (37:26): [True: 87, False: 100]
  ------------------
   38|       |
   39|    187|  num_iteration = fuzzed_data.ConsumeIntegral<u_int8_t>();
   40|  12.9k|  for (i = 0; i < num_iteration; i++) {
  ------------------
  |  Branch (40:15): [True: 12.7k, False: 187]
  ------------------
   41|  12.7k|    value = fuzzed_data.ConsumeFloatingPoint<double>();
   42|  12.7k|    if (rc_ses == 0)
  ------------------
  |  Branch (42:9): [True: 7.71k, False: 5.03k]
  ------------------
   43|  7.71k|      ndpi_ses_add_value(&s, value, &forecast, &confidence_band);
   44|  12.7k|    if (rc_des == 0)
  ------------------
  |  Branch (44:9): [True: 7.11k, False: 5.63k]
  ------------------
   45|  7.11k|      ndpi_des_add_value(&d, value, &forecast, &confidence_band);
   46|  12.7k|  }
   47|       |
   48|    187|  ndpi_ses_reset(&s);
   49|    187|  ndpi_des_reset(&d);
   50|       |
   51|    187|  return 0;
   52|    190|}

fuzz_set_alloc_callbacks:
   31|    190|{
   32|    190|  ndpi_set_memory_alloction_functions(malloc_wrapper,
   33|    190|                                      free_wrapper,
   34|    190|                                      calloc_wrapper,
   35|    190|                                      realloc_wrapper,
   36|       |                                      /* Aligned allocations are used only by croaring,
   37|       |                                         but no during fuzzing. So no point to set
   38|       |                                         these two wrappers here */
   39|    190|                                      NULL, NULL,
   40|    190|                                      malloc_wrapper,
   41|    190|                                      free_wrapper);
   42|    190|}
fuzz_set_alloc_seed:
   44|    190|{
   45|    190|  mem_alloc_state = seed;
   46|    190|}
fuzz_set_alloc_callbacks_and_seed:
   48|    190|{
   49|    190|  fuzz_set_alloc_callbacks();
   50|    190|  fuzz_set_alloc_seed(seed);
   51|    190|}
fuzz_common_code.c:malloc_wrapper:
   17|    190|static void *malloc_wrapper(size_t size) {
   18|    190|  return (fastrand () % 16) ? malloc (size) : NULL;
  ------------------
  |  Branch (18:10): [True: 187, False: 3]
  ------------------
   19|    190|}
fuzz_common_code.c:fastrand:
   11|    190|{
   12|    190|  if(!mem_alloc_state) return 1; /* No failures */
  ------------------
  |  Branch (12:6): [True: 0, False: 190]
  ------------------
   13|    190|  mem_alloc_state = (214013 * mem_alloc_state + 2531011);
   14|    190|  return (mem_alloc_state >> 16) & 0x7FFF;
   15|    190|}
fuzz_common_code.c:free_wrapper:
   20|    187|static void free_wrapper(void *freeable) {
   21|    187|  free(freeable);
   22|    187|}

ndpi_ses_init:
 1350|  2.23k|int ndpi_ses_init(struct ndpi_ses_struct *ses, double alpha, float significance) {
 1351|  2.23k|  if(!ses)
  ------------------
  |  Branch (1351:6): [True: 111, False: 2.12k]
  ------------------
 1352|    111|    return(-1);
 1353|       |
 1354|  2.12k|  memset(ses, 0, sizeof(struct ndpi_ses_struct));
 1355|       |
 1356|  2.12k|  ses->params.alpha = alpha;
 1357|       |
 1358|  2.12k|  if((significance < 0) || (significance > 1)) significance = 0.05;
  ------------------
  |  Branch (1358:6): [True: 0, False: 2.12k]
  |  Branch (1358:28): [True: 10, False: 2.11k]
  ------------------
 1359|  2.12k|  ses->params.ro         = ndpi_normal_cdf_inverse(1 - (significance / 2.));
 1360|       |
 1361|  2.12k|  return(0);
 1362|  2.23k|}
ndpi_ses_add_value:
 1381|   202k|int ndpi_ses_add_value(struct ndpi_ses_struct *ses, const double _value, double *forecast, double *confidence_band) {
 1382|   202k|  double value = (double)_value, error, sq_error;
 1383|   202k|  int rc;
 1384|       |
 1385|   202k|  if(ses->num_values == 0)
  ------------------
  |  Branch (1385:6): [True: 2.12k, False: 200k]
  ------------------
 1386|  2.12k|    *forecast = value;
 1387|   200k|  else {
 1388|   200k|#if 1
 1389|       |    /* "Classic" formula */
 1390|   200k|    *forecast = (ses->params.alpha * value) + ((1 - ses->params.alpha) * ses->last_forecast);
 1391|       |#else
 1392|       |    /* Alternative formula */
 1393|       |    *forecast = (ses->params.alpha * (ses->last_value - ses->last_forecast)) + ses->last_forecast;
 1394|       |#endif
 1395|   200k|  }
 1396|       |
 1397|   202k|  error  = value - *forecast;
 1398|   202k|  sq_error =  error * error;
 1399|   202k|  ses->sum_square_error += sq_error, ses->prev_error.sum_square_error += sq_error;
 1400|       |
 1401|   202k|  if(ses->num_values > 0) {
  ------------------
  |  Branch (1401:6): [True: 200k, False: 2.12k]
  ------------------
 1402|   200k|    u_int observations = (ses->num_values < MAX_SQUARE_ERROR_ITERATIONS) ? (ses->num_values + 1) : ((ses->num_values % MAX_SQUARE_ERROR_ITERATIONS) + MAX_SQUARE_ERROR_ITERATIONS + 1);
  ------------------
  |  | 2144|   200k|#define MAX_SQUARE_ERROR_ITERATIONS 64 /* MUST be < num_values_rollup (256 max) */
  ------------------
                  u_int observations = (ses->num_values < MAX_SQUARE_ERROR_ITERATIONS) ? (ses->num_values + 1) : ((ses->num_values % MAX_SQUARE_ERROR_ITERATIONS) + MAX_SQUARE_ERROR_ITERATIONS + 1);
  ------------------
  |  | 2144|   106k|#define MAX_SQUARE_ERROR_ITERATIONS 64 /* MUST be < num_values_rollup (256 max) */
  ------------------
                  u_int observations = (ses->num_values < MAX_SQUARE_ERROR_ITERATIONS) ? (ses->num_values + 1) : ((ses->num_values % MAX_SQUARE_ERROR_ITERATIONS) + MAX_SQUARE_ERROR_ITERATIONS + 1);
  ------------------
  |  | 2144|   106k|#define MAX_SQUARE_ERROR_ITERATIONS 64 /* MUST be < num_values_rollup (256 max) */
  ------------------
  |  Branch (1402:26): [True: 94.0k, False: 106k]
  ------------------
 1403|   200k|    double sq = sqrt(ses->sum_square_error / observations);
 1404|       |
 1405|   200k|    *confidence_band = ses->params.ro * sq;
 1406|   200k|    rc = 1;
 1407|   200k|  } else
 1408|  2.12k|    *confidence_band = 0, rc = 0;
 1409|       |
 1410|   202k|  ses->num_values++, ses->last_value = value, ses->last_forecast = *forecast;
 1411|       |
 1412|   202k|  if(++ses->prev_error.num_values_rollup == MAX_SQUARE_ERROR_ITERATIONS) {
  ------------------
  |  | 2144|   202k|#define MAX_SQUARE_ERROR_ITERATIONS 64 /* MUST be < num_values_rollup (256 max) */
  ------------------
  |  Branch (1412:6): [True: 2.22k, False: 200k]
  ------------------
 1413|  2.22k|    ses->sum_square_error = ses->prev_error.sum_square_error;
 1414|  2.22k|    ses->prev_error.num_values_rollup = 0, ses->prev_error.sum_square_error = 0;
 1415|  2.22k|  }
 1416|       |
 1417|       |#ifdef SES_DEBUG
 1418|       |  printf("[num_values: %u][[error: %.3f][forecast: %.3f][sqe: %.3f][sq: %.3f][confidence_band: %.3f]\n",
 1419|       |	   ses->num_values, error, *forecast, ses->sum_square_error, sq_error, *confidence_band);
 1420|       |#endif
 1421|       |
 1422|   202k|  return(rc);
 1423|   202k|}
ndpi_ses_reset:
 1427|    187|void ndpi_ses_reset(struct ndpi_ses_struct *ses) {
 1428|    187|  ses->prev_error.sum_square_error = 0, ses->prev_error.num_values_rollup = 0;
 1429|    187|  ses->num_values = 0;
 1430|    187|  ses->sum_square_error = ses->last_forecast = ses->last_value = 0;
 1431|    187|}
ndpi_ses_fitting:
 1438|    187|void ndpi_ses_fitting(double *values, u_int32_t num_values, float *ret_alpha) {
 1439|    187|  u_int i;
 1440|    187|  float alpha, best_alpha;
 1441|    187|  double sse, lowest_sse;
 1442|       |
 1443|    187|  if(!values || num_values == 0) {
  ------------------
  |  Branch (1443:6): [True: 0, False: 187]
  |  Branch (1443:17): [True: 73, False: 114]
  ------------------
 1444|     73|    *ret_alpha = 0;
 1445|     73|    return;
 1446|     73|  }
 1447|       |
 1448|    114|  lowest_sse = 0, best_alpha = 0;
 1449|       |
 1450|  2.16k|  for(alpha=0.1; alpha<0.99; alpha += 0.05) {
  ------------------
  |  Branch (1450:18): [True: 2.05k, False: 114]
  ------------------
 1451|  2.05k|    struct ndpi_ses_struct ses;
 1452|       |
 1453|  2.05k|    ndpi_ses_init(&ses, alpha, 0.05);
 1454|       |
 1455|       |#ifdef SES_DEBUG
 1456|       |    printf("\nDouble Exponential Smoothing [alpha: %.2f]\n", alpha);
 1457|       |#endif
 1458|       |
 1459|  2.05k|    sse = 0;
 1460|       |
 1461|   197k|    for(i=0; i<num_values; i++) {
  ------------------
  |  Branch (1461:14): [True: 195k, False: 2.05k]
  ------------------
 1462|   195k|      double prediction, confidence_band;
 1463|   195k|      double diff;
 1464|       |
 1465|   195k|      if(ndpi_ses_add_value(&ses, values[i], &prediction, &confidence_band) != 0) {
  ------------------
  |  Branch (1465:10): [True: 193k, False: 2.05k]
  ------------------
 1466|   193k|	diff = fabs(prediction-values[i]);
 1467|       |
 1468|       |#ifdef SES_DEBUG
 1469|       |	printf("%2u)\t%12.3f\t%.3f\t%.3f\n", i, values[i], prediction, diff);
 1470|       |#endif
 1471|       |
 1472|   193k|	sse += diff*diff;
 1473|   193k|      }
 1474|   195k|    }
 1475|       |
 1476|  2.05k|    if(lowest_sse == 0)
  ------------------
  |  Branch (1476:8): [True: 266, False: 1.78k]
  ------------------
 1477|    266|      lowest_sse = sse, best_alpha = alpha; /* first run */
 1478|  1.78k|    else {
 1479|  1.78k|      if(sse <= lowest_sse)
  ------------------
  |  Branch (1479:10): [True: 1.78k, False: 0]
  ------------------
 1480|  1.78k|	lowest_sse = sse, best_alpha = alpha;
 1481|  1.78k|    }
 1482|       |
 1483|       |#ifdef SES_DEBUG
 1484|       |    printf("[alpha: %.2f] - SSE: %.2f [BEST: alpha: %.2f/SSE: %.2f]\n", alpha, sse,
 1485|       |	   best_alpha, lowest_sse);
 1486|       |#endif
 1487|  2.05k|  } /* for (alpha) */
 1488|       |
 1489|       |#ifdef SES_DEBUG
 1490|       |  printf("BEST [alpha: %.2f][SSE: %.2f]\n", best_alpha, lowest_sse);
 1491|       |#endif
 1492|       |
 1493|    114|  *ret_alpha = best_alpha;
 1494|    114|}
ndpi_des_init:
 1503|  37.1k|int ndpi_des_init(struct ndpi_des_struct *des, double alpha, double beta, float significance) {
 1504|  37.1k|  if(!des)
  ------------------
  |  Branch (1504:6): [True: 100, False: 37.0k]
  ------------------
 1505|    100|    return(-1);
 1506|       |
 1507|  37.0k|  memset(des, 0, sizeof(struct ndpi_des_struct));
 1508|       |
 1509|  37.0k|  des->params.alpha = alpha;
 1510|  37.0k|  des->params.beta = beta;
 1511|       |
 1512|  37.0k|  if((significance < 0) || (significance > 1)) significance = 0.05;
  ------------------
  |  Branch (1512:6): [True: 0, False: 37.0k]
  |  Branch (1512:28): [True: 9, False: 37.0k]
  ------------------
 1513|  37.0k|  des->params.ro         = ndpi_normal_cdf_inverse(1 - (significance / 2.));
 1514|       |
 1515|  37.0k|  return(0);
 1516|  37.1k|}
ndpi_des_reset:
 1520|    187|void ndpi_des_reset(struct ndpi_des_struct *des) {
 1521|    187|  des->prev_error.sum_square_error = 0, des->prev_error.num_values_rollup = 0;
 1522|    187|  des->num_values = 0;
 1523|    187|  des->sum_square_error = des->last_forecast = des->last_trend = des->last_value = 0;
 1524|    187|}
ndpi_des_add_value:
 1543|  3.52M|int ndpi_des_add_value(struct ndpi_des_struct *des, const double _value, double *forecast, double *confidence_band) {
 1544|  3.52M|  double value = (double)_value, error, sq_error;
 1545|  3.52M|  int rc;
 1546|       |
 1547|  3.52M|  if(des->num_values == 0)
  ------------------
  |  Branch (1547:6): [True: 37.0k, False: 3.48M]
  ------------------
 1548|  37.0k|    *forecast = value, des->last_trend = 0;
 1549|  3.48M|  else {
 1550|  3.48M|    *forecast = (des->params.alpha * value) + ((1 - des->params.alpha) * (des->last_forecast + des->last_trend));
 1551|  3.48M|    des->last_trend = (des->params.beta * (*forecast - des->last_forecast)) + ((1 - des->params.beta) * des->last_trend);
 1552|  3.48M|  }
 1553|       |
 1554|  3.52M|  error  = value - *forecast;
 1555|  3.52M|  sq_error =  error * error;
 1556|  3.52M|  des->sum_square_error += sq_error, des->prev_error.sum_square_error += sq_error;
 1557|       |
 1558|  3.52M|  if(des->num_values > 0) {
  ------------------
  |  Branch (1558:6): [True: 3.48M, False: 37.0k]
  ------------------
 1559|  3.48M|    u_int observations = (des->num_values < MAX_SQUARE_ERROR_ITERATIONS) ? (des->num_values + 1) : ((des->num_values % MAX_SQUARE_ERROR_ITERATIONS) + MAX_SQUARE_ERROR_ITERATIONS + 1);
  ------------------
  |  | 2144|  3.48M|#define MAX_SQUARE_ERROR_ITERATIONS 64 /* MUST be < num_values_rollup (256 max) */
  ------------------
                  u_int observations = (des->num_values < MAX_SQUARE_ERROR_ITERATIONS) ? (des->num_values + 1) : ((des->num_values % MAX_SQUARE_ERROR_ITERATIONS) + MAX_SQUARE_ERROR_ITERATIONS + 1);
  ------------------
  |  | 2144|  1.84M|#define MAX_SQUARE_ERROR_ITERATIONS 64 /* MUST be < num_values_rollup (256 max) */
  ------------------
                  u_int observations = (des->num_values < MAX_SQUARE_ERROR_ITERATIONS) ? (des->num_values + 1) : ((des->num_values % MAX_SQUARE_ERROR_ITERATIONS) + MAX_SQUARE_ERROR_ITERATIONS + 1);
  ------------------
  |  | 2144|  1.84M|#define MAX_SQUARE_ERROR_ITERATIONS 64 /* MUST be < num_values_rollup (256 max) */
  ------------------
  |  Branch (1559:26): [True: 1.63M, False: 1.84M]
  ------------------
 1560|  3.48M|    double sq = sqrt(des->sum_square_error / observations);
 1561|       |
 1562|  3.48M|    *confidence_band = des->params.ro * sq;
 1563|  3.48M|    rc = 1;
 1564|  3.48M|  } else
 1565|  37.0k|    *confidence_band = 0, rc = 0;
 1566|       |
 1567|  3.52M|  des->num_values++, des->last_value = value, des->last_forecast = *forecast;
 1568|       |
 1569|  3.52M|  if(++des->prev_error.num_values_rollup == MAX_SQUARE_ERROR_ITERATIONS) {
  ------------------
  |  | 2144|  3.52M|#define MAX_SQUARE_ERROR_ITERATIONS 64 /* MUST be < num_values_rollup (256 max) */
  ------------------
  |  Branch (1569:6): [True: 38.6k, False: 3.48M]
  ------------------
 1570|  38.6k|    des->sum_square_error = des->prev_error.sum_square_error;
 1571|  38.6k|    des->prev_error.num_values_rollup = 0, des->prev_error.sum_square_error = 0;
 1572|  38.6k|  }
 1573|       |
 1574|       |#ifdef DES_DEBUG
 1575|       |  printf("[num_values: %u][[error: %.3f][forecast: %.3f][trend: %.3f[sqe: %.3f][sq: %.3f][confidence_band: %.3f]\n",
 1576|       |	 des->num_values, error, *forecast, des->last_trend, des->sum_square_error, sq, *confidence_band);
 1577|       |#endif
 1578|       |
 1579|  3.52M|  return(rc);
 1580|  3.52M|}
ndpi_des_fitting:
 1587|    187|void ndpi_des_fitting(double *values, u_int32_t num_values, float *ret_alpha, float *ret_beta) {
 1588|    187|  u_int i;
 1589|    187|  float alpha, best_alpha, best_beta, beta = 0;
 1590|    187|  double sse, lowest_sse;
 1591|       |
 1592|    187|  if(!values || num_values == 0) {
  ------------------
  |  Branch (1592:6): [True: 0, False: 187]
  |  Branch (1592:17): [True: 73, False: 114]
  ------------------
 1593|     73|    *ret_alpha = 0;
 1594|     73|    *ret_beta = 0;
 1595|     73|    return;
 1596|     73|  }
 1597|       |
 1598|    114|  lowest_sse = 0, best_alpha = 0, best_beta = 0;
 1599|       |
 1600|  2.16k|  for(beta=0.1; beta<0.99; beta += 0.05) {
  ------------------
  |  Branch (1600:17): [True: 2.05k, False: 114]
  ------------------
 1601|  38.9k|    for(alpha=0.1; alpha<0.99; alpha += 0.05) {
  ------------------
  |  Branch (1601:20): [True: 36.9k, False: 2.05k]
  ------------------
 1602|  36.9k|      struct ndpi_des_struct des;
 1603|       |
 1604|  36.9k|      ndpi_des_init(&des, alpha, beta, 0.05);
 1605|       |
 1606|       |#ifdef DES_DEBUG
 1607|       |      printf("\nDouble Exponential Smoothing [alpha: %.2f][beta: %.2f]\n", alpha, beta);
 1608|       |#endif
 1609|       |
 1610|  36.9k|      sse = 0;
 1611|       |
 1612|  3.55M|      for(i=0; i<num_values; i++) {
  ------------------
  |  Branch (1612:16): [True: 3.51M, False: 36.9k]
  ------------------
 1613|  3.51M|	double prediction, confidence_band;
 1614|  3.51M|	double diff;
 1615|       |
 1616|  3.51M|	if(ndpi_des_add_value(&des, values[i], &prediction, &confidence_band) != 0) {
  ------------------
  |  Branch (1616:5): [True: 3.47M, False: 36.9k]
  ------------------
 1617|  3.47M|	  diff = fabs(prediction-values[i]);
 1618|       |
 1619|       |#ifdef DES_DEBUG
 1620|       |	  printf("%2u)\t%12.3f\t%.3f\t%.3f\n", i, values[i], prediction, diff);
 1621|       |#endif
 1622|       |
 1623|  3.47M|	  sse += diff*diff;
 1624|  3.47M|	}
 1625|  3.51M|      }
 1626|       |
 1627|  36.9k|      if(lowest_sse == 0)
  ------------------
  |  Branch (1627:10): [True: 2.95k, False: 33.9k]
  ------------------
 1628|  2.95k|	lowest_sse = sse, best_alpha = alpha, best_beta = beta; /* first run */
 1629|  33.9k|      else {
 1630|  33.9k|	if(sse <= lowest_sse)
  ------------------
  |  Branch (1630:5): [True: 9.63k, False: 24.3k]
  ------------------
 1631|  9.63k|	  lowest_sse = sse, best_alpha = alpha, best_beta = beta;
 1632|  33.9k|      }
 1633|       |
 1634|       |#ifdef DES_DEBUG
 1635|       |      printf("[alpha: %.2f][beta: %.2f] - SSE: %.2f [BEST: alpha: %.2f/beta: %.2f/SSE: %.2f]\n", alpha, beta, sse,
 1636|       |	     best_alpha, best_beta, lowest_sse);
 1637|       |#endif
 1638|  36.9k|    } /* for (alpha) */
 1639|  2.05k|  } /* for (beta) */
 1640|       |
 1641|       |#ifdef DES_DEBUG
 1642|       |  printf("BEST [alpha: %.2f][beta: %.2f][SSE: %.2f]\n", best_alpha, best_beta, lowest_sse);
 1643|       |#endif
 1644|       |
 1645|    114|  *ret_alpha = best_alpha, *ret_beta = best_beta;
 1646|    114|}
ndpi_analyze.c:ndpi_normal_cdf_inverse:
 1084|  39.1k|static double ndpi_normal_cdf_inverse(double p) {
 1085|  39.1k|  if(p <= 0.0 || p >= 1.0)
  ------------------
  |  Branch (1085:6): [True: 0, False: 39.1k]
  |  Branch (1085:18): [True: 7, False: 39.1k]
  ------------------
 1086|      7|    return(0); /* Invalid argument: valid range 0 < X < 1 */
 1087|       |
 1088|  39.1k|  if(p < 0.5) {
  ------------------
  |  Branch (1088:6): [True: 0, False: 39.1k]
  ------------------
 1089|       |    // F^-1(p) = - G^-1(p)
 1090|      0|    return -ndpi_rational_approximation( sqrt(-2.0*log(p)) );
 1091|  39.1k|  } else {
 1092|       |    // F^-1(p) = G^-1(1-p)
 1093|  39.1k|    return ndpi_rational_approximation( sqrt(-2.0*log(1-p)) );
 1094|  39.1k|  }
 1095|  39.1k|}
ndpi_analyze.c:ndpi_rational_approximation:
 1075|  39.1k|static double ndpi_rational_approximation(double t) {
 1076|       |  // Abramowitz and Stegun formula 26.2.23.
 1077|       |  // The absolute value of the error should be less than 4.5 e-4.
 1078|  39.1k|  double c[] = { 2.515517, 0.802853, 0.010328 };
 1079|  39.1k|  double d[] = { 1.432788, 0.189269, 0.001308 };
 1080|       |
 1081|  39.1k|  return(t - ((c[2]*t + c[1])*t + c[0]) / (((d[2]*t + d[1])*t + d[0])*t + 1.0));
 1082|  39.1k|}

ndpi_set_memory_alloction_functions:
   52|    190|                                         void (*__ndpi_flow_free)(void *ptr)) {
   53|       |
   54|       |  /* We can't log here */
   55|       |
   56|    190|  if(__ndpi_malloc && __ndpi_free &&
  ------------------
  |  Branch (56:6): [True: 190, False: 0]
  |  Branch (56:23): [True: 190, False: 0]
  ------------------
   57|    190|     __ndpi_calloc && __ndpi_realloc) {
  ------------------
  |  Branch (57:6): [True: 190, False: 0]
  |  Branch (57:23): [True: 190, False: 0]
  ------------------
   58|    190|    _ndpi_malloc = __ndpi_malloc;
   59|    190|    _ndpi_free = __ndpi_free;
   60|    190|    _ndpi_calloc = __ndpi_calloc;
   61|    190|    _ndpi_realloc = __ndpi_realloc;
   62|    190|  }
   63|    190|  if(__ndpi_aligned_malloc && __ndpi_aligned_free) {
  ------------------
  |  Branch (63:6): [True: 0, False: 190]
  |  Branch (63:31): [True: 0, False: 0]
  ------------------
   64|      0|    _ndpi_aligned_malloc = __ndpi_aligned_malloc;
   65|      0|    _ndpi_aligned_free = __ndpi_aligned_free;
   66|      0|  }
   67|    190|  if(__ndpi_flow_malloc && __ndpi_flow_free) {
  ------------------
  |  Branch (67:6): [True: 190, False: 0]
  |  Branch (67:28): [True: 190, False: 0]
  ------------------
   68|    190|    _ndpi_flow_malloc = __ndpi_flow_malloc;
   69|    190|    _ndpi_flow_free = __ndpi_flow_free;
   70|    190|  }
   71|    190|}
ndpi_malloc:
   81|    190|void *ndpi_malloc(size_t size) {
   82|    190|  __sync_fetch_and_add(&ndpi_tot_allocated_memory, size);
   83|    190|  return(_ndpi_malloc ? _ndpi_malloc(size) : malloc(size));
  ------------------
  |  Branch (83:10): [True: 190, False: 0]
  ------------------
   84|    190|}
ndpi_free:
   95|    187|void ndpi_free(void *ptr) {
   96|    187|  _ndpi_free ? _ndpi_free(ptr) : free(ptr);
  ------------------
  |  Branch (96:3): [True: 187, False: 0]
  ------------------
   97|    187|}

