decompiled_code:
void __fastcall tps_data_destroy(void *a1)
{
free(a1);
}

canonical_decompiled_code:
void __fastcall func5(void *a1)
{
free(a1);
}

original_code:
void tps_data_destroy(TPSData *data) {
  free(data);
}

canonical_original_code:
void tps_data_destroy(struct TPSData *data) {
  free(data);
}


repo: giomasce/dvbt

decompiled_code:
void __fastcall heap_destroy(void *ptr)
{
free(*((void **)ptr + 1));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func6(void *ptr)
{
free(*((void **)ptr + 1));
free(ptr);
}

original_code:
void heap_destroy(Heap *heap) {
  free(heap->elements);
  free(heap);
}

canonical_original_code:
void heap_destroy(struct Heap *heap) {
  free(heap->elements);
  free(heap);
}

variable_types: struct Heap { unsigned long length; struct HeapElement { double weight; void *ptr; } *elements; } *

return_type: void

user_defined_types: struct Heap { unsigned long length; struct HeapElement *elements; }


decompiled_code:
__int64 __fastcall heap_up(__int64 a1, unsigned __int64 a2)
{
unsigned __int64 v3; // rbx
unsigned __int64 v4; // rbp
unsigned __int64 v5; // rsi
__int64 *v6; // rdi
__int64 *v7; // rsi
__int64 result; // rax

v3 = a2;
if ( a2 )
{
do
{
v4 = v3 - 1;
v5 = v3;
v3 = (v3 - 1) >> 1;
v6 = (__int64 *)(*(_QWORD *)(a1 + 8) + 16 * v3);
v7 = (__int64 *)(*(_QWORD *)(a1 + 8) + 16 * v5);
if ( *(double *)v6 <= *(double *)v7 )
break;
result = heap_swap(v6, v7);
}
while ( v4 > 1 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, unsigned __int64 a2)
{
unsigned __int64 v3; // rbx
unsigned __int64 v4; // rbp
unsigned __int64 v5; // rsi
__int64 *v6; // rdi
__int64 *v7; // rsi
__int64 result; // rax

v3 = a2;
if ( a2 )
{
do
{
v4 = v3 - 1;
v5 = v3;
v3 = (v3 - 1) >> 1;
v6 = (__int64 *)(*(_QWORD *)(a1 + 8) + 16 * v3);
v7 = (__int64 *)(*(_QWORD *)(a1 + 8) + 16 * v5);
if ( *(double *)v6 <= *(double *)v7 )
break;
result = func7(v6, v7);
}
while ( v4 > 1 );
}
return result;
}

original_code:
void heap_up(Heap *heap, size_t i) {
  while (i > 0) {
    size_t parent = (i - 1) / 2;
    if (heap->elements[parent].weight > heap->elements[i].weight) {
      heap_swap(&heap->elements[parent], &heap->elements[i]);
      i = parent;
    } else {
      break;
    }
  }
}

canonical_original_code:
void heap_up(struct Heap *heap, unsigned long i) {
  while (i > 0) {
    unsigned long parent = (i - 1) / 2;
    if (heap->elements[parent].weight > heap->elements[i].weight) {
      heap_swap(&heap->elements[parent], &heap->elements[i]);
      i = parent;
    } else {
      break;
    }
  }
}

variable_types:
i
unsigned long

variable_types:
parent
unsigned long

user_defined_types: struct HeapElement { double weight; void *ptr; }


decompiled_code:
unsigned __int64 __fastcall heap_down(unsigned __int64 *a1, unsigned __int64 a2)
{
unsigned __int64 result; // rax
unsigned __int64 v4; // rcx
unsigned __int64 v5; // rbx
__int64 *v6; // rdi
__int64 *v7; // rsi

result = 2 * a2 + 1;
v4 = *a1;
if ( result < *a1 )
{
while ( 1 )
{
v5 = 2 * (a2 + 1);
if ( v5 >= v4 )
{
v5 = result;
}
else if ( *(double *)(a1[1] + 16 * result) <= *(double *)(a1[1] + 32 * (a2 + 1)) )
{
v5 = result;
}
v6 = (__int64 *)(a1[1] + 16 * v5);
v7 = (__int64 *)(a1[1] + 16 * a2);
if ( *(double *)v7 <= *(double *)v6 )
break;
heap_swap(v6, v7);
result = 2 * v5 + 1;
v4 = *a1;
if ( result >= *a1 )
break;
a2 = v5;
}
}
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func9(unsigned __int64 *a1, unsigned __int64 a2)
{
unsigned __int64 result; // rax
unsigned __int64 v4; // rcx
unsigned __int64 v5; // rbx
__int64 *v6; // rdi
__int64 *v7; // rsi

result = 2 * a2 + 1;
v4 = *a1;
if ( result < *a1 )
{
while ( 1 )
{
v5 = 2 * (a2 + 1);
if ( v5 >= v4 )
{
v5 = result;
}
else if ( *(double *)(a1[1] + 16 * result) <= *(double *)(a1[1] + 32 * (a2 + 1)) )
{
v5 = result;
}
v6 = (__int64 *)(a1[1] + 16 * v5);
v7 = (__int64 *)(a1[1] + 16 * a2);
if ( *(double *)v7 <= *(double *)v6 )
break;
func7(v6, v7);
result = 2 * v5 + 1;
v4 = *a1;
if ( result >= *a1 )
break;
a2 = v5;
}
}
return result;
}

original_code:
void heap_down(Heap *heap, size_t i) {
  while (2*i+1 < heap->length) {
    size_t child = 2*i + 1;
    if ((2*i+2 < heap->length) && (heap->elements[2*i+2].weight < heap->elements[child].weight)) {
      child = 2*i + 2;
    }
    if (heap->elements[child].weight < heap->elements[i].weight) {
      heap_swap(&heap->elements[child], &heap->elements[i]);
      i = child;
    } else {
      break;
    }
  }
}

canonical_original_code:
void heap_down(struct Heap *heap, unsigned long i) {
  while (2*i+1 < heap->length) {
    unsigned long child = 2*i + 1;
    if ((2*i+2 < heap->length) && (heap->elements[2*i+2].weight < heap->elements[child].weight)) {
      child = 2*i + 2;
    }
    if (heap->elements[child].weight < heap->elements[i].weight) {
      heap_swap(&heap->elements[child], &heap->elements[i]);
      i = child;
    } else {
      break;
    }
  }
}

variable_types:
child
unsigned long


original_code:
void heap_push(Heap *heap, double weight, void *ptr) {
  heap->elements[heap->length].weight = weight;
  heap->elements[heap->length].ptr = ptr;
  heap->length++;
  heap_up(heap, heap->length-1);
}

canonical_original_code:
void heap_push(struct Heap *heap, double weight, void *ptr) {
  heap->elements[heap->length].weight = weight;
  heap->elements[heap->length].ptr = ptr;
  heap->length++;
  heap_up(heap, heap->length-1);
}

variable_types: weight double

variable_types:
ptr
void *


decompiled_code:
unsigned __int64 __fastcall heap_pop(__int64 a1)
{
unsigned __int64 result; // rax
__int64 v2; // rsi

result = *(_QWORD *)a1;
v2 = *(_QWORD *)a1 - 1LL;
*(_QWORD *)a1 = v2;
if ( v2 )
{
heap_swap(*(__int64 **)(a1 + 8), (__int64 *)(*(_QWORD *)(a1 + 8) + 16 * v2));
result = heap_down((unsigned __int64 *)a1, 0LL);
}
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func12(__int64 a1)
{
unsigned __int64 result; // rax
__int64 v2; // rsi

result = *(_QWORD *)a1;
v2 = *(_QWORD *)a1 - 1LL;
*(_QWORD *)a1 = v2;
if ( v2 )
{
func7(*(__int64 **)(a1 + 8), (__int64 *)(*(_QWORD *)(a1 + 8) + 16 * v2));
result = func9((unsigned __int64 *)a1, 0LL);
}
return result;
}

original_code:
void heap_pop(Heap *heap) {
  heap->length--;
  if (heap->length > 0) {
    heap_swap(&heap->elements[0], &heap->elements[heap->length]);
    heap_down(heap, 0);
  }
}

canonical_original_code:
void heap_pop(struct Heap *heap) {
  heap->length--;
  if (heap->length > 0) {
    heap_swap(&heap->elements[0], &heap->elements[heap->length]);
    heap_down(heap, 0);
  }
}


f

repo: giordano/Tesi-triennale

decompiled_code:
double __fastcall f(double a1, double a2, double a3)
{
double v4; // r14

v4 = fmod(a3, 6.283185307179586);
return a1 - a2 * sin(a1) - v4;
}

canonical_decompiled_code:
double __fastcall func7(double a1, double a2, double a3)
{
double v4; // r14

v4 = fmod(a3, 6.283185307179586);
return a1 - a2 * sin(a1) - v4;
}

original_code:
double f(double psi, double e, double phi)
{
  phi=fmod(phi,2*3.14159265358979323846);
  return psi-e*sin(psi)-phi;
}

variable_types: psi double

variable_types: e double

variable_types: phi double

return_type: double


decompiled_code:
double __fastcall psi_newton(double a1, double a2)
{
double i; // rbx
double v4; // [rsp+8h] [rbp-30h]
double cosx; // [rsp+10h] [rbp-28h] BYREF
double sinx[4]; // [rsp+18h] [rbp-20h] BYREF

v4 = fmod(a1, 6.283185307179586);
for ( i = v4; fabs(f(i, a2, v4)) > 1.0e-12; i = i - (i - a2 * sinx[0] - v4) / (1.0 - a2 * cosx) )
sincos(i, sinx, &cosx);
return i;
}

canonical_decompiled_code:
double __fastcall func9(double a1, double a2)
{
double i; // rbx
double v4; // [rsp+8h] [rbp-30h]
double cosx; // [rsp+10h] [rbp-28h] BYREF
double sinx[4]; // [rsp+18h] [rbp-20h] BYREF

v4 = fmod(a1, 6.283185307179586);
for ( i = v4; fabs(f(i, a2, v4)) > 1.0e-12; i = i - (i - a2 * sinx[0] - v4) / (1.0 - a2 * cosx) )
sincos(i, sinx, &cosx);
return i;
}

original_code:
double psi_newton(double phi, double e)
{
  double psi;
  phi=fmod(phi,2*3.14159265358979323846);
  psi=phi;
  while(fabs(f(psi,e,phi))>1e-12)
    psi-=(psi-e*sin(psi)-phi)/(1-e*cos(psi));
  return psi;
}


r

decompiled_code:
double __fastcall r(double a1, double a2, double a3)
{
return (1.0 - a2 * cos(a3)) * a1;
}

canonical_decompiled_code:
double __fastcall func11(double a1, double a2, double a3)
{
return (1.0 - a2 * cos(a3)) * a1;
}

original_code:
double r(double semiasse, double e, double psi)
{
  return semiasse*(1-e*cos(psi));
}

variable_types: semiasse double


pianodelcielo

decompiled_code:
void __fastcall pianodelcielo(double *a1, double *a2, double a3, double a4)
{
double v4; // r13
double v5; // rbx
double v6; // xmm3_8
double v7; // xmm2_8
double v8; // [rsp+0h] [rbp-38h] BYREF
double sinx[6]; // [rsp+8h] [rbp-30h] BYREF

sincos(a3, sinx, &v8);
v4 = v8;
v5 = sinx[0];
sincos(a4, sinx, &v8);
v6 = v8;
v7 = sinx[0];
*a2 = (v4 * *a1 - v5 * a1[1]) * sinx[0] + v8 * a1[2];
a2[1] = v5 * *a1 + v4 * a1[1];
a2[2] = (v5 * a1[1] - v4 * *a1) * v6 + v7 * a1[2];
}

canonical_decompiled_code:
void __fastcall func13(double *a1, double *a2, double a3, double a4)
{
double v4; // r13
double v5; // rbx
double v6; // xmm3_8
double v7; // xmm2_8
double v8; // [rsp+0h] [rbp-38h] BYREF
double sinx[6]; // [rsp+8h] [rbp-30h] BYREF

sincos(a3, sinx, &v8);
v4 = v8;
v5 = sinx[0];
sincos(a4, sinx, &v8);
v6 = v8;
v7 = sinx[0];
*a2 = (v4 * *a1 - v5 * a1[1]) * sinx[0] + v8 * a1[2];
a2[1] = v5 * *a1 + v4 * a1[1];
a2[2] = (v5 * a1[1] - v4 * *a1) * v6 + v7 * a1[2];
}

original_code:
void pianodelcielo(double Qa[3], double phi, double i, double Qb[3])
{
  Qb[0]=sin(i)*(Qa[0]*cos(phi)-Qa[1]*sin(phi))+Qa[2]*cos(i);
  Qb[1]=Qa[0]*sin(phi)+Qa[1]*cos(phi);
  Qb[2]=cos(i)*(Qa[1]*sin(phi)-Qa[0]*cos(phi))+Qa[2]*sin(i);
}

variable_types:
Qa
double [3]

variable_types: i double

variable_types:
Qb
double [3]


decompiled_code:
void __fastcall vettore_scalare(int a1, __int64 a2, __int64 a3, double a4)
{
__int64 i; // rax

if ( a1 > 0 )
{
for ( i = 0LL; i != a1; ++i )
*(double *)(a3 + 8 * i) = a4 * *(double *)(a2 + 8 * i);
}
}

original_code:
void vettore_scalare(int n, double a[], double b[], double c)
{
  int i;
  for (i=0; i<n; i++)
    b[i]=c*a[i];
}

variable_types: n int

variable_types:
a
double []

variable_types:
b
double []

variable_types: c double

variable_types: i int


original_code:
double area_coperta(double r1, double r2, double d, double x1,
      double x2){
  double theta1, theta2;
  double dA;
  theta1=2*acos((r1*r1-r2*r2+d*d)/(2*r1*d));
  theta2=2*acos((r2*r2-r1*r1+d*d)/(2*r2*d));
  if(x1 >= x2)
    dA=0;
  else
    {
      if(d > r1+r2)
 dA=0;
      else if(r1-r2 <= d)
 dA=r1*r1/2*(theta1-sin(theta1))+r2*r2/2*(theta2-sin(theta2));
      else
 dA=3.14159265358979323846*r2*r2;
    }
  return dA;
}

canonical_original_code:
double area_coperta(double r1, double r2, double d, double x1, double x2){
  double theta1; double theta2;
  double dA;
  theta1=2*acos((r1*r1-r2*r2+d*d)/(2*r1*d));
  theta2=2*acos((r2*r2-r1*r1+d*d)/(2*r2*d));
  if(x1 >= x2)
    dA=0;
  else
    {
      if(d > r1+r2)
 dA=0;
      else if(r1-r2 <= d)
 dA=r1*r1/2*(theta1-sin(theta1))+r2*r2/2*(theta2-sin(theta2));
      else
 dA=3.14159265358979323846*r2*r2;
    }
  return dA;
}

variable_types: d double

variable_types: dA double


flusso

decompiled_code:
double __fastcall flusso(double a1, double a2, double a3, double a4)
{
return (1.0 - a4 / (a3 * 3.141592653589793 * a3)) * (a1 * a2) * 0.25;
}

original_code:
double flusso(double f, double lum, double r, double dA)
{
  return f*lum*(1-dA/(3.14159265358979323846*r*r))/4;
}

variable_types: f double

variable_types: lum double

variable_types: r double


repo: giraldeau/minimods

decompiled_code:
int __fastcall show_stack(_QWORD *a1)
{
_QWORD *v1; // rbx
int result; // eax

v1 = a1;
printf("%-18s %-18s\n", "address", "value");
do
{
result = printf("0x%016lx 0x%016lx\n", v1, *v1);
++v1;
}
while ( v1 != a1 + 100 );
return result;
}

canonical_decompiled_code:
int __fastcall func7(_QWORD *a1)
{
_QWORD *v1; // rbx
int result; // eax

v1 = a1;
printf("%-18s %-18s\n", "address", "value");
do
{
result = printf("0x%016lx 0x%016lx\n", v1, *v1);
++v1;
}
while ( v1 != a1 + 100 );
return result;
}

original_code:
void show_stack(unsigned long stack) {
 int i;
 unsigned long addr;
 printf("%-18s %-18s\n", "address", "value");
 for (i = 0; i < 100; i++) {
  addr = stack + i * sizeof(unsigned long);
  printf("0x%016lx 0x%016lx\n", addr, *(unsigned long *)addr);
 }
}

variable_types:
stack
unsigned long

variable_types:
addr
unsigned long


c

decompiled_code:
int c()
{
++x;
return d();
}

canonical_decompiled_code:
int func9()
{
++x;
return func8();
}


b

decompiled_code:
int b()
{
++x;
return c();
}

canonical_decompiled_code:
int func10()
{
++x;
return func9();
}


a

decompiled_code:
int a()
{
++x;
return b();
}

canonical_decompiled_code:
int func11()
{
++x;
return func10();
}


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
a();
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
func11();
return 0;
}

original_code:
int main(int argc, char **argv) {
 a();
 return 0;
}

variable_types: argc int

variable_types:
argv
char **

return_type: int


delete

repo: girishponkiya/brach-and-bound

original_code:
list delete(list l, int x){
 int i;
 list temp, prev, ll;
 ll = l;
 i = 1;
 if( x==0 ){
  ll = ll->next;
   }else{
  prev = ll;
  while( i<x && prev ){
     prev = prev->next;
     i++;
  }
  if( prev ){
   temp = prev->next;
   if( temp ){
    prev->next = prev->next->next;
    free( temp );
   }
  }
   }
   return ll;
}

canonical_original_code:
struct _list *delete(struct _list *l, int x){
 int i;
 struct _list *temp; struct _list *prev; struct _list *ll;
 ll = l;
 i = 1;
 if( x==0 ){
  ll = ll->next;
   }else{
  prev = ll;
  while( i<x && prev ){
     prev = prev->next;
     i++;
  }
  if( prev ){
   temp = prev->next;
   if( temp ){
    prev->next = prev->next->next;
    free( temp );
   }
  }
   }
   return ll;
}

variable_types:
l
struct _list *

variable_types: x int

variable_types: struct _list { int num; struct _list *next; } *


deleteList

decompiled_code:
void __fastcall deleteList(void *ptr)
{
void *v1; // rbx
void *v2; // rdi

v1 = ptr;
while ( v1 )
{
v2 = v1;
v1 = (void *)*((_QWORD *)v1 + 1);
free(v2);
}
}

canonical_decompiled_code:
void __fastcall func8(void *ptr)
{
void *v1; // rbx
void *v2; // rdi

v1 = ptr;
while ( v1 )
{
v2 = v1;
v1 = (void *)*((_QWORD *)v1 + 1);
free(v2);
}
}

original_code:
void deleteList(list l){
 list temp;
 while( l != ((void *)0)){
  temp = l;
   l = l->next;
  free( temp );
 }
}

canonical_original_code:
void deleteList(struct _list *l){
 struct _list *temp;
 while( l != ((void *)0)){
  temp = l;
   l = l->next;
  free( temp );
 }
}

user_defined_types: struct _list { int num; struct _list *next; }


calcJ

decompiled_code:
__int64 __fastcall calcJ(__int64 a1)
{
__int64 result; // rax

if ( !a1 )
return 0LL;
LODWORD(result) = 0;
do
{
result = (unsigned int)(*(_DWORD *)a1 + result);
a1 = *(_QWORD *)(a1 + 8);
}
while ( a1 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
__int64 result; // rax

if ( !a1 )
return 0LL;
LODWORD(result) = 0;
do
{
result = (unsigned int)(*(_DWORD *)a1 + result);
a1 = *(_QWORD *)(a1 + 8);
}
while ( a1 );
return result;
}

original_code:
int calcJ(list set, int size ){
   int result = 0;
   while( set != ((void *)0) ){
  result += set->num;
  set = set->next;
   }
   return result;
}

canonical_original_code:
int calcJ(struct _list *set, int size){
   int result = 0;
   while( set != ((void *)0) ){
  result += set->num;
  set = set->next;
   }
   return result;
}

variable_types: size int

variable_types: result int


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int *v3; // rbp
unsigned int *v4; // r12
int v5; // ebx
unsigned int *v6; // rax
unsigned int *v7; // rbx
unsigned int v8; // eax
unsigned int *v9; // rbx
unsigned int v10; // eax
int v12; // [rsp+8h] [rbp-30h]
int v13; // [rsp+Ch] [rbp-2Ch]

printf("\n\n===: Program for feature selection :===");
printf("\n\n M = ");
__isoc99_scanf();
printf(" m = ");
__isoc99_scanf();
if ( v13 <= 0 )
{
printf("\n Set of features: ");
v3 = 0LL;
}
else
{
v3 = (unsigned int *)malloc(0x10uLL);
*v3 = 1;
*((_QWORD *)v3 + 1) = 0LL;
v4 = v3;
v5 = 1;
while ( v13 != v5 )
{
v6 = (unsigned int *)malloc(0x10uLL);
*v6 = ++v5;
*((_QWORD *)v6 + 1) = 0LL;
if ( v3 )
*((_QWORD *)v4 + 1) = v6;
else
v3 = v6;
v4 = v6;
}
printf("\n Set of features: ");
if ( v3 )
{
v7 = v3;
do
{
printf("%d, ", *v7);
v7 = (unsigned int *)*((_QWORD *)v7 + 1);
}
while ( v7 );
}
}
v8 = calcJ((__int64)v3);
printf("\n J value of all features: %d", v8);
tset = (void *)selectOptimalFeature(v3, v13, v12);
printf("\n\n Optimal subset is: ");
v9 = (unsigned int *)tset;
if ( tset )
{
do
{
printf("%d, ", *v9);
v9 = (unsigned int *)*((_QWORD *)v9 + 1);
}
while ( v9 );
}
v10 = calcJ((__int64)tset);
printf("\n J of optimal features: %d \n\n", v10);
deleteList(tset);
deleteList(v3);
tset = 0LL;
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int *v3; // rbp
unsigned int *v4; // r12
int v5; // ebx
unsigned int *v6; // rax
unsigned int *v7; // rbx
unsigned int v8; // eax
unsigned int *v9; // rbx
unsigned int v10; // eax
int v12; // [rsp+8h] [rbp-30h]
int v13; // [rsp+Ch] [rbp-2Ch]

printf("\n\n===: Program for feature selection :===");
printf("\n\n M = ");
__isoc99_scanf();
printf(" m = ");
__isoc99_scanf();
if ( v13 <= 0 )
{
printf("\n Set of features: ");
v3 = 0LL;
}
else
{
v3 = (unsigned int *)malloc(0x10uLL);
*v3 = 1;
*((_QWORD *)v3 + 1) = 0LL;
v4 = v3;
v5 = 1;
while ( v13 != v5 )
{
v6 = (unsigned int *)malloc(0x10uLL);
*v6 = ++v5;
*((_QWORD *)v6 + 1) = 0LL;
if ( v3 )
*((_QWORD *)v4 + 1) = v6;
else
v3 = v6;
v4 = v6;
}
printf("\n Set of features: ");
if ( v3 )
{
v7 = v3;
do
{
printf("%d, ", *v7);
v7 = (unsigned int *)*((_QWORD *)v7 + 1);
}
while ( v7 );
}
}
v8 = func9((__int64)v3);
printf("\n J value of all features: %d", v8);
tset = (void *)func10(v3, v13, v12);
printf("\n\n Optimal subset is: ");
v9 = (unsigned int *)tset;
if ( tset )
{
do
{
printf("%d, ", *v9);
v9 = (unsigned int *)*((_QWORD *)v9 + 1);
}
while ( v9 );
}
v10 = func9((__int64)tset);
printf("\n J of optimal features: %d \n\n", v10);
func8(tset);
func8(v3);
tset = 0LL;
return 0;
}

original_code:
int main(){
 int M, m,
  cntr, i;
 list set = ((void *)0),
   temp, ptr;
 printf("\n\n===: Program for feature selection :===");
 printf("\n\n M = ");
   scanf("%d",&M);
   printf(" m = ");
   scanf("%d",&m);
   cntr = 1;
   for( i=0; i<M; i++){
    temp=(list)malloc(sizeof(struct _list));
    temp->num = i+1;
  temp->next = ((void *)0);
  if(set==((void *)0)){
   set = temp;
   ptr = temp;
  }else{
     ptr->next = temp;
     ptr = temp;
  }
   }
   ptr = set;
   printf("\n Set of features: ");
   while( ptr != ((void *)0) ){
    printf("%d, ", ptr->num);
    ptr = ptr->next;
   }
   printf("\n J value of all features: %d", calcJ(set, M));
   tset = selectOptimalFeature( set, M, m, m+1 );
   printf("\n\n Optimal subset is: ");
   ptr = tset;
   while( ptr != ((void *)0) ){
    printf("%d, ", ptr->num);
    ptr = ptr->next;
   }
   printf("\n J of optimal features: %d \n\n", calcJ( tset, m ));
   deleteList( tset );
   deleteList( set );
   tset = set = ((void *)0);
 return 0;
}

canonical_original_code:
int main(){
 int M; int m; int cntr; int i;
 struct _list *set = ((void *)0); struct _list *temp; struct _list *ptr;
 printf("\n\n===: Program for feature selection :===");
 printf("\n\n M = ");
   scanf("%d",&M);
   printf(" m = ");
   scanf("%d",&m);
   cntr = 1;
   for( i=0; i<M; i++){
    temp=(struct _list *)malloc(sizeof(struct _list));
    temp->num = i+1;
  temp->next = ((void *)0);
  if(set==((void *)0)){
   set = temp;
   ptr = temp;
  }else{
     ptr->next = temp;
     ptr = temp;
  }
   }
   ptr = set;
   printf("\n Set of features: ");
   while( ptr != ((void *)0) ){
    printf("%d, ", ptr->num);
    ptr = ptr->next;
   }
   printf("\n J value of all features: %d", calcJ(set, M));
   tset = selectOptimalFeature( set, M, m, m+1 );
   printf("\n\n Optimal subset is: ");
   ptr = tset;
   while( ptr != ((void *)0) ){
    printf("%d, ", ptr->num);
    ptr = ptr->next;
   }
   printf("\n J of optimal features: %d \n\n", calcJ( tset, m ));
   deleteList( tset );
   deleteList( set );
   tset = set = ((void *)0);
 return 0;
}

variable_types: M int

variable_types: m int

variable_types: cntr int


repo: gitaloha/eureka

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebx
_BYTE v5[16]; // [rsp+0h] [rbp-28h] BYREF
__int64 v6[3]; // [rsp+10h] [rbp-18h] BYREF

if ( (unsigned int)parseCapFile("test", v6, envp) == -1 )
{
v3 = -1;
puts("parse failed\r");
}
else
{
testPackList(v6[0], v6[1]);
statTotalFlow(v6, v5);
testTotalFlow(v5);
releaseTotalFlowList(v5);
releasePackets(v6);
v3 = 0;
}
return v3;
}

original_code:
int main()
{
 IP_PACKET_LIST list;
 TOTAL_FLOW_LIST totals;
 if(-1 == parseCapFile("test", &list))
 {
  printf("parse failed\r\n");
  return -1;
 }
 testPackList(list);
 statTotalFlow(&list, &totals);
 testTotalFlow(&totals);
 releaseTotalFlowList(&totals);
 releasePackets(&list);
 return 0;
}

canonical_original_code:
int main()
{
 struct ip_packet_list list;
 struct total_flow_list totals;
 if(-1 == parseCapFile("test", &list))
 {
  printf("parse failed\r\n");
  return -1;
 }
 testPackList(list);
 statTotalFlow(&list, &totals);
 testTotalFlow(&totals);
 releaseTotalFlowList(&totals);
 releasePackets(&list);
 return 0;
}

variable_types: struct ip_packet_list { struct ip_packet { struct timestamp { unsigned int sec; unsigned int microsec; } time; short direct; unsigned short ip_len; unsigned short offset; unsigned short type; unsigned char ip_version; union ip_addr { unsigned char ip4[4]; unsigned short ip6[-1]; } src_ip; union ip_addr dest_ip; struct ip_packet *next; struct tcp_packet { unsigned short src_port; unsigned short dest_port; unsigned int seq_num; unsigned int ack_num; unsigned char flag; } *pTcpPacket; } *pHead; struct ip_packet **pptail; }

variable_types: struct total_flow_list { struct total_flow { unsigned int time; unsigned long bytes; struct total_flow *next; } *pHead; struct total_flow **ppTail; }

user_defined_types: struct ip_packet_list { struct ip_packet *pHead; struct ip_packet **pptail; }

user_defined_types: struct total_flow_list { struct total_flow *pHead; struct total_flow **ppTail; }

user_defined_types: struct ip_packet { struct timestamp time; short direct; unsigned short ip_len; unsigned short offset; unsigned short type; unsigned char ip_version; union ip_addr src_ip; union ip_addr dest_ip; struct ip_packet *next; struct tcp_packet *pTcpPacket; }


isBigEnd

decompiled_code:
__int64 isBigEnd()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func0()
{
return 0LL;
}

original_code:
static int isBigEnd()
{
 short s = 0x1234;
 char *pc = (char *)&s;
 if(*pc == 0x12){
  return 1;
 }
 else{
  return 0;
 }
}

variable_types: s short

variable_types:
pc
char *


decompiled_code:
__int64 __fastcall hton16(unsigned int a1)
{
int v1; // edx
__int64 result; // rax
unsigned int v3; // ebx

HIWORD(v3) = HIWORD(a1);
v1 = isBigEnd();
result = a1;
LOWORD(v3) = __ROL2__(a1, 8);
if ( !v1 )
result = v3;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int a1)
{
int v1; // edx
__int64 result; // rax
unsigned int v3; // ebx

HIWORD(v3) = HIWORD(a1);
v1 = func0();
result = a1;
LOWORD(v3) = __ROL2__(a1, 8);
if ( !v1 )
result = v3;
return result;
}

original_code:
inline static ushort hton16( ushort us){
 if(isBigEnd())
 {
  return us;
 }
 return ((us & 0xFF00)>>8) | ((us & 0x00FF) << 8);
}

canonical_original_code:
inline static unsigned short hton16(unsigned short us){
 if(isBigEnd())
 {
  return us;
 }
 return ((us & 0xFF00)>>8) | ((us & 0x00FF) << 8);
}

variable_types:
us
unsigned short

return_type: unsigned short


decompiled_code:
__int64 __fastcall hton32(unsigned int a1)
{
int v1; // edx
__int64 result; // rax

v1 = isBigEnd();
result = a1;
if ( !v1 )
result = (a1 << 8) & 0xFF0000 | (a1 >> 8) & 0xFF00 | (a1 << 24) | HIBYTE(a1);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1)
{
int v1; // edx
__int64 result; // rax

v1 = func0();
result = a1;
if ( !v1 )
result = (a1 << 8) & 0xFF0000 | (a1 >> 8) & 0xFF00 | (a1 << 24) | HIBYTE(a1);
return result;
}

canonical_original_code:
inline static unsigned int hton32(unsigned int ui)
{
 if(isBigEnd())
 {
  return ui;
 }
 return ((ui & 0xFF000000) >> 24) |
  ((ui & 0x00FF0000) >> 8) |
  ((ui & 0x0000FF00) << 8) |
  ((ui & 0x000000FF) << 24);
}

variable_types:
ui
unsigned int

return_type: unsigned int


testHton

decompiled_code:
int testHton()
{
unsigned __int16 v0; // ax
unsigned int v1; // eax

v0 = hton16(0x3412u);
printf("%X\r\n", v0);
v1 = hton32(0x78563412u);
return printf("%x\n", v1);
}

canonical_decompiled_code:
int func6()
{
unsigned __int16 v0; // ax
unsigned int v1; // eax

v0 = func1(0x3412u);
printf("%X\r\n", v0);
v1 = func2(0x78563412u);
return printf("%x\n", v1);
}

original_code:
void testHton()
{
 ushort us = 0x3412;
 uint ui = 0x78563412;
 printf("%X\r\n", hton16(us));
 printf("%x\n", hton32(ui));
 return ;
}

canonical_original_code:
void testHton()
{
 unsigned short us = 0x3412;
 unsigned int ui = 0x78563412;
 printf("%X\r\n", hton16(us));
 printf("%x\n", hton32(ui));
 return ;
}


repo: gitslime/StockAnalyser

decompiled_code:
unsigned __int64 __fastcall MMA_SetParam(__int64 a1, float *a2)
{
int v2; // eax
unsigned int v3; // edx
float v4; // xmm0_4
unsigned __int64 result; // rax

if ( a1 != 2 )
_assert_fail("ulCnt == sizeof(MMA_PARAM_S)/sizeof(UINT32)", "method/mma.c", 0x17u, "MMA_SetParam");
if ( *a2 >= 9.223372e18 )
v2 = (int)(float)(*a2 - 9.223372e18);
else
v2 = (int)*a2;
v3 = v2;
g_stMmaParam = v2;
v4 = a2[1];
if ( v4 >= 9.223372e18 )
result = (unsigned int)(int)(float)(a2[1] - 9.223372e18) ^ 0x8000000000000000LL;
else
result = (unsigned int)(int)v4;
*(&g_stMmaParam + 1) = result;
if ( v3 >= (unsigned int)result )
_assert_fail("g_stMmaParam.ulMaLong > g_stMmaParam.ulMaShort", "method/mma.c", 0x1Cu, "MMA_SetParam");
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func0(__int64 a1, float *a2)
{
int v2; // eax
unsigned int v3; // edx
float v4; // xmm0_4
unsigned __int64 result; // rax

if ( a1 != 2 )
_assert_fail("ulCnt == sizeof(MMA_PARAM_S)/sizeof(UINT32)", "method/mma.c", 0x17u, "MMA_SetParam");
if ( *a2 >= 9.223372e18 )
v2 = (int)(float)(*a2 - 9.223372e18);
else
v2 = (int)*a2;
v3 = v2;
g_stMmaParam = v2;
v4 = a2[1];
if ( v4 >= 9.223372e18 )
result = (unsigned int)(int)(float)(a2[1] - 9.223372e18) ^ 0x8000000000000000LL;
else
result = (unsigned int)(int)v4;
*(&g_stMmaParam + 1) = result;
if ( v3 >= (unsigned int)result )
_assert_fail("g_stMmaParam.ulMaLong > g_stMmaParam.ulMaShort", "method/mma.c", 0x1Cu, "MMA_SetParam");
return result;
}

original_code:
VOID MMA_SetParam( ULONG ulCnt, FLOAT *afParam)
{
    ((void) sizeof ((ulCnt == sizeof(MMA_PARAM_S)/sizeof(UINT32)) ? 1 : 0), __extension__ ({ if (ulCnt == sizeof(MMA_PARAM_S)/sizeof(UINT32)) ; else __assert_fail ("ulCnt == sizeof(MMA_PARAM_S)/sizeof(UINT32)", "method/mma.c", 23, __extension__ __PRETTY_FUNCTION__); }));
    g_stMmaParam.ulMaShort = (ULONG)afParam[0];
    g_stMmaParam.ulMaLong = (ULONG)afParam[1];
    ((void) sizeof ((g_stMmaParam.ulMaLong > g_stMmaParam.ulMaShort) ? 1 : 0), __extension__ ({ if (g_stMmaParam.ulMaLong > g_stMmaParam.ulMaShort) ; else __assert_fail ("g_stMmaParam.ulMaLong > g_stMmaParam.ulMaShort", "method/mma.c", 28, __extension__ __PRETTY_FUNCTION__); }));
    return;
}

canonical_original_code:
void MMA_SetParam(unsigned long ulCnt, float *afParam)
{
    ((void) sizeof ((ulCnt == sizeof(MMA_PARAM_S)/sizeof(UINT32)) ? 1 : 0), __extension__ ({ if (ulCnt == sizeof(MMA_PARAM_S)/sizeof(UINT32)) ; else __assert_fail ("ulCnt == sizeof(MMA_PARAM_S)/sizeof(UINT32)", "method/mma.c", 23, __extension__ __PRETTY_FUNCTION__); }));
    g_stMmaParam.ulMaShort = (unsigned long)afParam[0];
    g_stMmaParam.ulMaLong = (unsigned long)afParam[1];
    ((void) sizeof ((g_stMmaParam.ulMaLong > g_stMmaParam.ulMaShort) ? 1 : 0), __extension__ ({ if (g_stMmaParam.ulMaLong > g_stMmaParam.ulMaShort) ; else __assert_fail ("g_stMmaParam.ulMaLong > g_stMmaParam.ulMaShort", "method/mma.c", 28, __extension__ __PRETTY_FUNCTION__); }));
    return;
}

variable_types:
ulCnt
unsigned long

variable_types:
afParam
float *


decompiled_code:
void MMA_Statistics()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code:
VOID MMA_Statistics( ULONG ulIndex, FILE_WHOLE_DATA_S *pstSettleData)
{
    return;
}

canonical_original_code:
void MMA_Statistics(unsigned long ulIndex, struct tagWholeData *pstSettleData)
{
    return;
}

variable_types:
ulIndex
unsigned long

variable_types: struct tagWholeData { char szComment[16]; unsigned int ulDate; unsigned int ulRsv; struct tagPrice { unsigned int ulBegin; unsigned int ulHigh; unsigned int ulLow; unsigned int ulEnd; unsigned int ulVol; unsigned int ulFlag; } stDailyPrice; struct tagPrice astMin30Price[8]; struct tagFactor { unsigned int ulFlag; float fMulti; float fAdder; } stFactor; unsigned int ulPad; } *

user_defined_types: struct tagWholeData { char szComment[16]; unsigned int ulDate; unsigned int ulRsv; struct tagPrice stDailyPrice; struct tagPrice astMin30Price[8]; struct tagFactor stFactor; unsigned int ulPad; }


decompiled_code:
__int64 __fastcall MMA_Choose(unsigned __int64 a1, __int64 a2, __int64 a3)
{
unsigned __int64 v4; // r13
unsigned int v5; // edx
__int64 v7; // r14
unsigned __int64 v8; // r12
unsigned __int64 v9; // rax
float v10; // xmm2_4
int v11; // er12
__int64 v12; // rdx
int v13; // ebx
float v14; // [rsp+8h] [rbp-30h]
float v15; // [rsp+Ch] [rbp-2Ch]

v4 = (unsigned int)*(&g_stMmaParam + 1);
v5 = 0;
if ( v4 <= a1 )
{
v7 = (unsigned int)g_stMmaParam;
v8 = GetMeanBackward((unsigned int)g_stMmaParam, a2, 0xFFFFFFFFLL);
v9 = GetMeanBackward((unsigned int)*(&g_stMmaParam + 1), a2, 0xFFFFFFFFLL);
v5 = 0;
if ( v8 <= v9 )
{
if ( (v9 & 0x8000000000000000LL) != 0LL )
v14 = (float)(int)(v9 & 1 | (v9 >> 1)) + (float)(int)(v9 & 1 | (v9 >> 1));
else
v14 = (float)(int)v9;
if ( (v8 & 0x8000000000000000LL) != 0LL )
v10 = (float)(int)(v8 & 1 | (v8 >> 1)) + (float)(int)(v8 & 1 | (v8 >> 1));
else
v10 = (float)(int)v8;
v5 = 0;
v15 = (float)((float)((float)((float)*(int *)(a2 + ((1 - v7) << 8) + 36) * (float)*(&g_stMmaParam + 1))
- (float)((float)*(int *)(a2 + ((1 - v4) << 8) + 36) * (float)g_stMmaParam))
+ (float)((float)((float)(v14 - v10) * (float)g_stMmaParam) * (float)*(&g_stMmaParam + 1)))
/ (float)(*(&g_stMmaParam + 1) - g_stMmaParam);
if ( v15 <= (float)((float)*(int *)(a2 + 36) * 1.099) )
{
v11 = GetMeanFdBackward((unsigned int)g_stMmaParam, a2, 0LL);
v13 = GetMeanFdBackward((unsigned int)*(&g_stMmaParam + 1), a2, v12);
*(_WORD *)a3 = 0;
*(_WORD *)(a3 + 2) = 14;
*(_WORD *)(a3 + 4) = RandomUlong(50LL, 60LL);
*(_WORD *)(a3 + 6) = 1;
*(float *)(a3 + 12) = (float)(v11 - v13);
*(float *)(a3 + 8) = fmaxf(v15, v14) / 1000.0;
v5 = 1;
}
}
}
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned __int64 a1, __int64 a2, __int64 a3)
{
unsigned __int64 v4; // r13
unsigned int v5; // edx
__int64 v7; // r14
unsigned __int64 v8; // r12
unsigned __int64 v9; // rax
float v10; // xmm2_4
int v11; // er12
__int64 v12; // rdx
int v13; // ebx
float v14; // [rsp+8h] [rbp-30h]
float v15; // [rsp+Ch] [rbp-2Ch]

v4 = (unsigned int)*(&g_stMmaParam + 1);
v5 = 0;
if ( v4 <= a1 )
{
v7 = (unsigned int)g_stMmaParam;
v8 = GetMeanBackward((unsigned int)g_stMmaParam, a2, 0xFFFFFFFFLL);
v9 = GetMeanBackward((unsigned int)*(&g_stMmaParam + 1), a2, 0xFFFFFFFFLL);
v5 = 0;
if ( v8 <= v9 )
{
if ( (v9 & 0x8000000000000000LL) != 0LL )
v14 = (float)(int)(v9 & 1 | (v9 >> 1)) + (float)(int)(v9 & 1 | (v9 >> 1));
else
v14 = (float)(int)v9;
if ( (v8 & 0x8000000000000000LL) != 0LL )
v10 = (float)(int)(v8 & 1 | (v8 >> 1)) + (float)(int)(v8 & 1 | (v8 >> 1));
else
v10 = (float)(int)v8;
v5 = 0;
v15 = (float)((float)((float)((float)*(int *)(a2 + ((1 - v7) << 8) + 36) * (float)*(&g_stMmaParam + 1))
- (float)((float)*(int *)(a2 + ((1 - v4) << 8) + 36) * (float)g_stMmaParam))
+ (float)((float)((float)(v14 - v10) * (float)g_stMmaParam) * (float)*(&g_stMmaParam + 1)))
/ (float)(*(&g_stMmaParam + 1) - g_stMmaParam);
if ( v15 <= (float)((float)*(int *)(a2 + 36) * 1.099) )
{
v11 = GetMeanFdBackward((unsigned int)g_stMmaParam, a2, 0LL);
v13 = GetMeanFdBackward((unsigned int)*(&g_stMmaParam + 1), a2, v12);
*(_WORD *)a3 = 0;
*(_WORD *)(a3 + 2) = 14;
*(_WORD *)(a3 + 4) = RandomUlong(50LL, 60LL);
*(_WORD *)(a3 + 6) = 1;
*(float *)(a3 + 12) = (float)(v11 - v13);
*(float *)(a3 + 8) = fmaxf(v15, v14) / 1000.0;
v5 = 1;
}
}
}
return v5;
}

original_code:
BOOL_T MMA_Choose( ULONG ulIndex, FILE_WHOLE_DATA_S *pstCurrData, CHOOSE_PRE_DEAL_S *pstDealInfo)
{
    ULONG ulCurrMaShort, ulCurrMaLong;
    FLOAT fThreshPrice;
    INT iMafdShort, iMafdLong;
    FILE_WHOLE_DATA_S *pstChoose=pstCurrData;
    FILE_WHOLE_DATA_S *pstPrevShort=pstChoose-(g_stMmaParam.ulMaShort)+1;
    FILE_WHOLE_DATA_S *pstPrevLong =pstChoose-(g_stMmaParam.ulMaLong)+1;
    if (ulIndex < (g_stMmaParam.ulMaLong)) return (0);
    ulCurrMaShort = GetMeanBackward((g_stMmaParam.ulMaShort), pstChoose, (0xFFFFFFFF));
    ulCurrMaLong = GetMeanBackward((g_stMmaParam.ulMaLong), pstChoose, (0xFFFFFFFF));
    if (ulCurrMaShort > ulCurrMaLong) return (0);
    fThreshPrice = (((((FLOAT)(ulCurrMaLong)) - ((FLOAT)(ulCurrMaShort))) * (g_stMmaParam.ulMaShort) * (g_stMmaParam.ulMaLong)) + ((((FLOAT)(pstPrevShort->stDailyPrice.ulEnd)) * (g_stMmaParam.ulMaLong)) - (((FLOAT)(pstPrevLong->stDailyPrice.ulEnd)) * (g_stMmaParam.ulMaShort)))) / ((g_stMmaParam.ulMaLong) - (g_stMmaParam.ulMaShort));
    if (fThreshPrice > (pstChoose->stDailyPrice.ulEnd * (1+(0.099F)))) return (0);
    iMafdShort = GetMeanFdBackward((g_stMmaParam.ulMaShort),pstChoose);
    iMafdLong = GetMeanFdBackward((g_stMmaParam.ulMaLong), pstChoose);
    pstDealInfo->bIsSell = (0);
    pstDealInfo->usDealHour = (14);
    pstDealInfo->usDealMin = (USHORT)RandomUlong(50,60);
    pstDealInfo->bIsHigher = (1);
    pstDealInfo->fWeight = (FLOAT)(iMafdShort - iMafdLong);
    pstDealInfo->fThresholdPrice = (((FLOAT)((((fThreshPrice) > (ulCurrMaLong)) ? (fThreshPrice) : (ulCurrMaLong))))/(1000));
    return (1);
}

canonical_original_code:
unsigned short MMA_Choose(unsigned long ulIndex, struct tagWholeData *pstCurrData, struct tagPreDealInfo *pstDealInfo)
{
    unsigned long ulCurrMaShort; unsigned long ulCurrMaLong;
    float fThreshPrice;
    int iMafdShort; int iMafdLong;
    struct tagWholeData *pstChoose = pstCurrData;
    struct tagWholeData *pstPrevShort = pstChoose-(g_stMmaParam.ulMaShort)+1;
    struct tagWholeData *pstPrevLong = pstChoose-(g_stMmaParam.ulMaLong)+1;
    if (ulIndex < (g_stMmaParam.ulMaLong)) return (0);
    ulCurrMaShort = GetMeanBackward((g_stMmaParam.ulMaShort), pstChoose, (0xFFFFFFFF));
    ulCurrMaLong = GetMeanBackward((g_stMmaParam.ulMaLong), pstChoose, (0xFFFFFFFF));
    if (ulCurrMaShort > ulCurrMaLong) return (0);
    fThreshPrice = (((((FLOAT)(ulCurrMaLong)) - ((FLOAT)(ulCurrMaShort))) * (g_stMmaParam.ulMaShort) * (g_stMmaParam.ulMaLong)) + ((((FLOAT)(pstPrevShort->stDailyPrice.ulEnd)) * (g_stMmaParam.ulMaLong)) - (((FLOAT)(pstPrevLong->stDailyPrice.ulEnd)) * (g_stMmaParam.ulMaShort)))) / ((g_stMmaParam.ulMaLong) - (g_stMmaParam.ulMaShort));
    if (fThreshPrice > (pstChoose->stDailyPrice.ulEnd * (1+(0.099F)))) return (0);
    iMafdShort = GetMeanFdBackward((g_stMmaParam.ulMaShort),pstChoose);
    iMafdLong = GetMeanFdBackward((g_stMmaParam.ulMaLong), pstChoose);
    pstDealInfo->bIsSell = (0);
    pstDealInfo->usDealHour = (14);
    pstDealInfo->usDealMin = (unsigned short)RandomUlong(50,60);
    pstDealInfo->bIsHigher = (1);
    pstDealInfo->fWeight = (FLOAT)(iMafdShort - iMafdLong);
    pstDealInfo->fThresholdPrice = (((FLOAT)((((fThreshPrice) > (ulCurrMaLong)) ? (fThreshPrice) : (ulCurrMaLong))))/(1000));
    return (1);
}

variable_types: struct tagPreDealInfo { unsigned short bIsSell; unsigned short usDealHour; unsigned short usDealMin; unsigned short bIsHigher; float fThresholdPrice; float fWeight; } *

variable_types:
ulCurrMaShort
unsigned long

variable_types:
ulCurrMaLong
unsigned long

variable_types: fThreshPrice float

variable_types: iMafdShort int

variable_types: iMafdLong int

user_defined_types: struct tagPrice { unsigned int ulBegin; unsigned int ulHigh; unsigned int ulLow; unsigned int ulEnd; unsigned int ulVol; unsigned int ulFlag; }

user_defined_types: struct tagFactor { unsigned int ulFlag; float fMulti; float fAdder; }


decompiled_code:
__int64 __fastcall MMA_SortWishList(__int64 a1)
{
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
return a1;
}

original_code:
ULONG MMA_SortWishList( ULONG ulWishCnt, SIM_STOCK_DATA_S *pstAllData, SIM_WISH_LIST_S *astWishList)
{
    return ulWishCnt;
}

canonical_original_code:
unsigned long MMA_SortWishList(unsigned long ulWishCnt, struct tagStockData *pstAllData, struct tagWishList *astWishList)
{
    return ulWishCnt;
}

variable_types:
ulWishCnt
unsigned long

variable_types: struct tagStockData { unsigned int ulStockCode; unsigned int ulEntryCnt; unsigned short bIsHold; struct tagWholeData { char szComment[16]; unsigned int ulDate; unsigned int ulRsv; struct tagPrice { unsigned int ulBegin; unsigned int ulHigh; unsigned int ulLow; unsigned int ulEnd; unsigned int ulVol; unsigned int ulFlag; } stDailyPrice; struct tagPrice astMin30Price[8]; struct tagFactor { unsigned int ulFlag; float fMulti; float fAdder; } stFactor; unsigned int ulPad; } *pstCurrData; struct tagWholeData *astWholeData; } *

variable_types: struct tagWishList { unsigned int ulCode; unsigned int ulIndex; unsigned int ulWishPrice; float fWeight; } *

return_type: unsigned long

user_defined_types: struct tagStockData { unsigned int ulStockCode; unsigned int ulEntryCnt; unsigned short bIsHold; struct tagWholeData *pstCurrData; struct tagWholeData *astWholeData; }


decompiled_code:
__int64 MMA_GetGainPrice()
{
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func4()
{
return 0xFFFFFFFFLL;
}

original_code:
ULONG MMA_GetGainPrice( FILE_WHOLE_DATA_S *pstCurrData, STOCK_CTRL_S *pstStockCtrl)
{
    return (0xFFFFFFFF);
}

canonical_original_code:
unsigned long MMA_GetGainPrice(struct tagWholeData *pstCurrData, struct tagStockCtrl *pstStockCtrl)
{
    return (0xFFFFFFFF);
}

variable_types: struct tagStockCtrl { unsigned int ulGainPrice; unsigned int ulLossPrice; unsigned int ulBuyDate; unsigned int ulBuyPrice; unsigned int ulSellDate; unsigned int ulSellPrice; float fContext; } *


decompiled_code:
__int64 __fastcall MMA_GetLossPrice(__int64 a1)
{
unsigned __int64 v1; // rbp
bool v2; // cf
__int64 result; // rax

v1 = GetMean((unsigned int)g_stMmaParam, a1, 0xFFFFFFFFLL);
v2 = v1 < GetMean((unsigned int)*(&g_stMmaParam + 1), a1, 0xFFFFFFFFLL);
result = 0xFFFFFFFFLL;
if ( !v2 )
result = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
unsigned __int64 v1; // rbp
bool v2; // cf
__int64 result; // rax

v1 = GetMean((unsigned int)g_stMmaParam, a1, 0xFFFFFFFFLL);
v2 = v1 < GetMean((unsigned int)*(&g_stMmaParam + 1), a1, 0xFFFFFFFFLL);
result = 0xFFFFFFFFLL;
if ( !v2 )
result = 0LL;
return result;
}

original_code:
ULONG MMA_GetLossPrice( FILE_WHOLE_DATA_S *pstCurrData, STOCK_CTRL_S *pstStockCtrl)
{
    ULONG ulCurrMaShort, ulCurrMaLong;
    FLOAT fThreshPrice;
    FILE_WHOLE_DATA_S *pstPrevShort=pstCurrData-(g_stMmaParam.ulMaShort)+1;
    FILE_WHOLE_DATA_S *pstPrevLong =pstCurrData-(g_stMmaParam.ulMaLong)+1;
    ulCurrMaShort = GetMean((g_stMmaParam.ulMaShort), pstCurrData, (0xFFFFFFFF));
    ulCurrMaLong = GetMean((g_stMmaParam.ulMaLong), pstCurrData, (0xFFFFFFFF));
    return (ulCurrMaShort < ulCurrMaLong) ? (0xFFFFFFFF) : 0;
}

canonical_original_code:
unsigned long MMA_GetLossPrice(struct tagWholeData *pstCurrData, struct tagStockCtrl *pstStockCtrl)
{
    unsigned long ulCurrMaShort; unsigned long ulCurrMaLong;
    float fThreshPrice;
    struct tagWholeData *pstPrevShort = pstCurrData-(g_stMmaParam.ulMaShort)+1;
    struct tagWholeData *pstPrevLong = pstCurrData-(g_stMmaParam.ulMaLong)+1;
    ulCurrMaShort = GetMean((g_stMmaParam.ulMaShort), pstCurrData, (0xFFFFFFFF));
    ulCurrMaLong = GetMean((g_stMmaParam.ulMaLong), pstCurrData, (0xFFFFFFFF));
    return (ulCurrMaShort < ulCurrMaLong) ? (0xFFFFFFFF) : 0;
}

user_defined_types: struct tagStockCtrl { unsigned int ulGainPrice; unsigned int ulLossPrice; unsigned int ulBuyDate; unsigned int ulBuyPrice; unsigned int ulSellDate; unsigned int ulSellPrice; float fContext; }


decompiled_code:
__int64 __fastcall MMA_GetBuyPrice(_DWORD *a1, unsigned __int64 a2)
{
__int64 result; // rax
unsigned int v3; // edx
float v4[7]; // [rsp+Ch] [rbp-1Ch] BYREF

GetTotalRise(1LL, a1, 4LL, v4);
result = 0xFFFFFFFFLL;
if ( v4[0] <= 0.098999999 )
{
v3 = a1[9];
if ( a1[6] != v3 || a1[7] != a1[8] )
{
result = v3;
if ( v3 < a2 )
result = 0xFFFFFFFFLL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(_DWORD *a1, unsigned __int64 a2)
{
__int64 result; // rax
unsigned int v3; // edx
float v4[7]; // [rsp+Ch] [rbp-1Ch] BYREF

GetTotalRise(1LL, a1, 4LL, v4);
result = 0xFFFFFFFFLL;
if ( v4[0] <= 0.098999999 )
{
v3 = a1[9];
if ( a1[6] != v3 || a1[7] != a1[8] )
{
result = v3;
if ( v3 < a2 )
result = 0xFFFFFFFFLL;
}
}
return result;
}

original_code:
ULONG MMA_GetBuyPrice( FILE_WHOLE_DATA_S *pstCurrData, ULONG ulWishPrice)
{
    FLOAT fRise;
    (VOID)GetTotalRise(1,pstCurrData,(0x04UL),&fRise);
    if (fRise > (0.099F)) return (0xFFFFFFFF);
    if ((pstCurrData->stDailyPrice.ulBegin == pstCurrData->stDailyPrice.ulEnd) &&
        (pstCurrData->stDailyPrice.ulHigh == pstCurrData->stDailyPrice.ulLow)) return (0xFFFFFFFF);
    if (pstCurrData->stDailyPrice.ulEnd < ulWishPrice) return (0xFFFFFFFF);
    return pstCurrData->stDailyPrice.ulEnd;
}

canonical_original_code:
unsigned long MMA_GetBuyPrice(struct tagWholeData *pstCurrData, unsigned long ulWishPrice)
{
    float fRise;
    (void)GetTotalRise(1,pstCurrData,(0x04UL),&fRise);
    if (fRise > (0.099F)) return (0xFFFFFFFF);
    if ((pstCurrData->stDailyPrice.ulBegin == pstCurrData->stDailyPrice.ulEnd) &&
        (pstCurrData->stDailyPrice.ulHigh == pstCurrData->stDailyPrice.ulLow)) return (0xFFFFFFFF);
    if (pstCurrData->stDailyPrice.ulEnd < ulWishPrice) return (0xFFFFFFFF);
    return pstCurrData->stDailyPrice.ulEnd;
}

variable_types:
ulWishPrice
unsigned long

variable_types: fRise float


decompiled_code:
__int64 MMA_GetSellPrice()
{
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func7()
{
return 0xFFFFFFFFLL;
}

original_code:
ULONG MMA_GetSellPrice( FILE_WHOLE_DATA_S *pstCurrData, STOCK_CTRL_S *pstStockCtrl)
{
    return (0xFFFFFFFF);
}

canonical_original_code:
unsigned long MMA_GetSellPrice(struct tagWholeData *pstCurrData, struct tagStockCtrl *pstStockCtrl)
{
    return (0xFFFFFFFF);
}


decompiled_code:
void __fastcall OMA_SetParam(__int64 a1, float *a2)
{
int v2; // eax
unsigned int v3; // edx
float v4; // xmm0_4
float v5; // xmm1_4
float v6; // xmm2_4
int v7; // eax

if ( a1 )
{
if ( a1 != 4 )
_assert_fail("ulCnt == sizeof(OMA_PARAM_S)/sizeof(UINT32)", "method/oma.c", 0x24u, "OMA_SetParam");
if ( *a2 >= 9.223372e18 )
v2 = (int)(float)(*a2 - 9.223372e18);
else
v2 = (int)*a2;
v3 = v2;
g_stOmaParam = v2;
v4 = a2[1];
dword_574 = LODWORD(v4);
v5 = a2[2];
dword_578 = LODWORD(v5);
v6 = a2[3];
if ( v6 >= 9.223372e18 )
v7 = (int)(float)(a2[3] - 9.223372e18);
else
v7 = (int)v6;
dword_57C = v7;
if ( v3 <= 1 )
_assert_fail("OMA_PARAM_MA > 1", "method/oma.c", 0x2Bu, "OMA_SetParam");
if ( v4 > 0.0 )
_assert_fail("OMA_PARAM_NO <= 0", "method/oma.c", 0x2Cu, "OMA_SetParam");
if ( v5 <= v4 )
_assert_fail("OMA_PARAM_PO > OMA_PARAM_NO", "method/oma.c", 0x2Du, "OMA_SetParam");
if ( !v7 )
_assert_fail("OMA_PARAM_CD > 0", "method/oma.c", 0x2Eu, "OMA_SetParam");
}
else
{
g_stOmaParam = 24;
dword_574 = -1103605268;
dword_578 = -1130113270;
dword_57C = 2;
}
}

canonical_decompiled_code:
void __fastcall func0(__int64 a1, float *a2)
{
int v2; // eax
unsigned int v3; // edx
float v4; // xmm0_4
float v5; // xmm1_4
float v6; // xmm2_4
int v7; // eax

if ( a1 )
{
if ( a1 != 4 )
_assert_fail("ulCnt == sizeof(OMA_PARAM_S)/sizeof(UINT32)", "method/oma.c", 0x24u, "OMA_SetParam");
if ( *a2 >= 9.223372e18 )
v2 = (int)(float)(*a2 - 9.223372e18);
else
v2 = (int)*a2;
v3 = v2;
g_stOmaParam = v2;
v4 = a2[1];
dword_574 = LODWORD(v4);
v5 = a2[2];
dword_578 = LODWORD(v5);
v6 = a2[3];
if ( v6 >= 9.223372e18 )
v7 = (int)(float)(a2[3] - 9.223372e18);
else
v7 = (int)v6;
dword_57C = v7;
if ( v3 <= 1 )
_assert_fail("OMA_PARAM_MA > 1", "method/oma.c", 0x2Bu, "OMA_SetParam");
if ( v4 > 0.0 )
_assert_fail("OMA_PARAM_NO <= 0", "method/oma.c", 0x2Cu, "OMA_SetParam");
if ( v5 <= v4 )
_assert_fail("OMA_PARAM_PO > OMA_PARAM_NO", "method/oma.c", 0x2Du, "OMA_SetParam");
if ( !v7 )
_assert_fail("OMA_PARAM_CD > 0", "method/oma.c", 0x2Eu, "OMA_SetParam");
}
else
{
g_stOmaParam = 24;
dword_574 = -1103605268;
dword_578 = -1130113270;
dword_57C = 2;
}
}

original_code:
VOID OMA_SetParam( ULONG ulCnt, FLOAT *afParam)
{
    if (0==ulCnt) {
        g_stOmaParam.ulMaDays = (24);
        g_stOmaParam.fNoThreshold = (-0.18F);
        g_stOmaParam.fPoThreshold = (-0.02F);
        g_stOmaParam.ulChkSellDays = (2);
        return;
    }
    ((void) sizeof ((ulCnt == sizeof(OMA_PARAM_S)/sizeof(UINT32)) ? 1 : 0), __extension__ ({ if (ulCnt == sizeof(OMA_PARAM_S)/sizeof(UINT32)) ; else __assert_fail ("ulCnt == sizeof(OMA_PARAM_S)/sizeof(UINT32)", "method/oma.c", 36, __extension__ __PRETTY_FUNCTION__); }));
    g_stOmaParam.ulMaDays = (ULONG)afParam[0];
    g_stOmaParam.fNoThreshold = afParam[1];
    g_stOmaParam.fPoThreshold = afParam[2];
    g_stOmaParam.ulChkSellDays = (ULONG)afParam[3];
    ((void) sizeof (((g_stOmaParam.ulMaDays) > 1) ? 1 : 0), __extension__ ({ if ((g_stOmaParam.ulMaDays) > 1) ; else __assert_fail ("OMA_PARAM_MA > 1", "method/oma.c", 43, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof (((g_stOmaParam.fNoThreshold) <= 0) ? 1 : 0), __extension__ ({ if ((g_stOmaParam.fNoThreshold) <= 0) ; else __assert_fail ("OMA_PARAM_NO <= 0", "method/oma.c", 44, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof (((g_stOmaParam.fPoThreshold) > (g_stOmaParam.fNoThreshold)) ? 1 : 0), __extension__ ({ if ((g_stOmaParam.fPoThreshold) > (g_stOmaParam.fNoThreshold)) ; else __assert_fail ("OMA_PARAM_PO > OMA_PARAM_NO", "method/oma.c", 45, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof (((g_stOmaParam.ulChkSellDays) > 0) ? 1 : 0), __extension__ ({ if ((g_stOmaParam.ulChkSellDays) > 0) ; else __assert_fail ("OMA_PARAM_CD > 0", "method/oma.c", 46, __extension__ __PRETTY_FUNCTION__); }));
    return;
}

canonical_original_code:
void OMA_SetParam(unsigned long ulCnt, float *afParam)
{
    if (0==ulCnt) {
        g_stOmaParam.ulMaDays = (24);
        g_stOmaParam.fNoThreshold = (-0.18F);
        g_stOmaParam.fPoThreshold = (-0.02F);
        g_stOmaParam.ulChkSellDays = (2);
        return;
    }
    ((void) sizeof ((ulCnt == sizeof(OMA_PARAM_S)/sizeof(UINT32)) ? 1 : 0), __extension__ ({ if (ulCnt == sizeof(OMA_PARAM_S)/sizeof(UINT32)) ; else __assert_fail ("ulCnt == sizeof(OMA_PARAM_S)/sizeof(UINT32)", "method/oma.c", 36, __extension__ __PRETTY_FUNCTION__); }));
    g_stOmaParam.ulMaDays = (unsigned long)afParam[0];
    g_stOmaParam.fNoThreshold = afParam[1];
    g_stOmaParam.fPoThreshold = afParam[2];
    g_stOmaParam.ulChkSellDays = (unsigned long)afParam[3];
    ((void) sizeof (((g_stOmaParam.ulMaDays) > 1) ? 1 : 0), __extension__ ({ if ((g_stOmaParam.ulMaDays) > 1) ; else __assert_fail ("OMA_PARAM_MA > 1", "method/oma.c", 43, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof (((g_stOmaParam.fNoThreshold) <= 0) ? 1 : 0), __extension__ ({ if ((g_stOmaParam.fNoThreshold) <= 0) ; else __assert_fail ("OMA_PARAM_NO <= 0", "method/oma.c", 44, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof (((g_stOmaParam.fPoThreshold) > (g_stOmaParam.fNoThreshold)) ? 1 : 0), __extension__ ({ if ((g_stOmaParam.fPoThreshold) > (g_stOmaParam.fNoThreshold)) ; else __assert_fail ("OMA_PARAM_PO > OMA_PARAM_NO", "method/oma.c", 45, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof (((g_stOmaParam.ulChkSellDays) > 0) ? 1 : 0), __extension__ ({ if ((g_stOmaParam.ulChkSellDays) > 0) ; else __assert_fail ("OMA_PARAM_CD > 0", "method/oma.c", 46, __extension__ __PRETTY_FUNCTION__); }));
    return;
}


decompiled_code:
void __fastcall OMA_Statistics(unsigned __int64 a1, __int64 a2)
{
__int64 v2; // rax
float v3; // xmm1_4

if ( a1 > 0x17 )
{
v2 = GetMean(24LL, a2, 0xFFFFFFFFLL);
if ( v2 < 0 )
v3 = (float)(v2 & 1 | (unsigned int)((unsigned __int64)v2 >> 1))
+ (float)(v2 & 1 | (unsigned int)((unsigned __int64)v2 >> 1));
else
v3 = (float)(int)v2;
printf(
"%lu,%lu,%f\n",
*(unsigned int *)(a2 + 16),
*(unsigned int *)(a2 + 36),
(float)((float)((float)*(int *)(a2 + 36) / v3) - 1.0));
}
}

canonical_decompiled_code:
void __fastcall func1(unsigned __int64 a1, __int64 a2)
{
__int64 v2; // rax
float v3; // xmm1_4

if ( a1 > 0x17 )
{
v2 = GetMean(24LL, a2, 0xFFFFFFFFLL);
if ( v2 < 0 )
v3 = (float)(v2 & 1 | (unsigned int)((unsigned __int64)v2 >> 1))
+ (float)(v2 & 1 | (unsigned int)((unsigned __int64)v2 >> 1));
else
v3 = (float)(int)v2;
printf(
"%lu,%lu,%f\n",
*(unsigned int *)(a2 + 16),
*(unsigned int *)(a2 + 36),
(float)((float)((float)*(int *)(a2 + 36) / v3) - 1.0));
}
}

original_code:
VOID OMA_Statistics( ULONG ulIndex, FILE_WHOLE_DATA_S *pstCurrData)
{
    ULONG ulMa;
    if (ulIndex < (24)) return;
    ulMa=GetMean((24),pstCurrData,(0xFFFFFFFF));
    printf("%lu,%lu,%f\n",pstCurrData->ulDate, pstCurrData->stDailyPrice.ulEnd,
                        pstCurrData->stDailyPrice.ulEnd/(FLOAT)ulMa-1);
    return;
}

canonical_original_code:
void OMA_Statistics(unsigned long ulIndex, struct tagWholeData *pstCurrData)
{
    unsigned long ulMa;
    if (ulIndex < (24)) return;
    ulMa=GetMean((24),pstCurrData,(0xFFFFFFFF));
    printf("%lu,%lu,%f\n",pstCurrData->ulDate, pstCurrData->stDailyPrice.ulEnd,
                        pstCurrData->stDailyPrice.ulEnd/(float)ulMa-1);
    return;
}

variable_types:
ulMa
unsigned long


decompiled_code:
__int64 __fastcall OMA_Choose(unsigned __int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax
__int64 v5; // rax
__int64 v6; // rdx
__int64 v7; // rax
float v8; // xmm1_4
__int64 v9; // r12
__int64 v10; // rax
float v11; // xmm1_4
float v12; // xmm0_4
float v13; // xmm2_4
float v14; // xmm0_4
__int64 v15; // rax
float v16; // xmm0_4
float v17; // [rsp+0h] [rbp-1Ch]

result = 0LL;
if ( (unsigned int)g_stOmaParam <= a1 )
{
if ( g_stOmaParam )
{
v5 = a2;
v6 = 0LL;
while ( *(_DWORD *)(v5 + 240) != -2004318072 || *(float *)(v5 + 244) <= 1.0 )
{
++v6;
v5 -= 256LL;
if ( g_stOmaParam == v6 )
goto LABEL_8;
}
result = 0LL;
}
else
{
LABEL_8:
v7 = GetMean((unsigned int)g_stOmaParam, a2, 0xFFFFFFFFLL);
if ( v7 < 0 )
v8 = (float)(v7 & 1 | (unsigned int)((unsigned __int64)v7 >> 1))
+ (float)(v7 & 1 | (unsigned int)((unsigned __int64)v7 >> 1));
else
v8 = (float)(int)v7;
result = 0LL;
if ( (float)((float)((float)*(int *)(a2 + 36) / v8) - 1.0) < *(float *)&dword_574 )
{
v9 = GetMean((unsigned int)(g_stOmaParam - 1), a2 - 256, 0xFFFFFFFFLL);
v10 = GetMean((unsigned int)(g_stOmaParam - 1), a2, v9);
v11 = (float)*(int *)(a2 + 36);
v12 = v10 < 0 ? (float)(v10 & 1 | (unsigned int)((unsigned __int64)v10 >> 1))
+ (float)(v10 & 1 | (unsigned int)((unsigned __int64)v10 >> 1)) : (float)(int)v10;
v13 = v9 < 0 ? (float)(v9 & 1 | (unsigned int)((unsigned __int64)v9 >> 1))
+ (float)(v9 & 1 | (unsigned int)((unsigned __int64)v9 >> 1)) : (float)(int)v9;
v14 = (float)(v12 / v13) * v11;
result = 0LL;
if ( (float)((float)(v14 / v11) - 1.0) <= 0.098999999 )
{
v17 = fmaxf(v11, v14);
*(_WORD *)a3 = 0;
*(_WORD *)(a3 + 2) = 14;
*(_WORD *)(a3 + 4) = RandomUlong(50LL, 60LL);
*(_WORD *)(a3 + 6) = 1;
v15 = RandomUlong(0LL, 100LL);
if ( v15 < 0 )
v16 = (float)(v15 & 1 | (unsigned int)((unsigned __int64)v15 >> 1))
+ (float)(v15 & 1 | (unsigned int)((unsigned __int64)v15 >> 1));
else
v16 = (float)(int)v15;
*(float *)(a3 + 12) = v16;
*(float *)(a3 + 8) = v17 / 1000.0;
result = 1LL;
}
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned __int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax
__int64 v5; // rax
__int64 v6; // rdx
__int64 v7; // rax
float v8; // xmm1_4
__int64 v9; // r12
__int64 v10; // rax
float v11; // xmm1_4
float v12; // xmm0_4
float v13; // xmm2_4
float v14; // xmm0_4
__int64 v15; // rax
float v16; // xmm0_4
float v17; // [rsp+0h] [rbp-1Ch]

result = 0LL;
if ( (unsigned int)g_stOmaParam <= a1 )
{
if ( g_stOmaParam )
{
v5 = a2;
v6 = 0LL;
while ( *(_DWORD *)(v5 + 240) != -2004318072 || *(float *)(v5 + 244) <= 1.0 )
{
++v6;
v5 -= 256LL;
if ( g_stOmaParam == v6 )
goto LABEL_8;
}
result = 0LL;
}
else
{
LABEL_8:
v7 = GetMean((unsigned int)g_stOmaParam, a2, 0xFFFFFFFFLL);
if ( v7 < 0 )
v8 = (float)(v7 & 1 | (unsigned int)((unsigned __int64)v7 >> 1))
+ (float)(v7 & 1 | (unsigned int)((unsigned __int64)v7 >> 1));
else
v8 = (float)(int)v7;
result = 0LL;
if ( (float)((float)((float)*(int *)(a2 + 36) / v8) - 1.0) < *(float *)&dword_574 )
{
v9 = GetMean((unsigned int)(g_stOmaParam - 1), a2 - 256, 0xFFFFFFFFLL);
v10 = GetMean((unsigned int)(g_stOmaParam - 1), a2, v9);
v11 = (float)*(int *)(a2 + 36);
v12 = v10 < 0 ? (float)(v10 & 1 | (unsigned int)((unsigned __int64)v10 >> 1))
+ (float)(v10 & 1 | (unsigned int)((unsigned __int64)v10 >> 1)) : (float)(int)v10;
v13 = v9 < 0 ? (float)(v9 & 1 | (unsigned int)((unsigned __int64)v9 >> 1))
+ (float)(v9 & 1 | (unsigned int)((unsigned __int64)v9 >> 1)) : (float)(int)v9;
v14 = (float)(v12 / v13) * v11;
result = 0LL;
if ( (float)((float)(v14 / v11) - 1.0) <= 0.098999999 )
{
v17 = fmaxf(v11, v14);
*(_WORD *)a3 = 0;
*(_WORD *)(a3 + 2) = 14;
*(_WORD *)(a3 + 4) = RandomUlong(50LL, 60LL);
*(_WORD *)(a3 + 6) = 1;
v15 = RandomUlong(0LL, 100LL);
if ( v15 < 0 )
v16 = (float)(v15 & 1 | (unsigned int)((unsigned __int64)v15 >> 1))
+ (float)(v15 & 1 | (unsigned int)((unsigned __int64)v15 >> 1));
else
v16 = (float)(int)v15;
*(float *)(a3 + 12) = v16;
*(float *)(a3 + 8) = v17 / 1000.0;
result = 1LL;
}
}
}
}
return result;
}

original_code:
BOOL_T OMA_Choose( ULONG ulIndex, FILE_WHOLE_DATA_S *pstCurrData, CHOOSE_PRE_DEAL_S *pstDealInfo)
{
    ULONG ulMa;
    ULONG ulPrevShorterMa, ulCurrShorterMa;
    FLOAT fCurrOffset;
    FLOAT fThresholdPrice;
    FLOAT fCurrRise, fExpectRise;
    ULONG i;
    ULONG ulStartPrice;
    FILE_WHOLE_DATA_S *pstMeanData;
    if (ulIndex < (g_stOmaParam.ulMaDays)) return (0);
    for (i=0,pstMeanData=pstCurrData;i<(g_stOmaParam.ulMaDays);i++,pstMeanData--) {
        if ((pstMeanData->stFactor.ulFlag == 0x88888888) &&
            (pstMeanData->stFactor.fMulti > 1))
           return (0);
    }
    pstMeanData=pstCurrData-(g_stOmaParam.ulMaDays)+1;
    ulStartPrice = pstMeanData->stDailyPrice.ulEnd;
    ulMa = GetMean((g_stOmaParam.ulMaDays), pstCurrData, (0xFFFFFFFF));
    fCurrOffset = ((FLOAT)pstCurrData->stDailyPrice.ulEnd/ulMa) - 1;
    if (fCurrOffset >= (g_stOmaParam.fNoThreshold)) return (0);
    ulPrevShorterMa = GetMean((g_stOmaParam.ulMaDays)-1,pstCurrData-1,(0xFFFFFFFF));
    ulCurrShorterMa = GetMean((g_stOmaParam.ulMaDays)-1,pstCurrData,ulPrevShorterMa);
    fThresholdPrice = (FLOAT)ulCurrShorterMa/ulPrevShorterMa*pstCurrData->stDailyPrice.ulEnd;
    fExpectRise = fThresholdPrice/pstCurrData->stDailyPrice.ulEnd-1;
    if (fExpectRise > (0.099F)) return (0);
    fThresholdPrice = (((pstCurrData->stDailyPrice.ulEnd) > (fThresholdPrice)) ? (pstCurrData->stDailyPrice.ulEnd) : (fThresholdPrice));
    pstDealInfo->bIsSell = (0);
    pstDealInfo->usDealHour = 14;
    pstDealInfo->usDealMin = (USHORT)RandomUlong(50,60);
    pstDealInfo->bIsHigher = (1);
    pstDealInfo->fWeight = (FLOAT)RandomUlong(0,100);
    pstDealInfo->fThresholdPrice = (((FLOAT)(fThresholdPrice))/(1000));
    return (1);
}

canonical_original_code:
unsigned short OMA_Choose(unsigned long ulIndex, struct tagWholeData *pstCurrData, struct tagPreDealInfo *pstDealInfo)
{
    unsigned long ulMa;
    unsigned long ulPrevShorterMa; unsigned long ulCurrShorterMa;
    float fCurrOffset;
    float fThresholdPrice;
    float fCurrRise; float fExpectRise;
    unsigned long i;
    unsigned long ulStartPrice;
    struct tagWholeData *pstMeanData;
    if (ulIndex < (g_stOmaParam.ulMaDays)) return (0);
    for (i=0,pstMeanData=pstCurrData;i<(g_stOmaParam.ulMaDays);i++,pstMeanData--) {
        if ((pstMeanData->stFactor.ulFlag == 0x88888888) &&
            (pstMeanData->stFactor.fMulti > 1))
           return (0);
    }
    pstMeanData=pstCurrData-(g_stOmaParam.ulMaDays)+1;
    ulStartPrice = pstMeanData->stDailyPrice.ulEnd;
    ulMa = GetMean((g_stOmaParam.ulMaDays), pstCurrData, (0xFFFFFFFF));
    fCurrOffset = ((float)pstCurrData->stDailyPrice.ulEnd/ulMa) - 1;
    if (fCurrOffset >= (g_stOmaParam.fNoThreshold)) return (0);
    ulPrevShorterMa = GetMean((g_stOmaParam.ulMaDays)-1,pstCurrData-1,(0xFFFFFFFF));
    ulCurrShorterMa = GetMean((g_stOmaParam.ulMaDays)-1,pstCurrData,ulPrevShorterMa);
    fThresholdPrice = (float)ulCurrShorterMa/ulPrevShorterMa*pstCurrData->stDailyPrice.ulEnd;
    fExpectRise = fThresholdPrice/pstCurrData->stDailyPrice.ulEnd-1;
    if (fExpectRise > (0.099F)) return (0);
    fThresholdPrice = (((pstCurrData->stDailyPrice.ulEnd) > (fThresholdPrice)) ? (pstCurrData->stDailyPrice.ulEnd) : (fThresholdPrice));
    pstDealInfo->bIsSell = (0);
    pstDealInfo->usDealHour = 14;
    pstDealInfo->usDealMin = (unsigned short)RandomUlong(50,60);
    pstDealInfo->bIsHigher = (1);
    pstDealInfo->fWeight = (float)RandomUlong(0,100);
    pstDealInfo->fThresholdPrice = (((FLOAT)(fThresholdPrice))/(1000));
    return (1);
}

variable_types:
ulPrevShorterMa
unsigned long

variable_types:
ulCurrShorterMa
unsigned long

variable_types: fCurrOffset float

variable_types: fThresholdPrice float

variable_types: fCurrRise float

variable_types: fExpectRise float

variable_types:
i
unsigned long

variable_types:
ulStartPrice
unsigned long

user_defined_types: struct tagPreDealInfo { unsigned short bIsSell; unsigned short usDealHour; unsigned short usDealMin; unsigned short bIsHigher; float fThresholdPrice; float fWeight; }


decompiled_code:
__int64 __fastcall OMA_SortWishList(__int64 a1)
{
return a1;
}

original_code:
ULONG OMA_SortWishList( ULONG ulWishCnt, SIM_STOCK_DATA_S *pstAllData, SIM_WISH_LIST_S *astWishList)
{
    return ulWishCnt;
}

canonical_original_code:
unsigned long OMA_SortWishList(unsigned long ulWishCnt, struct tagStockData *pstAllData, struct tagWishList *astWishList)
{
    return ulWishCnt;
}

user_defined_types: struct tagWishList { unsigned int ulCode; unsigned int ulIndex; unsigned int ulWishPrice; float fWeight; }


decompiled_code:
__int64 OMA_GetGainPrice()
{
return 0xFFFFFFFFLL;
}

original_code:
ULONG OMA_GetGainPrice( FILE_WHOLE_DATA_S *pstCurrData, STOCK_CTRL_S *pstStockCtrl)
{
    return (0xFFFFFFFF);
}

canonical_original_code:
unsigned long OMA_GetGainPrice(struct tagWholeData *pstCurrData, struct tagStockCtrl *pstStockCtrl)
{
    return (0xFFFFFFFF);
}

variable_types: struct tagWholeData { char szComment[16]; unsigned int ulDate; unsigned int ulRsv; struct tagPrice { unsigned int ulBegin; unsigned int ulHigh; unsigned int ulLow; unsigned int ulEnd; unsigned int ulVol; unsigned int ulFlag; } stDailyPrice; struct tagPrice astMin30Price[8]; struct tagFactor { unsigned int ulFlag; float fMulti; float fAdder; } stFactor; unsigned int ulPad; } *


decompiled_code:
unsigned __int64 __fastcall OMA_GetLossPrice(__int64 a1, __int64 a2)
{
unsigned int v2; // eax
unsigned int v3; // edx
unsigned __int64 v4; // rax
float v5; // xmm0_4
unsigned __int64 result; // rax
float v7; // xmm0_4
float v8; // xmm0_4

v2 = *(_DWORD *)(a1 + 16);
v3 = *(_DWORD *)(a2 + 8);
if ( v2 < v3 )
_assert_fail("pstCurrData->ulDate>=pstStockCtrl->ulBuyDate", "method/oma.c", 0xD9u, "OMA_GetLossPrice");
if ( v2 == v3 )
goto LABEL_6;
v4 = 1LL;
do
{
a1 -= 256LL;
++v4;
}
while ( v3 != *(_DWORD *)(a1 + 16) );
if ( v4 <= 0x1E )
{
LABEL_6:
v5 = (float)*(int *)(a1 + 36) * 0.80000001;
if ( v5 >= 9.223372e18 )
result = (unsigned int)(int)(float)(v5 - 9.223372e18) ^ 0x8000000000000000LL;
else
result = (unsigned int)(int)v5;
}
else
{
if ( (v4 & 0x8000000000000000LL) != 0LL )
v7 = (float)(int)(v4 & 1 | (v4 >> 1)) + (float)(int)(v4 & 1 | (v4 >> 1));
else
v7 = (float)(int)v4;
v8 = (float)((float)(v7 * 0.003) + 1.0) * (float)*(int *)(a1 + 36);
if ( v8 >= 9.223372e18 )
result = (unsigned int)(int)(float)(v8 - 9.223372e18) ^ 0x8000000000000000LL;
else
result = (unsigned int)(int)v8;
}
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func5(__int64 a1, __int64 a2)
{
unsigned int v2; // eax
unsigned int v3; // edx
unsigned __int64 v4; // rax
float v5; // xmm0_4
unsigned __int64 result; // rax
float v7; // xmm0_4
float v8; // xmm0_4

v2 = *(_DWORD *)(a1 + 16);
v3 = *(_DWORD *)(a2 + 8);
if ( v2 < v3 )
_assert_fail("pstCurrData->ulDate>=pstStockCtrl->ulBuyDate", "method/oma.c", 0xD9u, "OMA_GetLossPrice");
if ( v2 == v3 )
goto LABEL_6;
v4 = 1LL;
do
{
a1 -= 256LL;
++v4;
}
while ( v3 != *(_DWORD *)(a1 + 16) );
if ( v4 <= 0x1E )
{
LABEL_6:
v5 = (float)*(int *)(a1 + 36) * 0.80000001;
if ( v5 >= 9.223372e18 )
result = (unsigned int)(int)(float)(v5 - 9.223372e18) ^ 0x8000000000000000LL;
else
result = (unsigned int)(int)v5;
}
else
{
if ( (v4 & 0x8000000000000000LL) != 0LL )
v7 = (float)(int)(v4 & 1 | (v4 >> 1)) + (float)(int)(v4 & 1 | (v4 >> 1));
else
v7 = (float)(int)v4;
v8 = (float)((float)(v7 * 0.003) + 1.0) * (float)*(int *)(a1 + 36);
if ( v8 >= 9.223372e18 )
result = (unsigned int)(int)(float)(v8 - 9.223372e18) ^ 0x8000000000000000LL;
else
result = (unsigned int)(int)v8;
}
return result;
}

original_code:
ULONG OMA_GetLossPrice( FILE_WHOLE_DATA_S *pstCurrData, STOCK_CTRL_S *pstStockCtrl)
{
    ULONG ulHoldDays=0;
    FILE_WHOLE_DATA_S *pstBuyData = pstCurrData;
    ((void) sizeof ((pstCurrData->ulDate>=pstStockCtrl->ulBuyDate) ? 1 : 0), __extension__ ({ if (pstCurrData->ulDate>=pstStockCtrl->ulBuyDate) ; else __assert_fail ("pstCurrData->ulDate>=pstStockCtrl->ulBuyDate", "method/oma.c", 217, __extension__ __PRETTY_FUNCTION__); }));
    while (1) {
        ulHoldDays++;
        if (pstBuyData->ulDate==pstStockCtrl->ulBuyDate) break;
        pstBuyData--;
    }
    if (ulHoldDays > 30) return (ULONG)((1+(ulHoldDays*0.003F))*pstBuyData->stDailyPrice.ulEnd);
    return (ULONG)(0.8F * pstBuyData->stDailyPrice.ulEnd);
}

canonical_original_code:
unsigned long OMA_GetLossPrice(struct tagWholeData *pstCurrData, struct tagStockCtrl *pstStockCtrl)
{
    unsigned long ulHoldDays = 0;
    struct tagWholeData *pstBuyData = pstCurrData;
    ((void) sizeof ((pstCurrData->ulDate>=pstStockCtrl->ulBuyDate) ? 1 : 0), __extension__ ({ if (pstCurrData->ulDate>=pstStockCtrl->ulBuyDate) ; else __assert_fail ("pstCurrData->ulDate>=pstStockCtrl->ulBuyDate", "method/oma.c", 217, __extension__ __PRETTY_FUNCTION__); }));
    while (1) {
        ulHoldDays++;
        if (pstBuyData->ulDate==pstStockCtrl->ulBuyDate) break;
        pstBuyData--;
    }
    if (ulHoldDays > 30) return (ULONG)((1+(ulHoldDays*0.003F))*pstBuyData->stDailyPrice.ulEnd);
    return (ULONG)(0.8F * pstBuyData->stDailyPrice.ulEnd);
}

variable_types:
ulHoldDays
unsigned long


decompiled_code:
__int64 __fastcall OMA_GetBuyPrice(_DWORD *a1, unsigned __int64 a2)
{
__int64 result; // rax
unsigned int v3; // edx
float v4[7]; // [rsp+Ch] [rbp-1Ch] BYREF

GetTotalRise(1LL, a1, 4LL, v4);
result = 0xFFFFFFFFLL;
if ( v4[0] <= 0.098999999 )
{
v3 = a1[9];
if ( a1[6] != v3 || a1[7] != a1[8] )
{
result = v3;
if ( v3 < a2 )
result = 0xFFFFFFFFLL;
}
}
return result;
}

original_code:
ULONG OMA_GetBuyPrice( FILE_WHOLE_DATA_S *pstCurrData, ULONG ulWishPrice)
{
    FLOAT fRise;
    (VOID)GetTotalRise(1,pstCurrData,(0x04UL),&fRise);
    if (fRise > (0.099F)) return (0xFFFFFFFF);
    if ((pstCurrData->stDailyPrice.ulBegin == pstCurrData->stDailyPrice.ulEnd) &&
        (pstCurrData->stDailyPrice.ulHigh == pstCurrData->stDailyPrice.ulLow)) return (0xFFFFFFFF);
    if (pstCurrData->stDailyPrice.ulEnd < ulWishPrice) return (0xFFFFFFFF);
    return pstCurrData->stDailyPrice.ulEnd;
}

canonical_original_code:
unsigned long OMA_GetBuyPrice(struct tagWholeData *pstCurrData, unsigned long ulWishPrice)
{
    float fRise;
    (void)GetTotalRise(1,pstCurrData,(0x04UL),&fRise);
    if (fRise > (0.099F)) return (0xFFFFFFFF);
    if ((pstCurrData->stDailyPrice.ulBegin == pstCurrData->stDailyPrice.ulEnd) &&
        (pstCurrData->stDailyPrice.ulHigh == pstCurrData->stDailyPrice.ulLow)) return (0xFFFFFFFF);
    if (pstCurrData->stDailyPrice.ulEnd < ulWishPrice) return (0xFFFFFFFF);
    return pstCurrData->stDailyPrice.ulEnd;
}


decompiled_code:
__int64 OMA_GetSellPrice()
{
return 0xFFFFFFFFLL;
}

original_code:
ULONG OMA_GetSellPrice( FILE_WHOLE_DATA_S *pstCurrData, STOCK_CTRL_S *pstStockCtrl)
{
    return (0xFFFFFFFF);
}

canonical_original_code:
unsigned long OMA_GetSellPrice(struct tagWholeData *pstCurrData, struct tagStockCtrl *pstStockCtrl)
{
    return (0xFFFFFFFF);
}


GetFileType

decompiled_code:
__int64 __fastcall GetFileType(char *s1)
{
if ( !strcasecmp(s1, "ths_day") )
return 268435492LL;
if ( !strcasecmp(s1, "ths_min5") )
return 268435461LL;
if ( !strcasecmp(s1, "custom") )
return 4026531840LL;
if ( strcasecmp(s1, "weight") )
{
puts("invaild file type");
exit(2);
}
return 536903680LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *s1)
{
if ( !strcasecmp(s1, "ths_day") )
return 268435492LL;
if ( !strcasecmp(s1, "ths_min5") )
return 268435461LL;
if ( !strcasecmp(s1, "custom") )
return 4026531840LL;
if ( strcasecmp(s1, "weight") )
{
puts("invaild file type");
exit(2);
}
return 536903680LL;
}

original_code:
ULONG GetFileType( CHAR* szType)
{
    ULONG ulFileType;
    if (0 == strcasecmp(szType, "ths_day")) {
        ulFileType = 0x10000024;
    }
    else if (0 == strcasecmp(szType, "ths_min5")) {
        ulFileType = 0x10000005;
    }
    else if (0 == strcasecmp(szType, "custom")) {
        ulFileType = 0xF0000000;
    }
    else if (0 == strcasecmp(szType, "weight")) {
        ulFileType = 0x20008000;
    }
    else {
        printf("invaild file type\n");
        ulFileType = (0xFFFFFFFF);
        exit(2);
    }
    return ulFileType;
}

canonical_original_code:
unsigned long GetFileType(char *szType)
{
    unsigned long ulFileType;
    if (0 == strcasecmp(szType, "ths_day")) {
        ulFileType = 0x10000024;
    }
    else if (0 == strcasecmp(szType, "ths_min5")) {
        ulFileType = 0x10000005;
    }
    else if (0 == strcasecmp(szType, "custom")) {
        ulFileType = 0xF0000000;
    }
    else if (0 == strcasecmp(szType, "weight")) {
        ulFileType = 0x20008000;
    }
    else {
        printf("invaild file type\n");
        ulFileType = (0xFFFFFFFF);
        exit(2);
    }
    return ulFileType;
}

variable_types:
szType
char *

variable_types:
ulFileType
unsigned long


PrintSingleDay

original_code:
VOID PrintSingleDay( FILE_WHOLE_DATA_S *pstEntry)
{
    ULONG i, ulMin30Cnt;
    ULONG aulMin[8] = {1000,1030,1100,1130,1330,1400,1430,1500};
    for (ulMin30Cnt=0;ulMin30Cnt<8;ulMin30Cnt++) {
        if (0xCCCCCCCC != pstEntry->astMin30Price[ulMin30Cnt].ulFlag) break;
    }
    printf("\n=============================================================================");
    printf("\nDATE: %lu", pstEntry->ulDate);
    for (i=0;i<ulMin30Cnt;i++) {
        printf("\t%lu", aulMin[i]);
    }
    printf("\n=============================================================================");
    printf("\nBEGIN:\t%lu", pstEntry->stDailyPrice.ulBegin);
    for (i=0;i<ulMin30Cnt;i++) {
        printf("\t%lu", pstEntry->astMin30Price[i].ulBegin);
    }
    printf("\nHIGH:\t%lu", pstEntry->stDailyPrice.ulHigh);
    for (i=0;i<ulMin30Cnt;i++) {
        printf("\t%lu", pstEntry->astMin30Price[i].ulHigh);
    }
    printf("\nLOW:\t%lu", pstEntry->stDailyPrice.ulLow);
    for (i=0;i<ulMin30Cnt;i++) {
        printf("\t%lu", pstEntry->astMin30Price[i].ulLow);
    }
    printf("\nEND:\t%lu", pstEntry->stDailyPrice.ulEnd);
    for (i=0;i<ulMin30Cnt;i++) {
        printf("\t%lu", pstEntry->astMin30Price[i].ulEnd);
    }
    printf("\nVOL:\t%lu", pstEntry->stDailyPrice.ulVol);
    for (i=0;i<ulMin30Cnt;i++) {
        printf("\t%lu", pstEntry->astMin30Price[i].ulVol);
    }
    printf("\n");
    if (0x88888888 == pstEntry->stFactor.ulFlag) {
        printf("Multi=%f, Adder=%f\n", pstEntry->stFactor.fMulti, pstEntry->stFactor.fAdder);
    }
    return;
}

canonical_original_code:
void PrintSingleDay(struct tagWholeData *pstEntry)
{
    unsigned long i; unsigned long ulMin30Cnt;
    unsigned long aulMin[8] = {1000,1030,1100,1130,1330,1400,1430,1500};
    for (ulMin30Cnt=0;ulMin30Cnt<8;ulMin30Cnt++) {
        if (0xCCCCCCCC != pstEntry->astMin30Price[ulMin30Cnt].ulFlag) break;
    }
    printf("\n=============================================================================");
    printf("\nDATE: %lu", pstEntry->ulDate);
    for (i=0;i<ulMin30Cnt;i++) {
        printf("\t%lu", aulMin[i]);
    }
    printf("\n=============================================================================");
    printf("\nBEGIN:\t%lu", pstEntry->stDailyPrice.ulBegin);
    for (i=0;i<ulMin30Cnt;i++) {
        printf("\t%lu", pstEntry->astMin30Price[i].ulBegin);
    }
    printf("\nHIGH:\t%lu", pstEntry->stDailyPrice.ulHigh);
    for (i=0;i<ulMin30Cnt;i++) {
        printf("\t%lu", pstEntry->astMin30Price[i].ulHigh);
    }
    printf("\nLOW:\t%lu", pstEntry->stDailyPrice.ulLow);
    for (i=0;i<ulMin30Cnt;i++) {
        printf("\t%lu", pstEntry->astMin30Price[i].ulLow);
    }
    printf("\nEND:\t%lu", pstEntry->stDailyPrice.ulEnd);
    for (i=0;i<ulMin30Cnt;i++) {
        printf("\t%lu", pstEntry->astMin30Price[i].ulEnd);
    }
    printf("\nVOL:\t%lu", pstEntry->stDailyPrice.ulVol);
    for (i=0;i<ulMin30Cnt;i++) {
        printf("\t%lu", pstEntry->astMin30Price[i].ulVol);
    }
    printf("\n");
    if (0x88888888 == pstEntry->stFactor.ulFlag) {
        printf("Multi=%f, Adder=%f\n", pstEntry->stFactor.fMulti, pstEntry->stFactor.fAdder);
    }
    return;
}

variable_types:
aulMin
unsigned long [8]


ShowThsDaily

decompiled_code:
int __fastcall ShowThsDaily(__int64 a1, __int64 a2, _DWORD *a3)
{
__int64 v3; // rax
_BYTE v5[264]; // [rsp+0h] [rbp-108h] BYREF

if ( !a2 )
return printf("date %ld not found\n", a1);
v3 = 0LL;
while ( *a3 != a1 )
{
a3 += 42;
if ( a2 == ++v3 )
return printf("date %ld not found\n", a1);
}
if ( a2 == v3 )
return printf("date %ld not found\n", a1);
memset(v5, 0, 0x100uLL);
FILE_ThsDayToCustom(a3, v5);
return PrintSingleDay((__int64)v5);
}

canonical_decompiled_code:
int __fastcall func2(__int64 a1, __int64 a2, _DWORD *a3)
{
__int64 v3; // rax
_BYTE v5[264]; // [rsp+0h] [rbp-108h] BYREF

if ( !a2 )
return printf("date %ld not found\n", a1);
v3 = 0LL;
while ( *a3 != a1 )
{
a3 += 42;
if ( a2 == ++v3 )
return printf("date %ld not found\n", a1);
}
if ( a2 == v3 )
return printf("date %ld not found\n", a1);
memset(v5, 0, 0x100uLL);
FILE_ThsDayToCustom(a3, v5);
return func1((__int64)v5);
}

original_code:
VOID ShowThsDaily( ULONG ulDate, ULONG ulEntryCnt, FILE_THS_DAILY_ENTRY_S *pstEntry)
{
    ULONG i;
    FILE_WHOLE_DATA_S stWholeData;
    for (i=0;i<ulEntryCnt;i++) {
        if (ulDate == pstEntry->ulDate) break;
        pstEntry++;
    }
    if (i==ulEntryCnt) {
        printf("date %ld not found\n", ulDate);
        return;
    }
    memset(&stWholeData, 0 ,sizeof(stWholeData));
    FILE_ThsDayToCustom(pstEntry, &stWholeData);
    PrintSingleDay(&stWholeData);
    return;
}

canonical_original_code:
void ShowThsDaily(unsigned long ulDate, unsigned long ulEntryCnt, struct tagFileDailyData *pstEntry)
{
    unsigned long i;
    struct tagWholeData stWholeData;
    for (i=0;i<ulEntryCnt;i++) {
        if (ulDate == pstEntry->ulDate) break;
        pstEntry++;
    }
    if (i==ulEntryCnt) {
        printf("date %ld not found\n", ulDate);
        return;
    }
    memset(&stWholeData, 0 ,sizeof(stWholeData));
    FILE_ThsDayToCustom(pstEntry, &stWholeData);
    PrintSingleDay(&stWholeData);
    return;
}

variable_types:
ulDate
unsigned long

variable_types:
ulEntryCnt
unsigned long

variable_types: struct tagFileDailyData { unsigned int ulDate; unsigned int ulBeginWithCheck; unsigned int ulHighWithCheck; unsigned int ulLowWithCheck; unsigned int ulEndWithCheck; unsigned int ulRsv; unsigned int ulVolWithCheck; unsigned char aucRsv[-1]; } *

variable_types: struct tagWholeData { char szComment[16]; unsigned int ulDate; unsigned int ulRsv; struct tagPrice { unsigned int ulBegin; unsigned int ulHigh; unsigned int ulLow; unsigned int ulEnd; unsigned int ulVol; unsigned int ulFlag; } stDailyPrice; struct tagPrice astMin30Price[8]; struct tagFactor { unsigned int ulFlag; float fMulti; float fAdder; } stFactor; unsigned int ulPad; }


decompiled_code:
int __fastcall ShowThsMin30(unsigned __int64 a1, __int64 a2, unsigned int *a3)
{
unsigned int *v3; // rbx
unsigned __int64 v4; // rax
unsigned __int64 v5; // rcx
__int64 v6; // rax
int v8[70]; // [rsp+0h] [rbp-118h] BYREF

v3 = a3;
v4 = FILE_ThsMin2Date(*a3);
if ( v4 > a1 )
return printf("Entry starts at %ld.\n", v4);
v5 = FILE_Date2ThsMin(a1);
if ( !a2 )
return printf("date %ld not found\n", a1);
v6 = 0LL;
while ( *v3 <= v5 )
{
++v6;
v3 += 34;
if ( a2 == v6 )
return printf("date %ld not found\n", a1);
}
if ( a2 == v6 )
return printf("date %ld not found\n", a1);
memset(v8, 0, 0x100uLL);
v8[4] = a1;
FILE_ThsMin5ToMin30(v3, v8);
return PrintSingleDay((__int64)v8);
}

canonical_decompiled_code:
int __fastcall func3(unsigned __int64 a1, __int64 a2, unsigned int *a3)
{
unsigned int *v3; // rbx
unsigned __int64 v4; // rax
unsigned __int64 v5; // rcx
__int64 v6; // rax
int v8[70]; // [rsp+0h] [rbp-118h] BYREF

v3 = a3;
v4 = FILE_ThsMin2Date(*a3);
if ( v4 > a1 )
return printf("Entry starts at %ld.\n", v4);
v5 = FILE_Date2ThsMin(a1);
if ( !a2 )
return printf("date %ld not found\n", a1);
v6 = 0LL;
while ( *v3 <= v5 )
{
++v6;
v3 += 34;
if ( a2 == v6 )
return printf("date %ld not found\n", a1);
}
if ( a2 == v6 )
return printf("date %ld not found\n", a1);
memset(v8, 0, 0x100uLL);
v8[4] = a1;
FILE_ThsMin5ToMin30(v3, v8);
return func1((__int64)v8);
}

original_code:
VOID ShowThsMin30( ULONG ulDate, ULONG ulEntryCnt, FILE_THS_MIN5_ENTRY_S *pstEntry)
{
    ULONG i;
    FILE_WHOLE_DATA_S stWholeData;
    ULONG ulShowMin;
    ULONG ulStartDate = FILE_ThsMin2Date(pstEntry->ulMin);
    if (ulStartDate > ulDate) {
        printf("Entry starts at %ld.\n", ulStartDate);
        return;
    }
    ulShowMin = FILE_Date2ThsMin(ulDate);
    for (i=0;i<ulEntryCnt;i++,pstEntry++) {
        if (pstEntry->ulMin > ulShowMin) break;
    }
    if (i==ulEntryCnt) {
        printf("date %ld not found\n", ulDate);
        return;
    }
    memset(&stWholeData, 0 ,sizeof(stWholeData));
    stWholeData.ulDate = ulDate;
    FILE_ThsMin5ToMin30(pstEntry, &stWholeData);
    PrintSingleDay(&stWholeData);
    return;
}

canonical_original_code:
void ShowThsMin30(unsigned long ulDate, unsigned long ulEntryCnt, struct tagFile5MinuteData *pstEntry)
{
    unsigned long i;
    struct tagWholeData stWholeData;
    unsigned long ulShowMin;
    unsigned long ulStartDate = FILE_ThsMin2Date(pstEntry->ulMin);
    if (ulStartDate > ulDate) {
        printf("Entry starts at %ld.\n", ulStartDate);
        return;
    }
    ulShowMin = FILE_Date2ThsMin(ulDate);
    for (i=0;i<ulEntryCnt;i++,pstEntry++) {
        if (pstEntry->ulMin > ulShowMin) break;
    }
    if (i==ulEntryCnt) {
        printf("date %ld not found\n", ulDate);
        return;
    }
    memset(&stWholeData, 0 ,sizeof(stWholeData));
    stWholeData.ulDate = ulDate;
    FILE_ThsMin5ToMin30(pstEntry, &stWholeData);
    PrintSingleDay(&stWholeData);
    return;
}

variable_types: struct tagFile5MinuteData { unsigned int ulMin; unsigned int ulBeginWithCheck; unsigned int ulHighWithCheck; unsigned int ulLowWithCheck; unsigned int ulEndWithCheck; unsigned int ulRsv; unsigned int ulVolWithCheck; unsigned char aucRsv[-1]; } *

variable_types:
ulShowMin
unsigned long

variable_types:
ulStartDate
unsigned long


ShowQlWeight

decompiled_code:
void ShowQlWeight()
{
;
}

canonical_decompiled_code:
void func4()
{
;
}

original_code:
VOID ShowQlWeight( ULONG ulDate, ULONG ulEntryCnt, FILE_QL_WEIGHT_ENTRY_S *pstEntry)
{
    return;
}

canonical_original_code:
void ShowQlWeight(unsigned long ulDate, unsigned long ulEntryCnt, struct tagFileWeight *pstEntry)
{
    return;
}

variable_types: struct tagFileWeight { unsigned int ulQlDate; unsigned int ulGift; unsigned int ulOffer; unsigned int ulOfferPrice; unsigned int ulProfit; unsigned int ulAdd; unsigned int ulTotalStock; unsigned int ulCirStock; unsigned int ulRsv; } *


ShowCustom

decompiled_code:
int __fastcall ShowCustom(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // rax
int result; // eax

v4 = GetIndexByDate(a1, 0LL, a2, a3);
if ( v4 == 0xFFFFFFFFLL )
result = printf("date %ld not found\n", a1);
else
result = PrintSingleDay(a3 + (v4 << 8));
return result;
}

canonical_decompiled_code:
int __fastcall func5(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // rax
int result; // eax

v4 = GetIndexByDate(a1, 0LL, a2, a3);
if ( v4 == 0xFFFFFFFFLL )
result = printf("date %ld not found\n", a1);
else
result = func1(a3 + (v4 << 8));
return result;
}

original_code:
VOID ShowCustom( ULONG ulDate, ULONG ulEntryCnt, FILE_WHOLE_DATA_S *pstEntry)
{
    ULONG ulIndex;
    FILE_WHOLE_DATA_S *pstCurrent;
    ulIndex = GetIndexByDate(ulDate, (0x00), ulEntryCnt, pstEntry);
    if ((0xFFFFFFFF) == ulIndex) {
        printf("date %ld not found\n", ulDate);
        return;
    }
    pstCurrent = pstEntry+ulIndex;
    PrintSingleDay(pstCurrent);
    return;
}

canonical_original_code:
void ShowCustom(unsigned long ulDate, unsigned long ulEntryCnt, struct tagWholeData *pstEntry)
{
    unsigned long ulIndex;
    struct tagWholeData *pstCurrent;
    ulIndex = GetIndexByDate(ulDate, (0x00), ulEntryCnt, pstEntry);
    if ((0xFFFFFFFF) == ulIndex) {
        printf("date %ld not found\n", ulDate);
        return;
    }
    pstCurrent = pstEntry+ulIndex;
    PrintSingleDay(pstCurrent);
    return;
}

variable_types:
ulIndex
unsigned long


ShowFileContent

decompiled_code:
void __fastcall ShowFileContent(__int64 a1, unsigned __int64 a2, __int64 a3, unsigned __int64 a4)
{
__int64 v5; // rax
void *ptr; // [rsp+8h] [rbp-20h] BYREF

ptr = 0LL;
v5 = FILE_GetFileData(a1, a3, a4, &ptr);
if ( v5 )
{
if ( a4 != 536903680 )
{
if ( a4 > 0x20008000 )
{
if ( a4 == 4026531840 )
{
ShowCustom(a2, v5, (__int64)ptr);
goto LABEL_7;
}
}
else
{
if ( a4 == 268435461 )
{
ShowThsMin30(a2, v5, (unsigned int *)ptr);
goto LABEL_7;
}
if ( a4 == 268435492 )
{
ShowThsDaily(a2, v5, ptr);
goto LABEL_7;
}
}
_assert_fail("0", "ShowData.c", 0xADu, "ShowFileContent");
}
LABEL_7:
free(ptr);
return;
}
puts("can't get data");
}

canonical_decompiled_code:
void __fastcall func6(__int64 a1, unsigned __int64 a2, __int64 a3, unsigned __int64 a4)
{
__int64 v5; // rax
void *ptr; // [rsp+8h] [rbp-20h] BYREF

ptr = 0LL;
v5 = FILE_GetFileData(a1, a3, a4, &ptr);
if ( v5 )
{
if ( a4 != 536903680 )
{
if ( a4 > 0x20008000 )
{
if ( a4 == 4026531840 )
{
func5(a2, v5, (__int64)ptr);
goto LABEL_7;
}
}
else
{
if ( a4 == 268435461 )
{
func3(a2, v5, (unsigned int *)ptr);
goto LABEL_7;
}
if ( a4 == 268435492 )
{
func2(a2, v5, ptr);
goto LABEL_7;
}
}
_assert_fail("0", "ShowData.c", 0xADu, "ShowFileContent");
}
LABEL_7:
free(ptr);
return;
}
puts("can't get data");
}

original_code:
VOID ShowFileContent( ULONG ulStockCode, ULONG ulDate, CHAR *szDir, ULONG ulFileType)
{
    ULONG ulEntryCnt;
    VOID *pData = ((void *)0);
    ulEntryCnt = FILE_GetFileData(ulStockCode, szDir, ulFileType, &pData);
    if (0 == ulEntryCnt) {
        printf("can't get data\n");
        return;
    }
    switch(ulFileType) {
        case 0x10000024:
            ShowThsDaily(ulDate, ulEntryCnt, pData);
            break;
        case 0x10000005:
            ShowThsMin30(ulDate, ulEntryCnt, pData);
            break;
        case 0x20008000:
            ShowQlWeight(ulDate, ulEntryCnt, pData);
            break;
        case 0xF0000000:
            ShowCustom(ulDate, ulEntryCnt, pData);
            break;
        default:
            ((void) sizeof ((0) ? 1 : 0), __extension__ ({ if (0) ; else __assert_fail ("0", "ShowData.c", 173, __extension__ __PRETTY_FUNCTION__); }));
    }
    free(pData);
    return;
}

canonical_original_code:
void ShowFileContent(unsigned long ulStockCode, unsigned long ulDate, char *szDir, unsigned long ulFileType)
{
    unsigned long ulEntryCnt;
    void *pData = ((void *)0);
    ulEntryCnt = FILE_GetFileData(ulStockCode, szDir, ulFileType, &pData);
    if (0 == ulEntryCnt) {
        printf("can't get data\n");
        return;
    }
    switch(ulFileType) {
        case 0x10000024:
            ShowThsDaily(ulDate, ulEntryCnt, pData);
            break;
        case 0x10000005:
            ShowThsMin30(ulDate, ulEntryCnt, pData);
            break;
        case 0x20008000:
            ShowQlWeight(ulDate, ulEntryCnt, pData);
            break;
        case 0xF0000000:
            ShowCustom(ulDate, ulEntryCnt, pData);
            break;
        default:
            ((void) sizeof ((0) ? 1 : 0), __extension__ ({ if (0) ; else __assert_fail ("0", "ShowData.c", 173, __extension__ __PRETTY_FUNCTION__); }));
    }
    free(pData);
    return;
}

variable_types:
ulStockCode
unsigned long

variable_types:
szDir
char *

variable_types:
pData
void *


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbp
__int64 v4; // r12
unsigned __int64 v5; // r13

if ( (unsigned int)(argc - 5) > 1 )
{
printf("USAGE: %s path type code date [debug]", *argv);
exit(1);
}
if ( !strcasecmp(argv[argc - 1], "debug") )
g_bIsDebugMode = 1;
v3 = atol(argv[3]);
v4 = atol(argv[4]);
v5 = GetFileType((char *)argv[2]);
DebugOutString("code=%06lu, date=%lu, type=0x%08lx\n", v3, v4, v5);
ShowFileContent(v3, v4, (__int64)argv[1], v5);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbp
__int64 v4; // r12
unsigned __int64 v5; // r13

if ( (unsigned int)(argc - 5) > 1 )
{
printf("USAGE: %s path type code date [debug]", *argv);
exit(1);
}
if ( !strcasecmp(argv[argc - 1], "debug") )
g_bIsDebugMode = 1;
v3 = atol(argv[3]);
v4 = atol(argv[4]);
v5 = func0((char *)argv[2]);
DebugOutString("code=%06lu, date=%lu, type=0x%08lx\n", v3, v4, v5);
func6(v3, v4, (__int64)argv[1], v5);
return 0;
}

original_code:
int main(int argc,char *argv[])
{
    ULONG ulStockCode;
    ULONG ulShowDate;
    ULONG ulFileType;
    if ((argc < 5) || (argc > 6)) {
        printf("USAGE: %s path type code date [debug]", argv[0]);
        exit(1);
    }
    if (0 == strcasecmp(argv[argc-1], "debug"))
        g_bIsDebugMode = (1);
    ulStockCode = (ULONG)atol(argv[3]);
    ulShowDate = (ULONG)atol(argv[4]);
    ulFileType = GetFileType(argv[2]);
    DebugOutString("code=%06lu, date=%lu, type=0x%08lx\n", ulStockCode, ulShowDate, ulFileType);
    ShowFileContent(ulStockCode, ulShowDate, argv[1], ulFileType);
    return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
    unsigned long ulStockCode;
    unsigned long ulShowDate;
    unsigned long ulFileType;
    if ((argc < 5) || (argc > 6)) {
        printf("USAGE: %s path type code date [debug]", argv[0]);
        exit(1);
    }
    if (0 == strcasecmp(argv[argc-1], "debug"))
        g_bIsDebugMode = (1);
    ulStockCode = (unsigned long)atol(argv[3]);
    ulShowDate = (unsigned long)atol(argv[4]);
    ulFileType = GetFileType(argv[2]);
    DebugOutString("code=%06lu, date=%lu, type=0x%08lx\n", ulStockCode, ulShowDate, ulFileType);
    ShowFileContent(ulStockCode, ulShowDate, argv[1], ulFileType);
    return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types:
ulShowDate
unsigned long


decompiled_code:
void SMA_SetParam()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code:
VOID SMA_SetParam( ULONG ulCnt, FLOAT *afParam)
{
    return;
}

canonical_original_code:
void SMA_SetParam(unsigned long ulCnt, float *afParam)
{
    return;
}

variable_types:
ulCnt
unsigned long

variable_types:
afParam
float *


decompiled_code:
void __fastcall SMA_Statistics(unsigned __int64 a1, __int64 a2)
{
__int64 v2; // rax
float v3; // xmm1_4

if ( a1 > 0x1D )
{
v2 = GetMean(15LL, a2, 0xFFFFFFFFLL);
if ( v2 < 0 )
v3 = (float)(v2 & 1 | (unsigned int)((unsigned __int64)v2 >> 1))
+ (float)(v2 & 1 | (unsigned int)((unsigned __int64)v2 >> 1));
else
v3 = (float)(int)v2;
printf(
"%lu,%lu,%f\n",
*(unsigned int *)(a2 + 16),
*(unsigned int *)(a2 + 36),
(float)((float)((float)*(int *)(a2 + 36) / v3) - 1.0));
}
}

canonical_decompiled_code:
void __fastcall func2(unsigned __int64 a1, __int64 a2)
{
__int64 v2; // rax
float v3; // xmm1_4

if ( a1 > 0x1D )
{
v2 = GetMean(15LL, a2, 0xFFFFFFFFLL);
if ( v2 < 0 )
v3 = (float)(v2 & 1 | (unsigned int)((unsigned __int64)v2 >> 1))
+ (float)(v2 & 1 | (unsigned int)((unsigned __int64)v2 >> 1));
else
v3 = (float)(int)v2;
printf(
"%lu,%lu,%f\n",
*(unsigned int *)(a2 + 16),
*(unsigned int *)(a2 + 36),
(float)((float)((float)*(int *)(a2 + 36) / v3) - 1.0));
}
}

original_code:
VOID SMA_Statistics( ULONG ulIndex, FILE_WHOLE_DATA_S *pstBuyData)
{
    ULONG ulMa, ulWma;
    FLOAT fRate;
    if (ulIndex < (30)) return;
    ulMa=GetMean((15),pstBuyData,(0xFFFFFFFF));
        printf("%lu,%lu,%f\n",pstBuyData->ulDate, pstBuyData->stDailyPrice.ulEnd, pstBuyData->stDailyPrice.ulEnd/(FLOAT)ulMa-1);
    return;
}

canonical_original_code:
void SMA_Statistics(unsigned long ulIndex, struct tagWholeData *pstBuyData)
{
    unsigned long ulMa; unsigned long ulWma;
    float fRate;
    if (ulIndex < (30)) return;
    ulMa=GetMean((15),pstBuyData,(0xFFFFFFFF));
        printf("%lu,%lu,%f\n",pstBuyData->ulDate, pstBuyData->stDailyPrice.ulEnd, pstBuyData->stDailyPrice.ulEnd/(float)ulMa-1);
    return;
}

variable_types: struct tagWholeData { char szComment[16]; unsigned int ulDate; unsigned int ulRsv; struct tagPrice { unsigned int ulBegin; unsigned int ulHigh; unsigned int ulLow; unsigned int ulEnd; unsigned int ulVol; unsigned int ulFlag; } stDailyPrice; struct tagPrice astMin30Price[8]; struct tagFactor { unsigned int ulFlag; float fMulti; float fAdder; } stFactor; unsigned int ulPad; } *

variable_types:
ulMa
unsigned long

variable_types:
ulWma
unsigned long

variable_types: fRate float


original_code:
BOOL_T SMA_Choose( ULONG ulIndex, FILE_WHOLE_DATA_S *pstCurrData, CHOOSE_PRE_DEAL_S *pstDealInfo)
{
    ULONG ulPrevMa,ulCurrMa;
    ULONG ulThreshPrice;
    ULONG i;
    FLOAT fPrevVolRatio, fChooseVolRatio;
    FILE_WHOLE_DATA_S *pstTemp=pstCurrData;
    FILE_WHOLE_DATA_S *pstChoose=pstCurrData;
    FILE_WHOLE_DATA_S *pstPrev=pstChoose-1;
    if (ulIndex <= SMA_GetMinIndex()) return (0);
    for (i=(15);i>0;i--,pstTemp--) {
        if (0x88888888==pstTemp->stFactor.ulFlag) return (0);
    }
    fPrevVolRatio=GetVolRatio(pstPrev);
    if ((fPrevVolRatio<1) || (fPrevVolRatio>2)) return (0);
    fChooseVolRatio=GetVolRatio(pstChoose);
    if (fChooseVolRatio>2) return (0);
    ulPrevMa=GetMean((15),pstPrev,(0xFFFFFFFF));
    ulCurrMa=GetMean((15),pstChoose,ulPrevMa);
    if (pstPrev->stDailyPrice.ulBegin > (ulPrevMa*0.99)) return (0);
    if (pstPrev->stDailyPrice.ulEnd < (ulPrevMa*1.01)) return (0);
    if (pstChoose->stDailyPrice.ulLow < ulCurrMa) return (0);
    if (ulCurrMa > (ULONG)(ulPrevMa*(1.000F))) return (0);
    {
        FLOAT fDrop;
        GetTotalRise((30),pstPrev,(0x04UL),&fDrop);
        if (fDrop>(-0.1800F)) return (0);
    }
    ulThreshPrice = (((ulCurrMa) < (ulPrevMa)) ? (ulCurrMa) : (ulPrevMa));
    pstDealInfo->bIsSell = (0);
    pstDealInfo->usDealHour = (14);
    pstDealInfo->usDealMin = (USHORT)RandomUlong(50,60);
    pstDealInfo->bIsHigher = (1);
    pstDealInfo->fThresholdPrice = (((FLOAT)(ulThreshPrice))/(1000));
    return (1);
}

canonical_original_code:
unsigned short SMA_Choose(unsigned long ulIndex, struct tagWholeData *pstCurrData, struct tagPreDealInfo *pstDealInfo)
{
    unsigned long ulPrevMa; unsigned long ulCurrMa;
    unsigned long ulThreshPrice;
    unsigned long i;
    float fPrevVolRatio; float fChooseVolRatio;
    struct tagWholeData *pstTemp = pstCurrData;
    struct tagWholeData *pstChoose = pstCurrData;
    struct tagWholeData *pstPrev = pstChoose-1;
    if (ulIndex <= SMA_GetMinIndex()) return (0);
    for (i=(15);i>0;i--,pstTemp--) {
        if (0x88888888==pstTemp->stFactor.ulFlag) return (0);
    }
    fPrevVolRatio=GetVolRatio(pstPrev);
    if ((fPrevVolRatio<1) || (fPrevVolRatio>2)) return (0);
    fChooseVolRatio=GetVolRatio(pstChoose);
    if (fChooseVolRatio>2) return (0);
    ulPrevMa=GetMean((15),pstPrev,(0xFFFFFFFF));
    ulCurrMa=GetMean((15),pstChoose,ulPrevMa);
    if (pstPrev->stDailyPrice.ulBegin > (ulPrevMa*0.99)) return (0);
    if (pstPrev->stDailyPrice.ulEnd < (ulPrevMa*1.01)) return (0);
    if (pstChoose->stDailyPrice.ulLow < ulCurrMa) return (0);
    if (ulCurrMa > (ULONG)(ulPrevMa*(1.000F))) return (0);
    {
        float fDrop;
        GetTotalRise((30),pstPrev,(0x04UL),&fDrop);
        if (fDrop>(-0.1800F)) return (0);
    }
    ulThreshPrice = (((ulCurrMa) < (ulPrevMa)) ? (ulCurrMa) : (ulPrevMa));
    pstDealInfo->bIsSell = (0);
    pstDealInfo->usDealHour = (14);
    pstDealInfo->usDealMin = (unsigned short)RandomUlong(50,60);
    pstDealInfo->bIsHigher = (1);
    pstDealInfo->fThresholdPrice = (((FLOAT)(ulThreshPrice))/(1000));
    return (1);
}

variable_types: struct tagPreDealInfo { unsigned short bIsSell; unsigned short usDealHour; unsigned short usDealMin; unsigned short bIsHigher; float fThresholdPrice; float fWeight; } *

variable_types:
ulPrevMa
unsigned long

variable_types:
ulCurrMa
unsigned long

variable_types:
ulThreshPrice
unsigned long

variable_types:
i
unsigned long

variable_types: fPrevVolRatio float

variable_types: fChooseVolRatio float

variable_types: fDrop float


decompiled_code:
void SMA_SortWishList()
{
;
}

original_code:
VOID SMA_SortWishList( ULONG ulWishCnt, SIM_STOCK_DATA_S *pstAllData, SIM_WISH_LIST_S *astWishList)
{
    return;
}

canonical_original_code:
void SMA_SortWishList(unsigned long ulWishCnt, struct tagStockData *pstAllData, struct tagWishList *astWishList)
{
    return;
}

variable_types:
ulWishCnt
unsigned long

variable_types: struct tagStockData { unsigned int ulStockCode; unsigned int ulEntryCnt; unsigned short bIsHold; struct tagWholeData { char szComment[16]; unsigned int ulDate; unsigned int ulRsv; struct tagPrice { unsigned int ulBegin; unsigned int ulHigh; unsigned int ulLow; unsigned int ulEnd; unsigned int ulVol; unsigned int ulFlag; } stDailyPrice; struct tagPrice astMin30Price[8]; struct tagFactor { unsigned int ulFlag; float fMulti; float fAdder; } stFactor; unsigned int ulPad; } *pstCurrData; struct tagWholeData *astWholeData; } *

variable_types: struct tagWishList { unsigned int ulCode; unsigned int ulIndex; unsigned int ulWishPrice; float fWeight; } *


decompiled_code:
unsigned __int64 __fastcall SMA_GetGainPrice(__int64 a1, __int64 a2, unsigned __int64 a3)
{
unsigned int v3; // ecx
unsigned int v4; // eax
__int64 v5; // rbx
unsigned __int64 v6; // rbp
__int64 v7; // r13
unsigned __int64 i; // r12
float v9; // xmm1_4
float v10; // xmm0_4
float v11; // xmm1_4
float v12; // xmm0_4
unsigned __int64 result; // rax

v3 = *(_DWORD *)(a1 + 16);
v4 = *(_DWORD *)(a2 + 8);
if ( v3 < v4 )
_assert_fail("pstCurrData->ulDate>=pstStockCtrl->ulBuyDate", "method/sma.c", 0x78u, "SMA_GetGainPrice");
v5 = a1;
if ( v3 == v4 )
{
v6 = 1LL;
}
else
{
v6 = 1LL;
do
{
v5 -= 256LL;
++v6;
}
while ( v4 != *(_DWORD *)(v5 + 16) );
v7 = v6;
if ( !v6 )
goto LABEL_8;
}
v7 = 0LL;
a3 = 0xFFFFFFFFLL;
for ( i = 0LL; i < v6; ++i )
{
a3 = GetMean(15LL, v5, a3);
v7 += *(unsigned int *)(v5 + 32) < a3;
v5 += 256LL;
}
LABEL_8:
if ( v7 < 0 )
v9 = (float)(v7 & 1 | (unsigned int)((unsigned __int64)v7 >> 1))
+ (float)(v7 & 1 | (unsigned int)((unsigned __int64)v7 >> 1));
else
v9 = (float)(int)v7;
v10 = 1.2029999 - (float)(v9 * 0.0099999998);
if ( (a3 & 0x8000000000000000LL) != 0LL )
v11 = (float)(int)(a3 & 1 | (a3 >> 1)) + (float)(int)(a3 & 1 | (a3 >> 1));
else
v11 = (float)(int)a3;
v12 = v10 * v11;
if ( v12 >= 9.223372e18 )
result = (unsigned int)(int)(float)(v12 - 9.223372e18) ^ 0x8000000000000000LL;
else
result = (unsigned int)(int)v12;
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func5(__int64 a1, __int64 a2, unsigned __int64 a3)
{
unsigned int v3; // ecx
unsigned int v4; // eax
__int64 v5; // rbx
unsigned __int64 v6; // rbp
__int64 v7; // r13
unsigned __int64 i; // r12
float v9; // xmm1_4
float v10; // xmm0_4
float v11; // xmm1_4
float v12; // xmm0_4
unsigned __int64 result; // rax

v3 = *(_DWORD *)(a1 + 16);
v4 = *(_DWORD *)(a2 + 8);
if ( v3 < v4 )
_assert_fail("pstCurrData->ulDate>=pstStockCtrl->ulBuyDate", "method/sma.c", 0x78u, "SMA_GetGainPrice");
v5 = a1;
if ( v3 == v4 )
{
v6 = 1LL;
}
else
{
v6 = 1LL;
do
{
v5 -= 256LL;
++v6;
}
while ( v4 != *(_DWORD *)(v5 + 16) );
v7 = v6;
if ( !v6 )
goto LABEL_8;
}
v7 = 0LL;
a3 = 0xFFFFFFFFLL;
for ( i = 0LL; i < v6; ++i )
{
a3 = GetMean(15LL, v5, a3);
v7 += *(unsigned int *)(v5 + 32) < a3;
v5 += 256LL;
}
LABEL_8:
if ( v7 < 0 )
v9 = (float)(v7 & 1 | (unsigned int)((unsigned __int64)v7 >> 1))
+ (float)(v7 & 1 | (unsigned int)((unsigned __int64)v7 >> 1));
else
v9 = (float)(int)v7;
v10 = 1.2029999 - (float)(v9 * 0.0099999998);
if ( (a3 & 0x8000000000000000LL) != 0LL )
v11 = (float)(int)(a3 & 1 | (a3 >> 1)) + (float)(int)(a3 & 1 | (a3 >> 1));
else
v11 = (float)(int)a3;
v12 = v10 * v11;
if ( v12 >= 9.223372e18 )
result = (unsigned int)(int)(float)(v12 - 9.223372e18) ^ 0x8000000000000000LL;
else
result = (unsigned int)(int)v12;
return result;
}

original_code:
ULONG SMA_GetGainPrice( FILE_WHOLE_DATA_S *pstCurrData, STOCK_CTRL_S *pstStockCtrl)
{
    ULONG i, ulHoldDays=0;
    ULONG ulPrevMa, ulCurrMa;
    ULONG ulBelowCnt;
    BOOL_T bIsSame=(0);
    FILE_WHOLE_DATA_S *pstData=pstCurrData;
    ((void) sizeof ((pstCurrData->ulDate>=pstStockCtrl->ulBuyDate) ? 1 : 0), __extension__ ({ if (pstCurrData->ulDate>=pstStockCtrl->ulBuyDate) ; else __assert_fail ("pstCurrData->ulDate>=pstStockCtrl->ulBuyDate", "method/sma.c", 120, __extension__ __PRETTY_FUNCTION__); }));
    while (1) {
        ulHoldDays++;
        if (pstData->ulDate==pstStockCtrl->ulBuyDate) break;
        pstData--;
    }
    for(i=0,ulPrevMa=(0xFFFFFFFF),ulBelowCnt=0;i<ulHoldDays;i++,pstData++) {
        ulCurrMa=GetMean((15),pstData,ulPrevMa);
        if (pstData->stDailyPrice.ulLow < ulCurrMa) {
            ulBelowCnt++;
        }
        ulPrevMa=ulCurrMa;
    }
    return (ULONG)(ulCurrMa * ((1.203F)-(ulBelowCnt*(0.010F))));
}

canonical_original_code:
unsigned long SMA_GetGainPrice(struct tagWholeData *pstCurrData, struct tagStockCtrl *pstStockCtrl)
{
    unsigned long i; unsigned long ulHoldDays = 0;
    unsigned long ulPrevMa; unsigned long ulCurrMa;
    unsigned long ulBelowCnt;
    unsigned short bIsSame = (0);
    struct tagWholeData *pstData = pstCurrData;
    ((void) sizeof ((pstCurrData->ulDate>=pstStockCtrl->ulBuyDate) ? 1 : 0), __extension__ ({ if (pstCurrData->ulDate>=pstStockCtrl->ulBuyDate) ; else __assert_fail ("pstCurrData->ulDate>=pstStockCtrl->ulBuyDate", "method/sma.c", 120, __extension__ __PRETTY_FUNCTION__); }));
    while (1) {
        ulHoldDays++;
        if (pstData->ulDate==pstStockCtrl->ulBuyDate) break;
        pstData--;
    }
    for(i=0,ulPrevMa=(0xFFFFFFFF),ulBelowCnt=0;i<ulHoldDays;i++,pstData++) {
        ulCurrMa=GetMean((15),pstData,ulPrevMa);
        if (pstData->stDailyPrice.ulLow < ulCurrMa) {
            ulBelowCnt++;
        }
        ulPrevMa=ulCurrMa;
    }
    return (ULONG)(ulCurrMa * ((1.203F)-(ulBelowCnt*(0.010F))));
}

variable_types: struct tagStockCtrl { unsigned int ulGainPrice; unsigned int ulLossPrice; unsigned int ulBuyDate; unsigned int ulBuyPrice; unsigned int ulSellDate; unsigned int ulSellPrice; float fContext; } *

variable_types:
ulHoldDays
unsigned long

variable_types:
ulBelowCnt
unsigned long

variable_types:
bIsSame
unsigned short