ListaRetira

decompiled_code:
__int64 __fastcall ListaRetira(__int64 a1, char *a2)
{
unsigned int v3; // er12
char *i; // rbx
char *v5; // rdi
__int64 v6; // rax
char *dest; // [rsp+8h] [rbp-20h] BYREF

v3 = ListaBusca((char *)a1, a2, &dest);
if ( !v3 )
{
for ( i = dest; ; strcpy(v5, i) )
{
v6 = 156096LL * *(int *)(a1 + 1560960);
if ( i == (char *)(a1 + v6) )
break;
v5 = i;
i += 156096;
}
PilhaDestroi(a1 + v6 + 32);
--*(_DWORD *)(a1 + 1560960);
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, char *a2)
{
unsigned int v3; // er12
char *i; // rbx
char *v5; // rdi
__int64 v6; // rax
char *dest; // [rsp+8h] [rbp-20h] BYREF

v3 = func5((char *)a1, a2, &dest);
if ( !v3 )
{
for ( i = dest; ; strcpy(v5, i) )
{
v6 = 156096LL * *(int *)(a1 + 1560960);
if ( i == (char *)(a1 + v6) )
break;
v5 = i;
i += 156096;
}
PilhaDestroi(a1 + v6 + 32);
--*(_DWORD *)(a1 + 1560960);
}
return v3;
}

original_code:
int ListaRetira(Lista* L, elem* x) {
    elem* p; elem* i;
    int encontrou = ListaBusca (L, x, &p);
    if (encontrou != 0)
        return encontrou;
    for (i = p; i != &L->elementos[L->tamanho]; i++) {
        strcpy(i->nome, (i + 1)->nome);
    }
    PilhaDestroi (&L->elementos[L->tamanho].a_pilha);
    L->tamanho--;
    return 0;
}

canonical_original_code:
int ListaRetira(struct Lista *L, struct elem *x) {
    struct elem *p; struct elem *i;
    int encontrou = ListaBusca (L, x, &p);
    if (encontrou != 0)
        return encontrou;
    for (i = p; i != &L->elementos[L->tamanho]; i++) {
        strcpy(i->nome, (i + 1)->nome);
    }
    PilhaDestroi (&L->elementos[L->tamanho].a_pilha);
    L->tamanho--;
    return 0;
}

variable_types: encontrou int


ListaPrint

decompiled_code:
int __fastcall ListaPrint(__int64 a1)
{
int result; // eax
__int64 v2; // r12
const char *v3; // rbp
int v4; // ebx
const char *v5; // rdi

result = *(_DWORD *)(a1 + 1560960);
if ( result > 0 )
{
v2 = a1;
v3 = (const char *)a1;
v4 = 0;
do
{
printf("Produto %d: %s", (unsigned int)++v4, v3);
v5 = v3 + 32;
v3 += 156096;
PilhaPrint(v5);
result = puts(&s);
}
while ( v4 < *(_DWORD *)(v2 + 1560960) );
}
return result;
}

canonical_decompiled_code:
int __fastcall func10(__int64 a1)
{
int result; // eax
__int64 v2; // r12
const char *v3; // rbp
int v4; // ebx
const char *v5; // rdi

result = *(_DWORD *)(a1 + 1560960);
if ( result > 0 )
{
v2 = a1;
v3 = (const char *)a1;
v4 = 0;
do
{
printf("Produto %d: %s", (unsigned int)++v4, v3);
v5 = v3 + 32;
v3 += 156096;
PilhaPrint(v5);
result = puts(&s);
}
while ( v4 < *(_DWORD *)(v2 + 1560960) );
}
return result;
}

original_code:
void ListaPrint (Lista* L, char ultimo) {
 int i;
 for (i = 0; i < L->tamanho; i++) {
  printf ("Produto %d: %s", i + 1, L->elementos[i].nome);
  PilhaPrint (&L->elementos[i].a_pilha);
  puts ("");
 }
}

canonical_original_code:
void ListaPrint(struct Lista *L, char ultimo) {
 int i;
 for (i = 0; i < L->tamanho; i++) {
  printf ("Produto %d: %s", i + 1, L->elementos[i].nome);
  PilhaPrint (&L->elementos[i].a_pilha);
  puts ("");
 }
}

variable_types: struct Lista { struct elem { char nome[30]; struct Pilha { float lances[255]; struct fila { char usuario[20][30]; int ini; } preferencia[255]; int topo; } a_pilha; } elementos[10]; int tamanho; } *

variable_types: ultimo char

variable_types: i int

return_type: void

user_defined_types: struct Lista { struct elem elementos[10]; int tamanho; }

user_defined_types: struct elem { char nome[30]; struct Pilha a_pilha; }

user_defined_types: struct Pilha { float lances[255]; struct fila preferencia[255]; int topo; }


ListaDestroi

decompiled_code:
__int64 __fastcall ListaDestroi(__int64 a1)
{
__int64 result; // rax
__int64 v3; // rbp
int v4; // ebx
__int64 v5; // rdi

result = *(unsigned int *)(a1 + 1560960);
if ( (int)result > 0 )
{
v3 = a1 + 32;
v4 = 0;
do
{
v5 = v3;
++v4;
v3 += 156096LL;
result = PilhaDestroi(v5);
}
while ( *(_DWORD *)(a1 + 1560960) > v4 );
}
*(_DWORD *)(a1 + 1560960) = 0;
return result;
}

original_code:
void ListaDestroi (Lista *L) {
 int i;
 for (i = 0; i < L->tamanho; i++) {
  PilhaDestroi (&L->elementos[i].a_pilha);
 }
 L->tamanho = 0;
}

canonical_original_code:
void ListaDestroi(struct Lista *L) {
 int i;
 for (i = 0; i < L->tamanho; i++) {
  PilhaDestroi (&L->elementos[i].a_pilha);
 }
 L->tamanho = 0;
}

user_defined_types: struct fila { char usuario[20][30]; int ini; }


MostraEscolhas

decompiled_code:
int MostraEscolhas()
{
puts(s);
puts("c) Cadastrar produto");
puts("l) Listar produtos e lances");
puts("d) Dar um lance");
puts("e) Encerrar leilao");
puts("q) Sair do programa\n");
return printf("resposta > ");
}

canonical_decompiled_code:
int func0()
{
puts(s);
puts("c) Cadastrar produto");
puts("l) Listar produtos e lances");
puts("d) Dar um lance");
puts("e) Encerrar leilao");
puts("q) Sair do programa\n");
return printf("resposta > ");
}

original_code:
void MostraEscolhas () {
 puts ("Leilões Alg1:");
 puts ("c) Cadastrar produto");
 puts ("l) Listar produtos e lances");
 puts ("d) Dar um lance");
 puts ("e) Encerrar leilao");
 puts ("q) Sair do programa\n");
 printf ("resposta > ");
}

canonical_original_code:
void MostraEscolhas() {
 puts ("Leilões Alg1:");
 puts ("c) Cadastrar produto");
 puts ("l) Listar produtos e lances");
 puts ("d) Dar um lance");
 puts ("e) Encerrar leilao");
 puts ("q) Sair do programa\n");
 printf ("resposta > ");
}


CadastraProduto

decompiled_code:
int __fastcall CadastraProduto(__int64 a1)
{
char v2[56]; // [rsp+0h] [rbp-38h] BYREF

printf("Nome do produto: ");
fgets(v2, 30, stdin);
ListaInsereOrdenado(a1, v2);
return puts("\n");
}

canonical_decompiled_code:
int __fastcall func1(__int64 a1)
{
char v2[56]; // [rsp+0h] [rbp-38h] BYREF

printf("Nome do produto: ");
fgets(v2, 30, stdin);
ListaInsereOrdenado(a1, v2);
return puts("\n");
}

original_code:
void CadastraProduto (Lista *produtos) {
 elem novo;
 printf ("Nome do produto: ");
 fgets (novo.nome, 30, stdin);
 ListaInsereOrdenado (produtos, &novo);
 puts ("\n");
}

canonical_original_code:
void CadastraProduto(struct Lista *produtos) {
 struct elem novo;
 printf ("Nome do produto: ");
 fgets (novo.nome, 30, stdin);
 ListaInsereOrdenado (produtos, &novo);
 puts ("\n");
}

variable_types: struct Lista { struct bloco { struct elem { char nome[30]; struct Pilha { struct pilha_no { float lances; struct fila { struct fila_no { char usuario[30]; struct fila_no *prox; } *ini; } preferencia; struct pilha_no *prox; } *topo; } a_pilha; } info; struct bloco *prox; } *cabeca; int tamanho; } *

user_defined_types: struct Lista { struct bloco *cabeca; int tamanho; }

user_defined_types: struct bloco { struct elem info; struct bloco *prox; }

user_defined_types: struct pilha_no { float lances; struct fila preferencia; struct pilha_no *prox; }


ListarProdutos

decompiled_code:
int __fastcall ListarProdutos(__int64 a1)
{
if ( (unsigned int)ListaEstaVazia() )
return puts("Nenhum produto cadastrado!\n\n");
puts("\tProdutos cadastrados");
puts("\t--------------------");
ListaPrint(a1, 0LL);
return puts("\n");
}

canonical_decompiled_code:
int __fastcall func2(__int64 a1)
{
if ( (unsigned int)ListaEstaVazia() )
return puts("Nenhum produto cadastrado!\n\n");
puts("\tProdutos cadastrados");
puts("\t--------------------");
ListaPrint(a1, 0LL);
return puts("\n");
}

original_code:
void ListarProdutos (Lista *produtos) {
 if (ListaEstaVazia (produtos)) {
  puts ("Nenhum produto cadastrado!\n\n");
  return;
 }
 else {
  puts ("\tProdutos cadastrados");
  puts ("\t--------------------");
  ListaPrint (produtos, 0);
  puts ("\n");
 }
}

canonical_original_code:
void ListarProdutos(struct Lista *produtos) {
 if (ListaEstaVazia (produtos)) {
  puts ("Nenhum produto cadastrado!\n\n");
  return;
 }
 else {
  puts ("\tProdutos cadastrados");
  puts ("\t--------------------");
  ListaPrint (produtos, 0);
  puts ("\n");
 }
}

user_defined_types: struct fila_no { char usuario[30]; struct fila_no *prox; }


DarLance

decompiled_code:
int __fastcall DarLance(__int64 a1)
{
float v2; // [rsp+0h] [rbp-68h] BYREF
float v3; // [rsp+4h] [rbp-64h] BYREF
__int64 v4; // [rsp+8h] [rbp-60h] BYREF
char v5[32]; // [rsp+10h] [rbp-58h] BYREF
char s[56]; // [rsp+30h] [rbp-38h] BYREF

if ( (unsigned int)ListaEstaVazia() )
return puts("Nenhum produto cadastrado!\n\n");
printf("Nome do produto: ");
fgets(s, 30, stdin);
if ( (unsigned int)ListaBusca(a1, s, &v4) >= 0xFFFFFFFE )
return puts("Produto Invalido!\nEscolha 'l' para listagem de produtos\n");
printf("Nome do usuario: ");
fgets(v5, 30, stdin);
do
{
printf("Valor do lance: ");
_isoc99_scanf("%f", &v2);
}
while ( v2 <= 0.0 );
PilhaEspiaTopo(v4 + 32, &v3);
if ( v3 > v2 )
{
puts("Valor menor que ultimo lance dado!");
}
else
{
if ( v2 != v3 )
ListaInserePilha(a1, s, &v2);
ListaInsereFila(a1, s, v5);
}
return puts("\n");
}

canonical_decompiled_code:
int __fastcall func3(__int64 a1)
{
float v2; // [rsp+0h] [rbp-68h] BYREF
float v3; // [rsp+4h] [rbp-64h] BYREF
__int64 v4; // [rsp+8h] [rbp-60h] BYREF
char v5[32]; // [rsp+10h] [rbp-58h] BYREF
char s[56]; // [rsp+30h] [rbp-38h] BYREF

if ( (unsigned int)ListaEstaVazia() )
return puts("Nenhum produto cadastrado!\n\n");
printf("Nome do produto: ");
fgets(s, 30, stdin);
if ( (unsigned int)ListaBusca(a1, s, &v4) >= 0xFFFFFFFE )
return puts("Produto Invalido!\nEscolha 'l' para listagem de produtos\n");
printf("Nome do usuario: ");
fgets(v5, 30, stdin);
do
{
printf("Valor do lance: ");
_isoc99_scanf("%f", &v2);
}
while ( v2 <= 0.0 );
PilhaEspiaTopo(v4 + 32, &v3);
if ( v3 > v2 )
{
puts("Valor menor que ultimo lance dado!");
}
else
{
if ( v2 != v3 )
ListaInserePilha(a1, s, &v2);
ListaInsereFila(a1, s, v5);
}
return puts("\n");
}

original_code:
void DarLance (Lista *produtos) {
 if (ListaEstaVazia (produtos)) {
  puts ("Nenhum produto cadastrado!\n\n");
  return;
 }
 float valor;
 char usuario[30];
 elem novo, *aux;
 printf ("Nome do produto: ");
 fgets (novo.nome, 30, stdin);
 int i = ListaBusca (produtos, &novo, &aux);
 if (i == -1 || i == -2) {
  puts ("Produto Invalido!\nEscolha 'l' para listagem de produtos\n");
  return;
 }
 printf ("Nome do usuario: ");
 fgets (usuario, 30, stdin);
 do {
  printf ("Valor do lance: ");
  scanf ("%f", &valor);
 } while (valor <= 0);
 float ultimo;
 PilhaEspiaTopo (&aux->a_pilha, &ultimo);
 if (valor < ultimo) {
  puts ("Valor menor que ultimo lance dado!");
 }
 else if (valor == ultimo) {
  ListaInsereFila (produtos, &novo, usuario);
 }
 else {
  ListaInserePilha (produtos, &novo, &valor);
  ListaInsereFila (produtos, &novo, usuario);
 }
 puts ("\n");
}

canonical_original_code:
void DarLance(struct Lista *produtos) {
 if (ListaEstaVazia (produtos)) {
  puts ("Nenhum produto cadastrado!\n\n");
  return;
 }
 float valor;
 char usuario[30];
 struct elem novo; struct elem *aux;
 printf ("Nome do produto: ");
 fgets (novo.nome, 30, stdin);
 int i = ListaBusca (produtos, &novo, &aux);
 if (i == -1 || i == -2) {
  puts ("Produto Invalido!\nEscolha 'l' para listagem de produtos\n");
  return;
 }
 printf ("Nome do usuario: ");
 fgets (usuario, 30, stdin);
 do {
  printf ("Valor do lance: ");
  scanf ("%f", &valor);
 } while (valor <= 0);
 float ultimo;
 PilhaEspiaTopo (&aux->a_pilha, &ultimo);
 if (valor < ultimo) {
  puts ("Valor menor que ultimo lance dado!");
 }
 else if (valor == ultimo) {
  ListaInsereFila (produtos, &novo, usuario);
 }
 else {
  ListaInserePilha (produtos, &novo, &valor);
  ListaInsereFila (produtos, &novo, usuario);
 }
 puts ("\n");
}

variable_types: valor float

variable_types:
usuario
char [30]

variable_types: struct elem { char nome[30]; struct Pilha { struct pilha_no { float lances; struct fila { struct fila_no { char usuario[30]; struct fila_no *prox; } *ini; } preferencia; struct pilha_no *prox; } *topo; } a_pilha; } *

variable_types: ultimo float


EncerraLeilao

decompiled_code:
__int64 __fastcall EncerraLeilao(__int64 a1)
{
__int64 result; // rax
char v2; // al
float v3; // [rsp+4h] [rbp-34h] BYREF
void *ptr; // [rsp+8h] [rbp-30h] BYREF
char v5[40]; // [rsp+10h] [rbp-28h] BYREF

while ( 1 )
{
result = ListaEstaVazia(a1);
if ( (_DWORD)result )
break;
while ( 1 )
{
ListaPop(a1, &ptr);
printf("%s: ", (const char *)ptr);
if ( (unsigned int)PilhaPop((char *)ptr + 32, &v3) == -1 )
break;
FilaRetira(*((_QWORD *)ptr + 4) + 8LL, v5);
printf("Comprador: %s, por R$%.2f\n", v5, v3);
if ( (unsigned int)FilaRetira(*((_QWORD *)ptr + 4) + 8LL, v5) != -1 )
{
printf("Mais pessoas deram o mesmo lance.\nDeseja dividir o produto com %s", v5);
while ( (unsigned int)FilaRetira(*((_QWORD *)ptr + 4) + 8LL, v5) != -1 )
printf(", %s", v5);
printf("? s/n");
do
v2 = getchar();
while ( v2 != 115 && v2 != 110 );
if ( v2 == 110 )
puts("Voce escolheu comprar sozinho. Parabens pela aquisicao!\n");
else
puts("Voce escolheu dividir o premio. Parabens pela aquisicao!\n");
}
PilhaDestroi((char *)ptr + 32);
free(ptr);
result = ListaEstaVazia(a1);
if ( (_DWORD)result )
return result;
}
puts("sem comprador; nenhum lance dado");
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
__int64 result; // rax
char v2; // al
float v3; // [rsp+4h] [rbp-34h] BYREF
void *ptr; // [rsp+8h] [rbp-30h] BYREF
char v5[40]; // [rsp+10h] [rbp-28h] BYREF

while ( 1 )
{
result = ListaEstaVazia(a1);
if ( (_DWORD)result )
break;
while ( 1 )
{
ListaPop(a1, &ptr);
printf("%s: ", (const char *)ptr);
if ( (unsigned int)PilhaPop((char *)ptr + 32, &v3) == -1 )
break;
FilaRetira(*((_QWORD *)ptr + 4) + 8LL, v5);
printf("Comprador: %s, por R$%.2f\n", v5, v3);
if ( (unsigned int)FilaRetira(*((_QWORD *)ptr + 4) + 8LL, v5) != -1 )
{
printf("Mais pessoas deram o mesmo lance.\nDeseja dividir o produto com %s", v5);
while ( (unsigned int)FilaRetira(*((_QWORD *)ptr + 4) + 8LL, v5) != -1 )
printf(", %s", v5);
printf("? s/n");
do
v2 = getchar();
while ( v2 != 115 && v2 != 110 );
if ( v2 == 110 )
puts("Voce escolheu comprar sozinho. Parabens pela aquisicao!\n");
else
puts("Voce escolheu dividir o premio. Parabens pela aquisicao!\n");
}
PilhaDestroi((char *)ptr + 32);
free(ptr);
result = ListaEstaVazia(a1);
if ( (_DWORD)result )
return result;
}
puts("sem comprador; nenhum lance dado");
}
return result;
}

original_code:
void EncerraLeilao (Lista *produtos) {
 elem *aux;
 float lance;
 char nome[30];
 while (!ListaEstaVazia (produtos)) {
  ListaPop (produtos, &aux);
  printf ("%s: ", aux->nome);
  if (PilhaPop (&aux->a_pilha, &lance) == -1) {
   puts ("sem comprador; nenhum lance dado");
  }
  else {
    FilaRetira (&aux->a_pilha.topo->preferencia, nome);
   printf ("Comprador: %s, por R$%.2f\n", nome, lance);
   if (
     FilaRetira (&aux->a_pilha.topo->preferencia, nome)
   != -1) {
    printf ("Mais pessoas deram o mesmo lance.\nDeseja dividir o produto com %s", nome);
    while (
      FilaRetira (&aux->a_pilha.topo->preferencia, nome)
    != -1) {
     printf (", %s", nome);
    }
    printf ("?  s/n");
    char escolha;
    do {
     escolha = getchar ();
    } while (escolha != 's' && escolha != 'n');
    switch (escolha) {
     case 's':
      puts ("Voce escolheu dividir o premio. Parabens pela aquisicao!\n");
      break;
     case 'n':
      puts ("Voce escolheu comprar sozinho. Parabens pela aquisicao!\n");
      break;
    }
   }
   PilhaDestroi (&aux->a_pilha);
   free (aux);
  }
 }
}

canonical_original_code:
void EncerraLeilao(struct Lista *produtos) {
 struct elem *aux;
 float lance;
 char nome[30];
 while (!ListaEstaVazia (produtos)) {
  ListaPop (produtos, &aux);
  printf ("%s: ", aux->nome);
  if (PilhaPop (&aux->a_pilha, &lance) == -1) {
   puts ("sem comprador; nenhum lance dado");
  }
  else {
    FilaRetira (&aux->a_pilha.topo->preferencia, nome);
   printf ("Comprador: %s, por R$%.2f\n", nome, lance);
   if (
     FilaRetira (&aux->a_pilha.topo->preferencia, nome)
   != -1) {
    printf ("Mais pessoas deram o mesmo lance.\nDeseja dividir o produto com %s", nome);
    while (
      FilaRetira (&aux->a_pilha.topo->preferencia, nome)
    != -1) {
     printf (", %s", nome);
    }
    printf ("?  s/n");
    char escolha;
    do {
     escolha = getchar ();
    } while (escolha != 's' && escolha != 'n');
    switch (escolha) {
     case 's':
      puts ("Voce escolheu dividir o premio. Parabens pela aquisicao!\n");
      break;
     case 'n':
      puts ("Voce escolheu comprar sozinho. Parabens pela aquisicao!\n");
      break;
    }
   }
   PilhaDestroi (&aux->a_pilha);
   free (aux);
  }
 }
}

variable_types: lance float

variable_types:
nome
char [30]

variable_types: escolha char


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char v3; // al
char v5; // [rsp+Fh] [rbp-19h] BYREF
char v6[24]; // [rsp+10h] [rbp-18h] BYREF

ListaCria(v6, argv, envp);
LABEL_2:
while ( 1 )
{
v3 = v5;
LABEL_3:
while ( 2 )
{
if ( v3 == 113 )
return 0;
while ( 1 )
{
MostraEscolhas();
_isoc99_scanf(" %c", &v5);
_fpurge(stdin);
puts(&byte_4F0);
v3 = v5;
if ( v5 == 101 )
{
EncerraLeilao((__int64)v6);
goto LABEL_2;
}
if ( v5 > 101 )
break;
if ( v5 == 99 )
{
CadastraProduto((__int64)v6);
goto LABEL_2;
}
if ( v5 != 100 )
goto LABEL_3;
DarLance((__int64)v6);
if ( v5 == 113 )
return 0;
}
if ( v5 != 108 )
continue;
break;
}
ListarProdutos((__int64)v6);
}
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char v3; // al
char v5; // [rsp+Fh] [rbp-19h] BYREF
char v6[24]; // [rsp+10h] [rbp-18h] BYREF

ListaCria(v6, argv, envp);
LABEL_2:
while ( 1 )
{
v3 = v5;
LABEL_3:
while ( 2 )
{
if ( v3 == 113 )
return 0;
while ( 1 )
{
func0();
_isoc99_scanf(" %c", &v5);
_fpurge(stdin);
puts(&byte_4F0);
v3 = v5;
if ( v5 == 101 )
{
func4((__int64)v6);
goto LABEL_2;
}
if ( v5 > 101 )
break;
if ( v5 == 99 )
{
func1((__int64)v6);
goto LABEL_2;
}
if ( v5 != 100 )
goto LABEL_3;
func3((__int64)v6);
if ( v5 == 113 )
return 0;
}
if ( v5 != 108 )
continue;
break;
}
func2((__int64)v6);
}
}

original_code:
int main (int argc, const char * argv[]) {
 char escolha;
 Lista produtos;
 ListaCria (&produtos);
 while (escolha != 'q') {
  MostraEscolhas ();
  scanf (" %c", &escolha);
  __fpurge (stdin);
  puts ("");
  switch (escolha) {
   case 'c':
    CadastraProduto (&produtos);
    break;
   case 'l':
    ListarProdutos (&produtos);
    break;
   case 'd':
    DarLance (&produtos);
    break;
   case 'e':
    EncerraLeilao (&produtos);
    break;
  }
 }
    return 0;
}

canonical_original_code:
int main(int argc, char *argv[]) {
 char escolha;
 struct Lista produtos;
 ListaCria (&produtos);
 while (escolha != 'q') {
  MostraEscolhas ();
  scanf (" %c", &escolha);
  __fpurge (stdin);
  puts ("");
  switch (escolha) {
   case 'c':
    CadastraProduto (&produtos);
    break;
   case 'l':
    ListarProdutos (&produtos);
    break;
   case 'd':
    DarLance (&produtos);
    break;
   case 'e':
    EncerraLeilao (&produtos);
    break;
  }
 }
    return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: struct Lista { struct bloco { struct elem { char nome[30]; struct Pilha { struct pilha_no { float lances; struct fila { struct fila_no { char usuario[30]; struct fila_no *prox; } *ini; } preferencia; struct pilha_no *prox; } *topo; } a_pilha; } info; struct bloco *prox; } *cabeca; int tamanho; }

return_type: int


PilhaCria

decompiled_code:
void __fastcall PilhaCria(__int64 a1)
{
*(_DWORD *)(a1 + 156060) = -1;
}

original_code:
void PilhaCria (Pilha *P) {
 P->topo = -1;
 return;
}

canonical_original_code:
void PilhaCria(struct Pilha *P) {
 P->topo = -1;
 return;
}

variable_types: struct Pilha { float lances[255]; struct fila { char usuario[20][30]; int ini; } preferencia[255]; int topo; } *


PilhaEstaVazia

decompiled_code:
_BOOL8 __fastcall PilhaEstaVazia(__int64 a1)
{
return *(_DWORD *)(a1 + 156060) == -1;
}

original_code:
int PilhaEstaVazia (Pilha *P) {
 if (P->topo == -1)
  return 1;
 else
  return 0;
}

canonical_original_code:
int PilhaEstaVazia(struct Pilha *P) {
 if (P->topo == -1)
  return 1;
 else
  return 0;
}


PilhaEstaCheia

decompiled_code:
_BOOL8 __fastcall PilhaEstaCheia(__int64 a1)
{
return *(_DWORD *)(a1 + 156060) == 255;
}

original_code:
int PilhaEstaCheia (Pilha *P) {
 if (P->topo == 255)
  return 1;
 else
  return 0;
}

canonical_original_code:
int PilhaEstaCheia(struct Pilha *P) {
 if (P->topo == 255)
  return 1;
 else
  return 0;
}


PilhaPush

decompiled_code:
__int64 __fastcall PilhaPush(__int64 a1, int *a2)
{
unsigned int v2; // er12
int v3; // xmm0_4
int v4; // eax

if ( PilhaEstaCheia(a1) )
return (unsigned int)-1;
v2 = 0;
v3 = *a2;
v4 = *(_DWORD *)(a1 + 156060) + 1;
*(_DWORD *)(a1 + 156060) = v4;
*(_DWORD *)(a1 + 4LL * v4) = v3;
FilaCria(a1 + 1020);
return v2;
}

original_code:
int PilhaPush (Pilha *P, float *valorLance) {
 if (PilhaEstaCheia(P))
  return -1;
 else {
  P->topo++;
  P->lances[P->topo] = *valorLance;
  FilaCria(P->preferencia);
 }
 return 0;
}

canonical_original_code:
int PilhaPush(struct Pilha *P, float *valorLance) {
 if (PilhaEstaCheia(P))
  return -1;
 else {
  P->topo++;
  P->lances[P->topo] = *valorLance;
  FilaCria(P->preferencia);
 }
 return 0;
}

variable_types:
valorLance
float *


PilhaPop

decompiled_code:
__int64 __fastcall PilhaPop(__int64 a1, _DWORD *a2)
{
__int64 result; // rax
int v3; // edx

result = PilhaEstaVazia(a1);
if ( (_DWORD)result )
return 0xFFFFFFFFLL;
v3 = *(_DWORD *)(a1 + 156060);
*(_DWORD *)(a1 + 4LL * v3) = *a2;
*(_DWORD *)(a1 + 156060) = v3 - 1;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, _DWORD *a2)
{
__int64 result; // rax
int v3; // edx

result = func1(a1);
if ( (_DWORD)result )
return 0xFFFFFFFFLL;
v3 = *(_DWORD *)(a1 + 156060);
*(_DWORD *)(a1 + 4LL * v3) = *a2;
*(_DWORD *)(a1 + 156060) = v3 - 1;
return result;
}

original_code:
int PilhaPop (Pilha *P, float *valorLance) {
 if (PilhaEstaVazia(P))
  return -1;
 else {
  P->lances[P->topo] = *valorLance;
  P->topo--;
  return 0;
 }
}

canonical_original_code:
int PilhaPop(struct Pilha *P, float *valorLance) {
 if (PilhaEstaVazia(P))
  return -1;
 else {
  P->lances[P->topo] = *valorLance;
  P->topo--;
  return 0;
 }
}


PilhaDestroi

decompiled_code:
// attributes: thunk
void __fastcall PilhaDestroi(__int64 a1)
{
PilhaCria(a1);
}

canonical_decompiled_code:
void __fastcall func6(__int64 a1)
{
func0(a1);
}

original_code:
void PilhaDestroi (Pilha *P) {
 P->topo = -1;
}

canonical_original_code:
void PilhaDestroi(struct Pilha *P) {
 P->topo = -1;
}


PilhaPrint

decompiled_code:
void __fastcall PilhaPrint(__int64 a1)
{
float v1; // [rsp+Ch] [rbp-261ACh] BYREF
char v2[156072]; // [rsp+10h] [rbp-261A8h] BYREF

if ( PilhaEstaVazia(a1) )
{
puts("\tNao ha lances");
}
else
{
PilhaCria((__int64)v2);
while ( !PilhaEstaVazia(a1) )
{
PilhaEspiaTopo(a1, &v1);
printf("R$%.2f\n", v1);
FilaPrint(a1 + 608LL * *(int *)(a1 + 156060) + 1020);
PilhaPop(a1, &v1);
PilhaPush((__int64)v2, (int *)&v1);
}
while ( !PilhaEstaVazia((__int64)v2) )
{
PilhaPop((__int64)v2, &v1);
PilhaPush(a1, (int *)&v1);
}
PilhaCria((__int64)v2);
}
}

original_code:
void PilhaPrint (Pilha *P)
{
 if (PilhaEstaVazia(P)) {
  puts ("\tNao ha lances");
  return ;
 }
 float retorno;
 Pilha aux;
 PilhaCria (&aux);
 while (!PilhaEstaVazia(P)) {
  PilhaEspiaTopo (P, &retorno);
  printf ("R$%.2f\n", retorno);
  FilaPrint(&P->preferencia[P->topo]);
  PilhaPop (P, &retorno);
  PilhaPush(&aux, &retorno);
 }
 while (!PilhaEstaVazia(&aux)) {
  PilhaPop (&aux, &retorno);
  PilhaPush (P, &retorno);
 }
 PilhaDestroi(&aux);
}

canonical_original_code:
void PilhaPrint(struct Pilha *P)
{
 if (PilhaEstaVazia(P)) {
  puts ("\tNao ha lances");
  return ;
 }
 float retorno;
 struct Pilha aux;
 PilhaCria (&aux);
 while (!PilhaEstaVazia(P)) {
  PilhaEspiaTopo (P, &retorno);
  printf ("R$%.2f\n", retorno);
  FilaPrint(&P->preferencia[P->topo]);
  PilhaPop (P, &retorno);
  PilhaPush(&aux, &retorno);
 }
 while (!PilhaEstaVazia(&aux)) {
  PilhaPop (&aux, &retorno);
  PilhaPush (P, &retorno);
 }
 PilhaDestroi(&aux);
}

variable_types: retorno float

variable_types: struct Pilha { float lances[255]; struct fila { char usuario[20][30]; int ini; } preferencia[255]; int topo; }


PilhaCopia

decompiled_code:
__int64 __fastcall PilhaCopia(__int64 a1, __int64 a2)
{
unsigned int v2; // er12
int v4; // [rsp+Ch] [rbp-261BCh] BYREF
char v5[156088]; // [rsp+10h] [rbp-261B8h] BYREF

if ( PilhaEstaVazia(a2) )
return (unsigned int)-1;
v2 = 0;
PilhaCria((__int64)v5);
while ( !PilhaEstaVazia(a2) )
{
PilhaPop(a2, &v4);
PilhaPush((__int64)v5, &v4);
}
while ( !PilhaEstaVazia((__int64)v5) )
{
PilhaPop((__int64)v5, &v4);
PilhaPush(a1, &v4);
PilhaPush(a2, &v4);
}
PilhaCria((__int64)v5);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, __int64 a2)
{
unsigned int v2; // er12
int v4; // [rsp+Ch] [rbp-261BCh] BYREF
char v5[156088]; // [rsp+10h] [rbp-261B8h] BYREF

if ( func1(a2) )
return (unsigned int)-1;
v2 = 0;
func0((__int64)v5);
while ( !func1(a2) )
{
func4(a2, &v4);
func3((__int64)v5, &v4);
}
while ( !func1((__int64)v5) )
{
func4((__int64)v5, &v4);
func3(a1, &v4);
func3(a2, &v4);
}
func0((__int64)v5);
return v2;
}

original_code:
int PilhaCopia (Pilha *P1, Pilha *P2) {
    if (PilhaEstaVazia(P2))
        return -1;
 float retorno;
    Pilha aux;
    PilhaCria (&aux);
 while (!PilhaEstaVazia(P2)) {
  PilhaPop (P2, &retorno);
  PilhaPush(&aux, &retorno);
 }
 while (!PilhaEstaVazia(&aux)) {
    PilhaPop(&aux, &retorno);
    PilhaPush(P1, &retorno);
    PilhaPush(P2, &retorno);
 }
 PilhaDestroi (&aux);
 return 0;
}

canonical_original_code:
int PilhaCopia(struct Pilha *P1, struct Pilha *P2) {
    if (PilhaEstaVazia(P2))
        return -1;
 float retorno;
    struct Pilha aux;
    PilhaCria (&aux);
 while (!PilhaEstaVazia(P2)) {
  PilhaPop (P2, &retorno);
  PilhaPush(&aux, &retorno);
 }
 while (!PilhaEstaVazia(&aux)) {
    PilhaPop(&aux, &retorno);
    PilhaPush(P1, &retorno);
    PilhaPush(P2, &retorno);
 }
 PilhaDestroi (&aux);
 return 0;
}


Circular

decompiled_code:
__int64 __fastcall Circular(int a1)
{
return (unsigned int)(a1 % 20);
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
return (unsigned int)(a1 % 20);
}

original_code:
int Circular (int x) {
 return x % 20;
}

canonical_original_code:
int Circular(int x) {
 return x % 20;
}

variable_types: x int


FilaCria

decompiled_code:
void __fastcall FilaCria(__int64 a1)
{
*(_QWORD *)(a1 + 600) = -1LL;
}

canonical_decompiled_code:
void __fastcall func1(__int64 a1)
{
*(_QWORD *)(a1 + 600) = -1LL;
}

original_code:
void FilaCria (Fila *F) {
 F->ini = -1;
 F->fim = -1;
}

canonical_original_code:
void FilaCria(struct fila *F) {
 F->ini = -1;
 F->fim = -1;
}

variable_types: struct fila { char usuario[20][30]; int ini; } *


FilaEstaVazia

decompiled_code:
_BOOL8 __fastcall FilaEstaVazia(__int64 a1)
{
return *(_DWORD *)(a1 + 600) == -1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(__int64 a1)
{
return *(_DWORD *)(a1 + 600) == -1;
}

original_code:
int FilaEstaVazia (Fila *F) {
 return F->ini == -1;
}

canonical_original_code:
int FilaEstaVazia(struct fila *F) {
 return F->ini == -1;
}


FilaEstaCheia

decompiled_code:
_BOOL8 __fastcall FilaEstaCheia(__int64 a1)
{
int v1; // eax
__int64 v2; // rcx

v1 = Circular(*(_DWORD *)(a1 + 604) + 1);
return *(_DWORD *)(v2 + 600) == v1;
}

original_code:
int FilaEstaCheia (Fila *F) {
 return F->ini == Circular (F->fim + 1);
}

canonical_original_code:
int FilaEstaCheia(struct fila *F) {
 return F->ini == Circular (F->fim + 1);
}


FilaInsere

decompiled_code:
__int64 __fastcall FilaInsere(__int64 a1, const char *a2)
{
int v2; // eax
__int64 result; // rax

if ( FilaEstaCheia(a1) )
return 0xFFFFFFFFLL;
v2 = Circular(*(_DWORD *)(a1 + 604) + 1);
*(_DWORD *)(a1 + 604) = v2;
strcpy((char *)(a1 + 30LL * v2), a2);
result = FilaEstaVazia(a1);
if ( (_DWORD)result )
{
*(_DWORD *)(a1 + 600) = *(_DWORD *)(a1 + 604);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, const char *a2)
{
int v2; // eax
__int64 result; // rax

if ( func3(a1) )
return 0xFFFFFFFFLL;
v2 = func0(*(_DWORD *)(a1 + 604) + 1);
*(_DWORD *)(a1 + 604) = v2;
strcpy((char *)(a1 + 30LL * v2), a2);
result = func2(a1);
if ( (_DWORD)result )
{
*(_DWORD *)(a1 + 600) = *(_DWORD *)(a1 + 604);
result = 0LL;
}
return result;
}

original_code:
int FilaInsere (Fila *F, const char *nome) {
 if (FilaEstaCheia (F))
  return -1;
 else {
  F->fim = Circular (F->fim + 1);
  strcpy (F->usuario[F->fim], nome);
  if (FilaEstaVazia (F))
   F->ini = F->fim;
  return 0;
 }
}

canonical_original_code:
int FilaInsere(struct fila *F, char *nome) {
 if (FilaEstaCheia (F))
  return -1;
 else {
  F->fim = Circular (F->fim + 1);
  strcpy (F->usuario[F->fim], nome);
  if (FilaEstaVazia (F))
   F->ini = F->fim;
  return 0;
 }
}

variable_types:
nome
char *


FilaRetira

decompiled_code:
__int64 __fastcall FilaRetira(__int64 a1, char *a2)
{
_BOOL4 v2; // er9
__int64 result; // rax
int v4; // er8
int v5; // ecx

v2 = FilaEstaVazia(a1);
result = 0xFFFFFFFFLL;
if ( !v2 )
{
strcpy(a2, (const char *)(a1 + 30LL * *(int *)(a1 + 600)));
*(_DWORD *)(a1 + 600) = Circular(*(_DWORD *)(a1 + 600) + 1);
v4 = Circular(*(_DWORD *)(a1 + 604) + 1);
result = 1LL;
if ( v5 == v4 )
*(_DWORD *)(a1 + 600) = -1;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, char *a2)
{
_BOOL4 v2; // er9
__int64 result; // rax
int v4; // er8
int v5; // ecx

v2 = func2(a1);
result = 0xFFFFFFFFLL;
if ( !v2 )
{
strcpy(a2, (const char *)(a1 + 30LL * *(int *)(a1 + 600)));
*(_DWORD *)(a1 + 600) = func0(*(_DWORD *)(a1 + 600) + 1);
v4 = func0(*(_DWORD *)(a1 + 604) + 1);
result = 1LL;
if ( v5 == v4 )
*(_DWORD *)(a1 + 600) = -1;
}
return result;
}

original_code:
int FilaRetira (Fila *F, char *nome) {
 if (FilaEstaVazia (F))
  return -1;
 else {
  strcpy (nome, F->usuario[F->ini]);
  F->ini = Circular (F->ini + 1);
  if (F->ini == Circular (F->fim + 1))
   F->ini = -1;
  return 1;
 }
}

canonical_original_code:
int FilaRetira(struct fila *F, char *nome) {
 if (FilaEstaVazia (F))
  return -1;
 else {
  strcpy (nome, F->usuario[F->ini]);
  F->ini = Circular (F->ini + 1);
  if (F->ini == Circular (F->fim + 1))
   F->ini = -1;
  return 1;
 }
}


FilaCopia

decompiled_code:
__int64 __fastcall FilaCopia(__int64 a1, __int64 a2)
{
unsigned int v2; // er12
char v4[32]; // [rsp+0h] [rbp-298h] BYREF
char v5[632]; // [rsp+20h] [rbp-278h] BYREF

if ( FilaEstaVazia(a2) )
return (unsigned int)-1;
v2 = 0;
FilaCria(a1);
FilaCria((__int64)v5);
while ( !FilaEstaVazia(a2) )
{
FilaRetira(a2, v4);
FilaInsere((__int64)v5, v4);
}
while ( !FilaEstaVazia((__int64)v5) )
{
FilaRetira((__int64)v5, v4);
FilaInsere(a1, v4);
FilaInsere(a2, v4);
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 a2)
{
unsigned int v2; // er12
char v4[32]; // [rsp+0h] [rbp-298h] BYREF
char v5[632]; // [rsp+20h] [rbp-278h] BYREF

if ( func2(a2) )
return (unsigned int)-1;
v2 = 0;
func1(a1);
func1((__int64)v5);
while ( !func2(a2) )
{
func5(a2, v4);
func4((__int64)v5, v4);
}
while ( !func2((__int64)v5) )
{
func5((__int64)v5, v4);
func4(a1, v4);
func4(a2, v4);
}
return v2;
}

original_code:
int FilaCopia (Fila *destiny, Fila *source) {
 if (FilaEstaVazia (source))
  return -1;
 else {
  FilaDestroi (destiny);
  Fila aux;
  FilaCria (&aux);
  char nome[30];
  while (!FilaEstaVazia (source)) {
   FilaRetira (source, nome);
   FilaInsere (&aux, nome);
  }
  while (!FilaEstaVazia (&aux)) {
   FilaRetira (&aux, nome);
   FilaInsere (destiny, nome);
   FilaInsere (source, nome);
  }
  return 0;
 }
}

canonical_original_code:
int FilaCopia(struct fila *destiny, struct fila *source) {
 if (FilaEstaVazia (source))
  return -1;
 else {
  FilaDestroi (destiny);
  struct fila aux;
  FilaCria (&aux);
  char nome[30];
  while (!FilaEstaVazia (source)) {
   FilaRetira (source, nome);
   FilaInsere (&aux, nome);
  }
  while (!FilaEstaVazia (&aux)) {
   FilaRetira (&aux, nome);
   FilaInsere (destiny, nome);
   FilaInsere (source, nome);
  }
  return 0;
 }
}

variable_types:
source
struct fila *

variable_types: struct fila { char usuario[20][30]; int ini; }


FilaPrint

decompiled_code:
void __fastcall FilaPrint(__int64 a1)
{
char v1[32]; // [rsp+0h] [rbp-288h] BYREF
char v2[616]; // [rsp+20h] [rbp-268h] BYREF

if ( FilaEstaVazia(a1) )
{
puts("Fila Vazia");
}
else
{
FilaCria((__int64)v2);
while ( !FilaEstaVazia(a1) )
{
FilaRetira(a1, v1);
printf("%s", v1);
FilaInsere((__int64)v2, v1);
}
puts(&s);
while ( !FilaEstaVazia((__int64)v2) )
{
FilaRetira((__int64)v2, v1);
FilaInsere(a1, v1);
}
FilaCria((__int64)v2);
}
}

original_code:
void FilaPrint (Fila *F) {
 if (FilaEstaVazia (F)) {
  puts ("Fila Vazia");
  return;
 }
 else {
  Fila aux;
  FilaCria (&aux);
  char nome[30];
  while (!FilaEstaVazia (F)) {
   FilaRetira (F, nome);
   printf ("%s", nome);
   FilaInsere (&aux, nome);
  }
  puts ("");
  while (!FilaEstaVazia (&aux)) {
   FilaRetira (&aux, nome);
   FilaInsere (F, nome);
  }
  FilaDestroi (&aux);
 }
}

canonical_original_code:
void FilaPrint(struct fila *F) {
 if (FilaEstaVazia (F)) {
  puts ("Fila Vazia");
  return;
 }
 else {
  struct fila aux;
  FilaCria (&aux);
  char nome[30];
  while (!FilaEstaVazia (F)) {
   FilaRetira (F, nome);
   printf ("%s", nome);
   FilaInsere (&aux, nome);
  }
  puts ("");
  while (!FilaEstaVazia (&aux)) {
   FilaRetira (&aux, nome);
   FilaInsere (F, nome);
  }
  FilaDestroi (&aux);
 }
}


FilaDestroi

decompiled_code:
// attributes: thunk
void __fastcall FilaDestroi(__int64 a1)
{
FilaCria(a1);
}

canonical_decompiled_code:
void __fastcall func8(__int64 a1)
{
func1(a1);
}

original_code:
void FilaDestroi (Fila *F) {
 F->ini = -1;
 F->fim = -1;
}

canonical_original_code:
void FilaDestroi(struct fila *F) {
 F->ini = -1;
 F->fim = -1;
}


textbackground

repo: gin/kohi

decompiled_code:
int __fastcall textbackground(unsigned int a1)
{
unsigned int v1; // er12
unsigned int v2; // eax
__int64 v3; // rsi
__int64 v4; // rsi
int result; // eax

v1 = a1;
_fpurge(stdin);
v2 = a1 - 10;
if ( a1 <= 7 )
{
if ( v2 > 7 )
goto LABEL_9;
}
else if ( v2 > 7 )
{
v3 = (unsigned int)_color;
v1 = 9;
_background = 9;
if ( (unsigned int)_color > 7 )
goto LABEL_4;
return printf("\x1B[0;3%d;4%dm", v3, v1);
}
v1 = a1 - 10;
LABEL_9:
v3 = (unsigned int)_color;
_background = v1;
if ( (unsigned int)_color <= 7 )
return printf("\x1B[0;3%d;4%dm", v3, v1);
LABEL_4:
v4 = (unsigned int)(v3 - 10);
if ( (unsigned int)v4 > 7 )
result = printf("\x1B[0;3%d;4%dm", 9LL, v1);
else
result = printf("\x1B[1;3%d;4%dm", v4, v1);
return result;
}

canonical_decompiled_code:
int __fastcall func0(unsigned int a1)
{
unsigned int v1; // er12
unsigned int v2; // eax
__int64 v3; // rsi
__int64 v4; // rsi
int result; // eax

v1 = a1;
_fpurge(stdin);
v2 = a1 - 10;
if ( a1 <= 7 )
{
if ( v2 > 7 )
goto LABEL_9;
}
else if ( v2 > 7 )
{
v3 = (unsigned int)_color;
v1 = 9;
_background = 9;
if ( (unsigned int)_color > 7 )
goto LABEL_4;
return printf("\x1B[0;3%d;4%dm", v3, v1);
}
v1 = a1 - 10;
LABEL_9:
v3 = (unsigned int)_color;
_background = v1;
if ( (unsigned int)_color <= 7 )
return printf("\x1B[0;3%d;4%dm", v3, v1);
LABEL_4:
v4 = (unsigned int)(v3 - 10);
if ( (unsigned int)v4 > 7 )
result = printf("\x1B[0;3%d;4%dm", 9LL, v1);
else
result = printf("\x1B[1;3%d;4%dm", v4, v1);
return result;
}

original_code:
void textbackground(const int background_)
{
 __fpurge(stdin);
 __background = background_;
 if (((background_ >= 0) && (background_ <= 7)) || ((background_ >= 10) && (background_ <= 17)))
 {
  if ((background_ >= 10) && (background_ <= 17))
   __background = (background_ - 10);
 }
 else
 {
  __background = 9;
 }
 if ((__color >= 0) && (__color <= 7))
 {
  printf("\033[0;3%d;4%dm",__color,__background);
 }
 else
 {
  if ((__color >= 10) && (__color <= 17))
   printf("\033[1;3%d;4%dm",(__color - 10),__background);
  else
   printf("\033[0;3%d;4%dm",9,__background);
 }
}

canonical_original_code:
void textbackground(int background_)
{
 __fpurge(stdin);
 __background = background_;
 if (((background_ >= 0) && (background_ <= 7)) || ((background_ >= 10) && (background_ <= 17)))
 {
  if ((background_ >= 10) && (background_ <= 17))
   __background = (background_ - 10);
 }
 else
 {
  __background = 9;
 }
 if ((__color >= 0) && (__color <= 7))
 {
  printf("\033[0;3%d;4%dm",__color,__background);
 }
 else
 {
  if ((__color >= 10) && (__color <= 17))
   printf("\033[1;3%d;4%dm",(__color - 10),__background);
  else
   printf("\033[0;3%d;4%dm",9,__background);
 }
}


textcolor

decompiled_code:
int __fastcall textcolor(unsigned int a1)
{
__int64 v1; // rsi
int result; // eax

_fpurge(stdin);
_color = a1;
if ( a1 <= 7 )
return printf("\x1B[0;3%d;4%dm", a1, (unsigned int)_background);
v1 = a1 - 10;
if ( (unsigned int)v1 > 7 )
result = printf("\x1B[0;3%d;4%dm", 9LL, (unsigned int)_background);
else
result = printf("\x1B[1;3%d;4%dm", v1, (unsigned int)_background);
return result;
}

canonical_decompiled_code:
int __fastcall func1(unsigned int a1)
{
__int64 v1; // rsi
int result; // eax

_fpurge(stdin);
_color = a1;
if ( a1 <= 7 )
return printf("\x1B[0;3%d;4%dm", a1, (unsigned int)_background);
v1 = a1 - 10;
if ( (unsigned int)v1 > 7 )
result = printf("\x1B[0;3%d;4%dm", 9LL, (unsigned int)_background);
else
result = printf("\x1B[1;3%d;4%dm", v1, (unsigned int)_background);
return result;
}

original_code:
void textcolor(const int color_)
{
 __fpurge(stdin);
 __color = color_;
 if ((__color >= 0) && (__color <= 7))
 {
  printf("\033[0;3%d;4%dm",__color,__background);
 }
 else
 {
  if ((__color >= 10) && (__color <= 17))
   printf("\033[1;3%d;4%dm",(__color - 10),__background);
  else
   printf("\033[0;3%d;4%dm",9,__background);
 }
}

canonical_original_code:
void textcolor(int color_)
{
 __fpurge(stdin);
 __color = color_;
 if ((__color >= 0) && (__color <= 7))
 {
  printf("\033[0;3%d;4%dm",__color,__background);
 }
 else
 {
  if ((__color >= 10) && (__color <= 17))
   printf("\033[1;3%d;4%dm",(__color - 10),__background);
  else
   printf("\033[0;3%d;4%dm",9,__background);
 }
}


gotoxy

decompiled_code:
int __fastcall gotoxy(int a1, int a2)
{
__int64 v3; // rsi
__int64 v4; // rdx

_fpurge(stdin);
v3 = 0LL;
v4 = (unsigned int)a1;
if ( a1 < 0 )
v4 = 0LL;
if ( a2 >= 0 )
v3 = (unsigned int)a2;
return printf("\x1B[%d;%df", v3, v4);
}

canonical_decompiled_code:
int __fastcall func2(int a1, int a2)
{
__int64 v3; // rsi
__int64 v4; // rdx

_fpurge(stdin);
v3 = 0LL;
v4 = (unsigned int)a1;
if ( a1 < 0 )
v4 = 0LL;
if ( a2 >= 0 )
v3 = (unsigned int)a2;
return printf("\x1B[%d;%df", v3, v4);
}

original_code:
void gotoxy(int x_, int y_)
{
 if (x_ < 0)
  x_ = 0;
 if (y_ < 0)
  y_ = 0;
 __fpurge(stdin);
 printf("\033[%d;%df", y_, x_);
}


clrscr

decompiled_code:
int clrscr()
{
_fpurge(stdin);
return printf("\x1B[2J\x1B[1;1H");
}

canonical_decompiled_code:
int func3()
{
_fpurge(stdin);
return printf("\x1B[2J\x1B[1;1H");
}

original_code:
void clrscr()
{
 __fpurge(stdin);
 printf("\033[2J\033[1;1H");
}


clrline

decompiled_code:
int clrline()
{
_fpurge(stdin);
return printf("\x1B[K");
}

canonical_decompiled_code:
int func4()
{
_fpurge(stdin);
return printf("\x1B[K");
}

original_code:
void clrline()
{
 __fpurge(stdin);
 printf("\033[K");
}


getch

decompiled_code:
__int64 getch()
{
__m128i v0; // xmm0
__m128i v1; // xmm2
unsigned int v2; // ebx
struct termios v4; // [rsp+0h] [rbp-88h] BYREF
struct termios termios_p; // [rsp+40h] [rbp-48h] BYREF

tcgetattr(0, &v4);
v0 = _mm_loadu_si128((const __m128i *)&v4);
v1 = _mm_loadu_si128((const __m128i *)&v4.c_cc[15]);
*(__m128i *)&termios_p.c_line = _mm_loadu_si128((const __m128i *)&v4.c_line);
*(_QWORD *)&termios_p.c_cc[31] = *(_QWORD *)&v4.c_cc[31];
*(__m128i *)&termios_p.c_iflag = v0;
termios_p.c_ospeed = v4.c_ospeed;
*(__m128i *)&termios_p.c_cc[15] = v1;
termios_p.c_lflag = -11;
*(_WORD *)&termios_p.c_cc[5] = 256;
tcsetattr(0, 0, &termios_p);
_fpurge(stdin);
v2 = getchar();
tcsetattr(0, 0, &v4);
return v2;
}

canonical_decompiled_code:
__int64 func5()
{
__m128i v0; // xmm0
__m128i v1; // xmm2
unsigned int v2; // ebx
struct termios v4; // [rsp+0h] [rbp-88h] BYREF
struct termios termios_p; // [rsp+40h] [rbp-48h] BYREF

tcgetattr(0, &v4);
v0 = _mm_loadu_si128((const __m128i *)&v4);
v1 = _mm_loadu_si128((const __m128i *)&v4.c_cc[15]);
*(__m128i *)&termios_p.c_line = _mm_loadu_si128((const __m128i *)&v4.c_line);
*(_QWORD *)&termios_p.c_cc[31] = *(_QWORD *)&v4.c_cc[31];
*(__m128i *)&termios_p.c_iflag = v0;
termios_p.c_ospeed = v4.c_ospeed;
*(__m128i *)&termios_p.c_cc[15] = v1;
termios_p.c_lflag = -11;
*(_WORD *)&termios_p.c_cc[5] = 256;
tcsetattr(0, 0, &termios_p);
_fpurge(stdin);
v2 = getchar();
tcsetattr(0, 0, &v4);
return v2;
}

original_code:
char getch()
{
struct termios SET_STORED;
struct termios SET_NEW;
char c;
 tcgetattr(0, &SET_STORED);
 SET_NEW = SET_STORED;
 SET_NEW.c_lflag = ~(0000010|0000002);
 SET_NEW.c_cc[5] = 0;
 SET_NEW.c_cc[6] = 1;
 tcsetattr(0, 0, &SET_NEW);
 __fpurge(stdin);
 c = getchar();
 tcsetattr(0, 0, &SET_STORED);
return c;
}

variable_types: struct termios { unsigned int c_iflag; unsigned int c_oflag; unsigned int c_cflag; unsigned int c_lflag; unsigned char c_line; unsigned char c_cc[32]; unsigned int c_ispeed; unsigned int c_ospeed; }

variable_types: c char

return_type: char


getche

decompiled_code:
__int64 getche()
{
__m128i v0; // xmm0
__m128i v1; // xmm2
unsigned int v2; // ebx
struct termios v4; // [rsp+0h] [rbp-88h] BYREF
struct termios termios_p; // [rsp+40h] [rbp-48h] BYREF

tcgetattr(0, &v4);
v0 = _mm_loadu_si128((const __m128i *)&v4);
v1 = _mm_loadu_si128((const __m128i *)&v4.c_cc[15]);
*(__m128i *)&termios_p.c_line = _mm_loadu_si128((const __m128i *)&v4.c_line);
*(_QWORD *)&termios_p.c_cc[31] = *(_QWORD *)&v4.c_cc[31];
*(__m128i *)&termios_p.c_iflag = v0;
termios_p.c_ospeed = v4.c_ospeed;
*(__m128i *)&termios_p.c_cc[15] = v1;
termios_p.c_lflag = -3;
*(_WORD *)&termios_p.c_cc[5] = 256;
tcsetattr(0, 0, &termios_p);
_fpurge(stdin);
v2 = getchar();
tcsetattr(0, 0, &v4);
return v2;
}

canonical_decompiled_code:
__int64 func6()
{
__m128i v0; // xmm0
__m128i v1; // xmm2
unsigned int v2; // ebx
struct termios v4; // [rsp+0h] [rbp-88h] BYREF
struct termios termios_p; // [rsp+40h] [rbp-48h] BYREF

tcgetattr(0, &v4);
v0 = _mm_loadu_si128((const __m128i *)&v4);
v1 = _mm_loadu_si128((const __m128i *)&v4.c_cc[15]);
*(__m128i *)&termios_p.c_line = _mm_loadu_si128((const __m128i *)&v4.c_line);
*(_QWORD *)&termios_p.c_cc[31] = *(_QWORD *)&v4.c_cc[31];
*(__m128i *)&termios_p.c_iflag = v0;
termios_p.c_ospeed = v4.c_ospeed;
*(__m128i *)&termios_p.c_cc[15] = v1;
termios_p.c_lflag = -3;
*(_WORD *)&termios_p.c_cc[5] = 256;
tcsetattr(0, 0, &termios_p);
_fpurge(stdin);
v2 = getchar();
tcsetattr(0, 0, &v4);
return v2;
}

original_code:
char getche()
{
struct termios SET_STORED;
struct termios SET_NEW;
char c;
 tcgetattr(0, &SET_STORED);
 SET_NEW = SET_STORED;
 SET_NEW.c_lflag = ~(0000002);
 SET_NEW.c_cc[5] = 0;
 SET_NEW.c_cc[6] = 1;
 tcsetattr(0, 0, &SET_NEW);
 __fpurge(stdin);
 c = getchar();
 tcsetattr(0, 0, &SET_STORED);
return c;
}

user_defined_types: struct termios { unsigned int c_iflag; unsigned int c_oflag; unsigned int c_cflag; unsigned int c_lflag; unsigned char c_line; unsigned char c_cc[32]; unsigned int c_ispeed; unsigned int c_ospeed; }


DisplayCallback

repo: giomasce/dvbt

decompiled_code:
__int64 DisplayCallback()
{
glClear();
if ( (unsigned int)glGetError() )
__assert_fail("glGetError() == 0", "vga_simple.c", 0x13u, "DisplayCallback");
glColor3d();
if ( (unsigned int)glGetError() )
__assert_fail("glGetError() == 0", "vga_simple.c", 0x18u, "DisplayCallback");
glBegin();
glVertex2d();
glVertex2d();
glVertex2d();
glVertex2d();
glEnd();
if ( (unsigned int)glGetError() )
__assert_fail("glGetError() == 0", "vga_simple.c", 0x1Fu, "DisplayCallback");
glutSwapBuffers();
++frames;
return glutPostRedisplay();
}

canonical_decompiled_code:
__int64 func7()
{
glClear();
if ( (unsigned int)glGetError() )
__assert_fail("glGetError() == 0", "vga_simple.c", 0x13u, "DisplayCallback");
glColor3d();
if ( (unsigned int)glGetError() )
__assert_fail("glGetError() == 0", "vga_simple.c", 0x18u, "DisplayCallback");
glBegin();
glVertex2d();
glVertex2d();
glVertex2d();
glVertex2d();
glEnd();
if ( (unsigned int)glGetError() )
__assert_fail("glGetError() == 0", "vga_simple.c", 0x1Fu, "DisplayCallback");
glutSwapBuffers();
++frames;
return glutPostRedisplay();
}

original_code:
void DisplayCallback() {
  glClear(0x00004000);
  ((void) sizeof ((glGetError() == 0) ? 1 : 0), __extension__ ({ if (glGetError() == 0) ; else __assert_fail ("glGetError() == 0", "vga_simple.c", 19, __extension__ __PRETTY_FUNCTION__); }));
  double color = (double) (frames % colors) / (colors-1);
  glColor3d(color, color, color);
  ((void) sizeof ((glGetError() == 0) ? 1 : 0), __extension__ ({ if (glGetError() == 0) ; else __assert_fail ("glGetError() == 0", "vga_simple.c", 24, __extension__ __PRETTY_FUNCTION__); }));
  glBegin(0x0007);
  glVertex2d(-1.0, -1.0);
  glVertex2d(1.0, -1.0);
  glVertex2d(1.0, 1.0);
  glVertex2d(-1.0, 1.0);
  glEnd();
  ((void) sizeof ((glGetError() == 0) ? 1 : 0), __extension__ ({ if (glGetError() == 0) ; else __assert_fail ("glGetError() == 0", "vga_simple.c", 31, __extension__ __PRETTY_FUNCTION__); }));
  glutSwapBuffers();
  frames++;
  glutPostRedisplay();
}

variable_types: color double


KeyboardCallback

decompiled_code:
void __fastcall KeyboardCallback(char a1)
{
if ( (a1 & 0xDF) == 88 )
exit(0);
}

canonical_decompiled_code:
void __fastcall func8(char a1)
{
if ( (a1 & 0xDF) == 88 )
exit(0);
}

original_code:
void KeyboardCallback(unsigned char key, int x, int y) {
  if (key == 'x' || key == 'X') {
    exit(0);
  }
}

variable_types:
key
unsigned char

variable_types: y int


ReshapeCallback

decompiled_code:
__int64 ReshapeCallback()
{
return glViewport();
}

canonical_decompiled_code:
__int64 func9()
{
return glViewport();
}

original_code:
void ReshapeCallback(int w, int h) {
  glViewport(0, 0, w, h);
}

variable_types: w int

variable_types: h int


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int result; // eax
const char *v4; // rax

glutInit();
glutInitDisplayMode();
glutCreateWindow();
glutFullScreen();
glutDisplayFunc();
glutKeyboardFunc();
glutReshapeFunc();
if ( (unsigned int)glewInit() )
{
v4 = (const char *)glewGetErrorString();
fprintf(stderr, "Error: '%s'\n", v4);
result = 1;
}
else if ( _GLXEW_SGI_swap_control )
{
_glewXSwapIntervalSGI(1LL, argv);
if ( (unsigned int)glGetError() )
__assert_fail("glGetError() == 0", "vga_simple.c", 0x4Fu, "main");
glClearColor();
if ( (unsigned int)glGetError() )
__assert_fail("glGetError() == 0", "vga_simple.c", 0x57u, "main");
glMatrixMode();
if ( (unsigned int)glGetError() )
__assert_fail("glGetError() == 0", "vga_simple.c", 0x59u, "main");
glLoadIdentity();
if ( (unsigned int)glGetError() )
__assert_fail("glGetError() == 0", "vga_simple.c", 0x5Bu, "main");
glMatrixMode();
if ( (unsigned int)glGetError() )
__assert_fail("glGetError() == 0", "vga_simple.c", 0x5Du, "main");
glLoadIdentity();
if ( (unsigned int)glGetError() )
__assert_fail("glGetError() == 0", "vga_simple.c", 0x5Fu, "main");
glutMainLoop();
result = 0;
}
else
{
puts("Extension GLX_SGI_swap_control not found, aborting...");
result = 1;
}
return result;
}

original_code:
int main(int argc, char** argv) {
  glutInit(&argc, argv);
  glutInitDisplayMode(0x0002 | 0x0000);
  glutCreateWindow("");
  glutFullScreen();
  glutDisplayFunc(DisplayCallback);
  glutKeyboardFunc(KeyboardCallback);
  glutReshapeFunc(ReshapeCallback);
  GLenum res = glewInit();
  if (res != 0) {
    fprintf(stderr, "Error: '%s'\n", glewGetErrorString(res));
    return 1;
  }
  if ((*(const GLboolean*)&__GLXEW_SGI_swap_control)) {
    __glewXSwapIntervalSGI(1);
    ((void) sizeof ((glGetError() == 0) ? 1 : 0), __extension__ ({ if (glGetError() == 0) ; else __assert_fail ("glGetError() == 0", "vga_simple.c", 79, __extension__ __PRETTY_FUNCTION__); }));
  } else {
    printf("Extension GLX_SGI_swap_control not found, aborting...\n");
    return 1;
  }
  glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
  ((void) sizeof ((glGetError() == 0) ? 1 : 0), __extension__ ({ if (glGetError() == 0) ; else __assert_fail ("glGetError() == 0", "vga_simple.c", 87, __extension__ __PRETTY_FUNCTION__); }));
  glMatrixMode(0x1701);
  ((void) sizeof ((glGetError() == 0) ? 1 : 0), __extension__ ({ if (glGetError() == 0) ; else __assert_fail ("glGetError() == 0", "vga_simple.c", 89, __extension__ __PRETTY_FUNCTION__); }));
  glLoadIdentity();
  ((void) sizeof ((glGetError() == 0) ? 1 : 0), __extension__ ({ if (glGetError() == 0) ; else __assert_fail ("glGetError() == 0", "vga_simple.c", 91, __extension__ __PRETTY_FUNCTION__); }));
  glMatrixMode(0x1700);
  ((void) sizeof ((glGetError() == 0) ? 1 : 0), __extension__ ({ if (glGetError() == 0) ; else __assert_fail ("glGetError() == 0", "vga_simple.c", 93, __extension__ __PRETTY_FUNCTION__); }));
  glLoadIdentity();
  ((void) sizeof ((glGetError() == 0) ? 1 : 0), __extension__ ({ if (glGetError() == 0) ; else __assert_fail ("glGetError() == 0", "vga_simple.c", 95, __extension__ __PRETTY_FUNCTION__); }));
  glutMainLoop();
  return 0;
}

canonical_original_code:
int main(int argc, char **argv) {
  glutInit(&argc, argv);
  glutInitDisplayMode(0x0002 | 0x0000);
  glutCreateWindow("");
  glutFullScreen();
  glutDisplayFunc(DisplayCallback);
  glutKeyboardFunc(KeyboardCallback);
  glutReshapeFunc(ReshapeCallback);
  unsigned int res = glewInit();
  if (res != 0) {
    fprintf(stderr, "Error: '%s'\n", glewGetErrorString(res));
    return 1;
  }
  if ((*(unsigned char *)&__GLXEW_SGI_swap_control)) {
    __glewXSwapIntervalSGI(1);
    ((void) sizeof ((glGetError() == 0) ? 1 : 0), __extension__ ({ if (glGetError() == 0) ; else __assert_fail ("glGetError() == 0", "vga_simple.c", 79, __extension__ __PRETTY_FUNCTION__); }));
  } else {
    printf("Extension GLX_SGI_swap_control not found, aborting...\n");
    return 1;
  }
  glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
  ((void) sizeof ((glGetError() == 0) ? 1 : 0), __extension__ ({ if (glGetError() == 0) ; else __assert_fail ("glGetError() == 0", "vga_simple.c", 87, __extension__ __PRETTY_FUNCTION__); }));
  glMatrixMode(0x1701);
  ((void) sizeof ((glGetError() == 0) ? 1 : 0), __extension__ ({ if (glGetError() == 0) ; else __assert_fail ("glGetError() == 0", "vga_simple.c", 89, __extension__ __PRETTY_FUNCTION__); }));
  glLoadIdentity();
  ((void) sizeof ((glGetError() == 0) ? 1 : 0), __extension__ ({ if (glGetError() == 0) ; else __assert_fail ("glGetError() == 0", "vga_simple.c", 91, __extension__ __PRETTY_FUNCTION__); }));
  glMatrixMode(0x1700);
  ((void) sizeof ((glGetError() == 0) ? 1 : 0), __extension__ ({ if (glGetError() == 0) ; else __assert_fail ("glGetError() == 0", "vga_simple.c", 93, __extension__ __PRETTY_FUNCTION__); }));
  glLoadIdentity();
  ((void) sizeof ((glGetError() == 0) ? 1 : 0), __extension__ ({ if (glGetError() == 0) ; else __assert_fail ("glGetError() == 0", "vga_simple.c", 95, __extension__ __PRETTY_FUNCTION__); }));
  glutMainLoop();
  return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types:
res
unsigned int


decompiled_code:
void *tps_decoder_new()
{
return calloc(0x38uLL, 1uLL);
}

canonical_decompiled_code:
void *func0()
{
return calloc(0x38uLL, 1uLL);
}

original_code:
TPSDecoder *tps_decoder_new() {
  TPSDecoder *dec = malloc(sizeof(TPSDecoder));
  bzero(dec, sizeof(TPSDecoder));
  return dec;
}

canonical_original_code:
struct TPSDecoder *tps_decoder_new() {
  struct TPSDecoder *dec = malloc(sizeof(TPSDecoder));
  bzero(dec, sizeof(TPSDecoder));
  return dec;
}

variable_types: struct TPSDecoder { _Bool last_bit; unsigned long buf; unsigned char len; _Bool synced; _Bool parity; struct TPSData { _Bool parity; unsigned char len; enum FrameNum { FRAME_NUM_1=0, FRAME_NUM_2=1, FRAME_NUM_3=2, FRAME_NUM_4=3 } frame_num; enum Constellation { CONSTELLATION_QPSK=0, CONSTELLATION_16_QAM=1, CONSTELLATION_64_QAM=2, CONSTELLATION_NUM=3 } constellation; enum Hierarchy { HIERARCHY_NON_HIERARCHICAL=0, HIERARCHY_ALPHA_1=1, HIERARCHY_ALPHA_2=2, HIERARCHY_ALPHA_4=3, HIERARCHY_NUM=4 } hierarchy; enum CodeRate { CODE_RATE_1_2=0, CODE_RATE_2_3=1, CODE_RATE_3_4=2, CODE_RATE_5_6=3, CODE_RATE_7_8=4 } hp_code_rate; enum CodeRate { CODE_RATE_1_2=0, CODE_RATE_2_3=1, CODE_RATE_3_4=2, CODE_RATE_5_6=3, CODE_RATE_7_8=4 } lp_code_rate; enum GuardInt { GUARD_INT_1_32=0, GUARD_INT_1_16=1, GUARD_INT_1_8=2, GUARD_INT_1_4=3 } guard_int; enum TransMode { TRANS_MODE_2K=0, TRANS_MODE_8K=1 } trans_mode; unsigned char cell_id_byte; unsigned char error_protection; } data; } *

user_defined_types: struct TPSDecoder { _Bool last_bit; unsigned long buf; unsigned char len; _Bool synced; _Bool parity; struct TPSData data; }

user_defined_types: struct TPSData { _Bool parity; unsigned char len; enum FrameNum frame_num; enum Constellation constellation; enum Hierarchy hierarchy; enum CodeRate hp_code_rate; enum CodeRate lp_code_rate; enum GuardInt guard_int; enum TransMode trans_mode; unsigned char cell_id_byte; unsigned char error_protection; }


decompiled_code:
// attributes: thunk
void tps_decoder_destroy(void *ptr)
{
free(ptr);
}

canonical_decompiled_code:
void func1(void *ptr)
{
free(ptr);
}

original_code:
void tps_decoder_destroy(TPSDecoder *dec) {
  free(dec);
}

canonical_original_code:
void tps_decoder_destroy(struct TPSDecoder *dec) {
  free(dec);
}

user_defined_types: enum FrameNum { FRAME_NUM_1=0, FRAME_NUM_2=1, FRAME_NUM_3=2, FRAME_NUM_4=3 }

user_defined_types: enum Constellation { CONSTELLATION_QPSK=0, CONSTELLATION_16_QAM=1, CONSTELLATION_64_QAM=2, CONSTELLATION_NUM=3 }

user_defined_types: enum Hierarchy { HIERARCHY_NON_HIERARCHICAL=0, HIERARCHY_ALPHA_1=1, HIERARCHY_ALPHA_2=2, HIERARCHY_ALPHA_4=3, HIERARCHY_NUM=4 }

user_defined_types: enum CodeRate { CODE_RATE_1_2=0, CODE_RATE_2_3=1, CODE_RATE_3_4=2, CODE_RATE_5_6=3, CODE_RATE_7_8=4 }

user_defined_types: enum GuardInt { GUARD_INT_1_32=0, GUARD_INT_1_16=1, GUARD_INT_1_8=2, GUARD_INT_1_4=3 }

user_defined_types: enum TransMode { TRANS_MODE_2K=0, TRANS_MODE_8K=1 }


original_code:
void tps_decoder_interpret(TPSDecoder *dec) {
  TPSData *data = &dec->data;
  data->parity = dec->parity;
  data->error_protection = dec->buf & ((1 << 14) - 1);
  dec->buf >>= 14;
  dec->buf >>= 6;
  data->cell_id_byte = dec->buf & ((1 << 8) - 1);
  dec->buf >>= 8;
  data->trans_mode = dec->buf & ((1 << 2) - 1);
  dec->buf >>= 2;
  data->guard_int = dec->buf & ((1 << 2) - 1);
  dec->buf >>= 2;
  data->lp_code_rate = dec->buf & ((1 << 3) - 1);
  dec->buf >>= 3;
  data->hp_code_rate = dec->buf & ((1 << 3) - 1);
  dec->buf >>= 3;
  data->hierarchy = dec->buf & ((1 << 3) - 1);
  dec->buf >>= 3;
  data->constellation = dec->buf & ((1 << 2) - 1);
  dec->buf >>= 2;
  data->frame_num = dec->buf & ((1 << 2) - 1);
  dec->buf >>= 2;
  data->len = dec->buf & ((1 << 6) - 1);
  dec->buf >>= 6;
}

canonical_original_code:
void tps_decoder_interpret(struct TPSDecoder *dec) {
  struct TPSData *data = &dec->data;
  data->parity = dec->parity;
  data->error_protection = dec->buf & ((1 << 14) - 1);
  dec->buf >>= 14;
  dec->buf >>= 6;
  data->cell_id_byte = dec->buf & ((1 << 8) - 1);
  dec->buf >>= 8;
  data->trans_mode = dec->buf & ((1 << 2) - 1);
  dec->buf >>= 2;
  data->guard_int = dec->buf & ((1 << 2) - 1);
  dec->buf >>= 2;
  data->lp_code_rate = dec->buf & ((1 << 3) - 1);
  dec->buf >>= 3;
  data->hp_code_rate = dec->buf & ((1 << 3) - 1);
  dec->buf >>= 3;
  data->hierarchy = dec->buf & ((1 << 3) - 1);
  dec->buf >>= 3;
  data->constellation = dec->buf & ((1 << 2) - 1);
  dec->buf >>= 2;
  data->frame_num = dec->buf & ((1 << 2) - 1);
  dec->buf >>= 2;
  data->len = dec->buf & ((1 << 6) - 1);
  dec->buf >>= 6;
}

variable_types: struct TPSData { _Bool parity; unsigned char len; enum FrameNum { FRAME_NUM_1=0, FRAME_NUM_2=1, FRAME_NUM_3=2, FRAME_NUM_4=3 } frame_num; enum Constellation { CONSTELLATION_QPSK=0, CONSTELLATION_16_QAM=1, CONSTELLATION_64_QAM=2, CONSTELLATION_NUM=3 } constellation; enum Hierarchy { HIERARCHY_NON_HIERARCHICAL=0, HIERARCHY_ALPHA_1=1, HIERARCHY_ALPHA_2=2, HIERARCHY_ALPHA_4=3, HIERARCHY_NUM=4 } hierarchy; enum CodeRate { CODE_RATE_1_2=0, CODE_RATE_2_3=1, CODE_RATE_3_4=2, CODE_RATE_5_6=3, CODE_RATE_7_8=4 } hp_code_rate; enum CodeRate { CODE_RATE_1_2=0, CODE_RATE_2_3=1, CODE_RATE_3_4=2, CODE_RATE_5_6=3, CODE_RATE_7_8=4 } lp_code_rate; enum GuardInt { GUARD_INT_1_32=0, GUARD_INT_1_16=1, GUARD_INT_1_8=2, GUARD_INT_1_4=3 } guard_int; enum TransMode { TRANS_MODE_2K=0, TRANS_MODE_8K=1 } trans_mode; unsigned char cell_id_byte; unsigned char error_protection; } *


decompiled_code:
__int64 __fastcall tps_decoder_push_bit(__int64 a1, char a2)
{
char v2; // al
char v3; // cl
unsigned __int8 v4; // dl
__int64 v5; // rax
unsigned __int64 v6; // rax
bool v7; // zf
__int64 result; // rax

v2 = *(_BYTE *)(a1 + 16);
v3 = *(_BYTE *)a1;
*(_BYTE *)a1 = a2;
v4 = v2 + 1;
v5 = *(_QWORD *)(a1 + 8);
*(_BYTE *)(a1 + 16) = v4;
v6 = (unsigned __int8)(a2 ^ v3) | (unsigned __int64)(2 * v5);
*(_QWORD *)(a1 + 8) = v6;
if ( v4 != 17 && (v4 <= 0x11u || *(_BYTE *)(a1 + 17)) )
{
if ( v4 != 68 )
return 0LL;
tps_decoder_interpret(a1);
*(_BYTE *)(a1 + 18) ^= 1u;
result = 1LL;
*(_BYTE *)(a1 + 16) = 0;
}
else
{
v7 = (unsigned __int16)v6 == TPS_SYNC_WORD_ODD;
*(_BYTE *)(a1 + 16) = 17;
if ( v7 )
{
result = 0LL;
*(_WORD *)(a1 + 17) = 257;
}
else
{
if ( (unsigned __int16)v6 != TPS_SYNC_WORD_EVEN )
{
*(_BYTE *)(a1 + 17) = 0;
return 0LL;
}
*(_WORD *)(a1 + 17) = 1;
result = 0LL;
}
}
return result;
}

original_code:
_Bool tps_decoder_push_bit(TPSDecoder *dec, _Bool read_bit) {
  read_bit = !!read_bit;
  _Bool bit = read_bit ^ dec->last_bit;
  dec->last_bit = read_bit;
  dec->len++;
  dec->buf <<= 1;
  dec->buf |= bit;
  if ((dec->len == 17) || (dec->len > 17 && !dec->synced)) {
    dec->len = 17;
    if ((dec->buf & 0xffff) == TPS_SYNC_WORD_ODD) {
      dec->synced = 1;
      dec->parity = 1;
    } else if ((dec->buf & 0xffff) == TPS_SYNC_WORD_EVEN) {
      dec->synced = 1;
      dec->parity = 0;
    } else {
      dec->synced = 0;
    }
  }
  if (dec->len == 68) {
    tps_decoder_interpret(dec);
    dec->parity = !dec->parity;
    dec->len = 0;
    return 1;
  }
  return 0;
}

canonical_original_code:
_Bool tps_decoder_push_bit(struct TPSDecoder *dec, _Bool read_bit) {
  read_bit = !!read_bit;
  _Bool bit = read_bit ^ dec->last_bit;
  dec->last_bit = read_bit;
  dec->len++;
  dec->buf <<= 1;
  dec->buf |= bit;
  if ((dec->len == 17) || (dec->len > 17 && !dec->synced)) {
    dec->len = 17;
    if ((dec->buf & 0xffff) == TPS_SYNC_WORD_ODD) {
      dec->synced = 1;
      dec->parity = 1;
    } else if ((dec->buf & 0xffff) == TPS_SYNC_WORD_EVEN) {
      dec->synced = 1;
      dec->parity = 0;
    } else {
      dec->synced = 0;
    }
  }
  if (dec->len == 68) {
    tps_decoder_interpret(dec);
    dec->parity = !dec->parity;
    dec->len = 0;
    return 1;
  }
  return 0;
}


decompiled_code:
void *tps_data_new()
{
return calloc(0x24uLL, 1uLL);
}

canonical_decompiled_code:
void *func4()
{
return calloc(0x24uLL, 1uLL);
}

original_code:
TPSData *tps_data_new() {
  TPSData *data = malloc(sizeof(TPSData));
  bzero(data, sizeof(TPSData));
  return data;
}

canonical_original_code:
struct TPSData *tps_data_new() {
  struct TPSData *data = malloc(sizeof(TPSData));
  bzero(data, sizeof(TPSData));
  return data;
}

return_type: struct TPSData { _Bool parity; unsigned char len; enum FrameNum { FRAME_NUM_1=0, FRAME_NUM_2=1, FRAME_NUM_3=2, FRAME_NUM_4=3 } frame_num; enum Constellation { CONSTELLATION_QPSK=0, CONSTELLATION_16_QAM=1, CONSTELLATION_64_QAM=2, CONSTELLATION_NUM=3 } constellation; enum Hierarchy { HIERARCHY_NON_HIERARCHICAL=0, HIERARCHY_ALPHA_1=1, HIERARCHY_ALPHA_2=2, HIERARCHY_ALPHA_4=3, HIERARCHY_NUM=4 } hierarchy; enum CodeRate { CODE_RATE_1_2=0, CODE_RATE_2_3=1, CODE_RATE_3_4=2, CODE_RATE_5_6=3, CODE_RATE_7_8=4 } hp_code_rate; enum CodeRate { CODE_RATE_1_2=0, CODE_RATE_2_3=1, CODE_RATE_3_4=2, CODE_RATE_5_6=3, CODE_RATE_7_8=4 } lp_code_rate; enum GuardInt { GUARD_INT_1_32=0, GUARD_INT_1_16=1, GUARD_INT_1_8=2, GUARD_INT_1_4=3 } guard_int; enum TransMode { TRANS_MODE_2K=0, TRANS_MODE_8K=1 } trans_mode; unsigned char cell_id_byte; unsigned char error_protection; } *


decompiled_code:
// attributes: thunk
void tps_data_destroy(void *ptr)
{
tps_decoder_destroy(ptr);
}

canonical_decompiled_code:
void func5(void *ptr)
{
func1(ptr);
}

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

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


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; } *

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


decompiled_code:
double __fastcall heap_up(__int64 a1, __int64 a2)
{
__int64 *v4; // rsi
__int64 *v5; // rdi
double result; // xmm0_8

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

canonical_decompiled_code:
double __fastcall func8(__int64 a1, __int64 a2)
{
__int64 *v4; // rsi
__int64 *v5; // rdi
double result; // xmm0_8

while ( a2 )
{
v4 = (__int64 *)(*(_QWORD *)(a1 + 8) + 16 * a2);
v5 = (__int64 *)(*(_QWORD *)(a1 + 8) + 16 * ((unsigned __int64)(a2 - 1) >> 1));
result = *(double *)v5;
if ( *(double *)v5 <= *(double *)v4 )
break;
func7(v5, v4);
}
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; }


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:
__int64 __fastcall heap_pop(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rsi
unsigned __int64 *v3; // r8

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(v3, 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 v5; // [rsp+0h] [rbp-18h]

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

canonical_decompiled_code:
double __fastcall func7(double a1, double a2, double a3)
{
double v5; // [rsp+0h] [rbp-18h]

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

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 v2; // xmm3_8
double i; // [rsp+0h] [rbp-28h]
double cosx; // [rsp+10h] [rbp-18h] BYREF
double sinx[2]; // [rsp+18h] [rbp-10h] BYREF

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

canonical_decompiled_code:
double __fastcall func9(double a1, double a2)
{
double v2; // xmm3_8
double i; // [rsp+0h] [rbp-28h]
double cosx; // [rsp+10h] [rbp-18h] BYREF
double sinx[2]; // [rsp+18h] [rbp-10h] BYREF

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

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 func10(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; // xmm4_8
double v5; // xmm1_8
double v6; // [rsp+8h] [rbp-40h]
double v7; // [rsp+10h] [rbp-38h]
double cosx; // [rsp+20h] [rbp-28h] BYREF
double sinx[4]; // [rsp+28h] [rbp-20h] BYREF

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

canonical_decompiled_code:
void __fastcall func12(double *a1, double *a2, double a3, double a4)
{
double v4; // xmm4_8
double v5; // xmm1_8
double v6; // [rsp+8h] [rbp-40h]
double v7; // [rsp+10h] [rbp-38h]
double cosx; // [rsp+20h] [rbp-28h] BYREF
double sinx[4]; // [rsp+28h] [rbp-20h] BYREF

sincos(a3, sinx, &cosx);
v7 = cosx;
v6 = sinx[0];
sincos(a4, sinx, &cosx);
v4 = cosx;
v5 = sinx[0];
*a2 = (*a1 * v7 - a1[1] * v6) * sinx[0] + a1[2] * cosx;
a2[1] = *a1 * v6 + a1[1] * v7;
a2[2] = (v6 * a1[1] - v7 * *a1) * v4 + v5 * 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) = *(double *)(a2 + 8 * i) * a4;
}
}

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 / (3.141592653589793 * a3 * 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


main

repo: giraldeau/minimods

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

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

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

variable_types: argc int

variable_types:
argv
char **


decompiled_code:
int __fastcall show_stack(__int64 *a1)
{
__int64 *v1; // rbx
__int64 v2; // rdx
__int64 *v3; // rsi
int result; // eax

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

canonical_decompiled_code:
int __fastcall func7(__int64 *a1)
{
__int64 *v1; // rbx
__int64 v2; // rdx
__int64 *v3; // rsi
int result; // eax

v1 = a1;
printf("%-18s %-18s\n", "address", "value");
do
{
v2 = *v1;
v3 = v1++;
result = printf("0x%016lx 0x%016lx\n", v3, v2);
}
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

repo: girishponkiya/brach-and-bound

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

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

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

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

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

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


delete

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

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


deleteList

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

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

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

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

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

for ( result = 0LL; a1; a1 = *(_QWORD *)(a1 + 8) )
result = (unsigned int)(*(_DWORD *)a1 + result);
return result;
}

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

for ( result = 0LL; a1; a1 = *(_QWORD *)(a1 + 8) )
result = (unsigned int)(*(_DWORD *)a1 + result);
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

repo: gitaloha/eureka

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

if ( (unsigned int)parseCapFile("test", v5, envp) == -1 )
{
v3 = -1;
puts("parse failed\r");
}
else
{
v3 = 0;
testPackList(v5[0], v5[1]);
statTotalFlow(v5, v6);
testTotalFlow(v6);
releaseTotalFlowList(v6);
releasePackets(v5);
}
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:
__int16 __fastcall hton16(__int16 a1)
{
int v1; // er8
__int16 result; // ax

v1 = isBigEnd();
result = __ROL2__(a1, 8);
if ( v1 )
result = a1;
return result;
}

canonical_decompiled_code:
__int16 __fastcall func1(__int16 a1)
{
int v1; // er8
__int16 result; // ax

v1 = func0();
result = __ROL2__(a1, 8);
if ( v1 )
result = a1;
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; // er8
__int64 result; // rax

v1 = isBigEnd();
result = _byteswap_ulong(a1);
if ( v1 )
result = a1;
return result;
}

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

v1 = func0();
result = _byteswap_ulong(a1);
if ( v1 )
result = 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(13330);
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(13330);
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)
{
float v2; // xmm0_4
int v3; // eax
float v4; // xmm0_4
unsigned int v5; // edx
unsigned __int64 result; // rax

if ( a1 != 2 )
_assert_fail("ulCnt == sizeof(MMA_PARAM_S)/sizeof(UINT32)", "method/mma.c", 0x17u, "MMA_SetParam");
v2 = *a2;
if ( *a2 >= 9.223372e18 )
v3 = (int)(float)(v2 - 9.223372e18);
else
v3 = (int)v2;
v4 = a2[1];
g_stMmaParam = v3;
v5 = v3;
if ( v4 >= 9.223372e18 )
result = (unsigned int)(int)(float)(v4 - 9.223372e18) ^ 0x8000000000000000LL;
else
result = (unsigned int)(int)v4;
*(&g_stMmaParam + 1) = result;
if ( v5 >= (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)
{
float v2; // xmm0_4
int v3; // eax
float v4; // xmm0_4
unsigned int v5; // edx
unsigned __int64 result; // rax

if ( a1 != 2 )
_assert_fail("ulCnt == sizeof(MMA_PARAM_S)/sizeof(UINT32)", "method/mma.c", 0x17u, "MMA_SetParam");
v2 = *a2;
if ( *a2 >= 9.223372e18 )
v3 = (int)(float)(v2 - 9.223372e18);
else
v3 = (int)v2;
v4 = a2[1];
g_stMmaParam = v3;
v5 = v3;
if ( v4 >= 9.223372e18 )
result = (unsigned int)(int)(float)(v4 - 9.223372e18) ^ 0x8000000000000000LL;
else
result = (unsigned int)(int)v4;
*(&g_stMmaParam + 1) = result;
if ( v5 >= (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 v3; // r13
__int64 result; // rax
__int64 v5; // r14
unsigned __int64 v7; // r12
unsigned __int64 v8; // rax
float v9; // xmm3_4
float v10; // xmm2_4
int v11; // er12
int v12; // eax
int v13; // er12
float v14; // [rsp+8h] [rbp-30h]

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

canonical_decompiled_code:
__int64 __fastcall func2(unsigned __int64 a1, __int64 a2, __int64 a3)
{
unsigned __int64 v3; // r13
__int64 result; // rax
__int64 v5; // r14
unsigned __int64 v7; // r12
unsigned __int64 v8; // rax
float v9; // xmm3_4
float v10; // xmm2_4
int v11; // er12
int v12; // eax
int v13; // er12
float v14; // [rsp+8h] [rbp-30h]

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

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; // rbx
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; // rbx
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; }