dimLum

original_code:
void dimLum(Lut* lt, Channels* input){
 int i;
 int tmp;
 if(lt == ((void *)0)) return;
 for (i=0; i < lt->size; i++){
  tmp = input->chan1[i] - lt->valueEffect;
  if(tmp > lt->maxValue) tmp = lt->maxValue;
  else if (tmp < 0) tmp = 0;
  lt->channels->chan1[i] = (unsigned char) tmp;
  tmp = input->chan2[i] - lt->valueEffect;
  if(tmp > lt->maxValue) tmp = lt->maxValue;
  else if (tmp < 0) tmp = 0;
  lt->channels->chan2[i] = (unsigned char) tmp;
  tmp = input->chan3[i] - lt->valueEffect;
  if(tmp > lt->maxValue) tmp = lt->maxValue;
  else if (tmp < 0) tmp = 0;
  lt->channels->chan3[i] = (unsigned char) tmp;
 }
}

canonical_original_code:
void dimLum(struct lut *lt, struct Channels *input){
 int i;
 int tmp;
 if(lt == ((void *)0)) return;
 for (i=0; i < lt->size; i++){
  tmp = input->chan1[i] - lt->valueEffect;
  if(tmp > lt->maxValue) tmp = lt->maxValue;
  else if (tmp < 0) tmp = 0;
  lt->channels->chan1[i] = (unsigned char) tmp;
  tmp = input->chan2[i] - lt->valueEffect;
  if(tmp > lt->maxValue) tmp = lt->maxValue;
  else if (tmp < 0) tmp = 0;
  lt->channels->chan2[i] = (unsigned char) tmp;
  tmp = input->chan3[i] - lt->valueEffect;
  if(tmp > lt->maxValue) tmp = lt->maxValue;
  else if (tmp < 0) tmp = 0;
  lt->channels->chan3[i] = (unsigned char) tmp;
 }
}


changeContrast

repo: L-Naej/IMAGIMP

original_code:
void changeContrast(Lut* lt, Channels* input){
 int i = 0, rg, gg, bg;
 for(i = 0; i < lt->size; i++){
  rg = (abs(127 - input->chan1[i]) * lt->valueEffect) / lt->maxValue;
  if(input->chan1[i] > 127)
   rg = input->chan1[i] + rg;
  else
   rg = input->chan1[i] - rg;
  if(rg > lt->maxValue) rg = lt->maxValue;
  else if (rg < 0) rg = 0;
  lt->channels->chan1[i] = (unsigned char) rg;
  gg = (abs(127 - input->chan2[i]) * lt->valueEffect) / lt->maxValue;
  if(input->chan2[i] > 127)
   gg = input->chan2[i] + gg;
  else
   gg = input->chan2[i] - gg;
  if(gg > lt->maxValue) gg = lt->maxValue;
  else if (gg < 0) gg = 0;
  lt->channels->chan2[i] = (unsigned char) gg;
  bg = (abs(127 - input->chan3[i]) * lt->valueEffect) / lt->maxValue;
  if(input->chan3[i] > 127)
   bg = input->chan3[i] + bg;
  else
   bg = input->chan3[i] - bg;
  if(bg > lt->maxValue) bg = lt->maxValue;
  else if (bg < 0) bg = 0;
  lt->channels->chan3[i] = (unsigned char) bg;
 }
}

canonical_original_code:
void changeContrast(struct lut *lt, struct Channels *input){
 int i = 0; int rg; int gg; int bg;
 for(i = 0; i < lt->size; i++){
  rg = (abs(127 - input->chan1[i]) * lt->valueEffect) / lt->maxValue;
  if(input->chan1[i] > 127)
   rg = input->chan1[i] + rg;
  else
   rg = input->chan1[i] - rg;
  if(rg > lt->maxValue) rg = lt->maxValue;
  else if (rg < 0) rg = 0;
  lt->channels->chan1[i] = (unsigned char) rg;
  gg = (abs(127 - input->chan2[i]) * lt->valueEffect) / lt->maxValue;
  if(input->chan2[i] > 127)
   gg = input->chan2[i] + gg;
  else
   gg = input->chan2[i] - gg;
  if(gg > lt->maxValue) gg = lt->maxValue;
  else if (gg < 0) gg = 0;
  lt->channels->chan2[i] = (unsigned char) gg;
  bg = (abs(127 - input->chan3[i]) * lt->valueEffect) / lt->maxValue;
  if(input->chan3[i] > 127)
   bg = input->chan3[i] + bg;
  else
   bg = input->chan3[i] - bg;
  if(bg > lt->maxValue) bg = lt->maxValue;
  else if (bg < 0) bg = 0;
  lt->channels->chan3[i] = (unsigned char) bg;
 }
}

variable_types: struct lut { struct Channels { unsigned char *chan1; unsigned char *chan2; unsigned char *chan3; int size; } *channels; long size; int maxValue; enum lut_function { INVERT=1, ADDLUM=2, DIMLUM=3, ADDCON=4, DIMCON=5, SEPIA=6, GRAY=7, NEUTRAL=0 } function; int valueEffect; } *

variable_types:
input
struct Channels *

variable_types: i int

variable_types: rg int

variable_types: gg int

variable_types: bg int

return_type: void

user_defined_types: struct lut { struct Channels *channels; long size; int maxValue; enum lut_function function; int valueEffect; }


sepia

original_code:
void sepia(Lut* sepia){
 int result = 0, i =0;
 for(i = 0; i < sepia->size; ++i){
  result = sepia->channels->chan1[i] + 100;
  result = result > sepia->maxValue ? sepia->maxValue : result;
  sepia->channels->chan1[i] = result;
  result = sepia->channels->chan2[i] + 50;
  result = result > sepia->maxValue ? sepia->maxValue : result;
  sepia->channels->chan2[i] = result;
 }
}

canonical_original_code:
void sepia(struct lut *sepia){
 int result = 0; int i = 0;
 for(i = 0; i < sepia->size; ++i){
  result = sepia->channels->chan1[i] + 100;
  result = result > sepia->maxValue ? sepia->maxValue : result;
  sepia->channels->chan1[i] = result;
  result = sepia->channels->chan2[i] + 50;
  result = result > sepia->maxValue ? sepia->maxValue : result;
  sepia->channels->chan2[i] = result;
 }
}

variable_types: result int

user_defined_types: enum lut_function { INVERT=1, ADDLUM=2, DIMLUM=3, ADDCON=4, DIMCON=5, SEPIA=6, GRAY=7, NEUTRAL=0 }

user_defined_types: struct Channels { unsigned char *chan1; unsigned char *chan2; unsigned char *chan3; int size; }


detectWH

original_code:
void detectWH(const char* text, int* w, int* h){
 if(text==((void *)0))return;
 char sW[5]; char sH[5];
 short i = 0, j = 0;
 sW[4] = sH[4] = '\0';
 int sText = strlen(text);
 while(!((*__ctype_b_loc ())[(int) ((text[i]))] & (unsigned short int) _ISspace) && i < 4){
  sW[i] = text[i];
  i++;
 }
 *w = atoi(sW);
 i++;
 while(text[i+j] != '\n' && j < 4 && (i+j) < sText){
  sH[j] = text[i+j];
  j++;
 }
 *h = atoi(sH);
}

canonical_original_code:
void detectWH(char *text, int *w, int *h){
 if(text==((void *)0))return;
 char sW[5]; char sH[5];
 short i = 0; short j = 0;
 sW[4] = sH[4] = '\0';
 int sText = strlen(text);
 while(!((*__ctype_b_loc ())[(int) ((text[i]))] & (unsigned short) _ISspace) && i < 4){
  sW[i] = text[i];
  i++;
 }
 *w = atoi(sW);
 i++;
 while(text[i+j] != '\n' && j < 4 && (i+j) < sText){
  sH[j] = text[i+j];
  j++;
 }
 *h = atoi(sH);
}

variable_types:
text
char *

variable_types:
w
int *

variable_types:
h
int *

variable_types:
sW
char [5]

variable_types:
sH
char [5]

variable_types: i short

variable_types: j short

variable_types: sText int


freeImage

decompiled_code:
void __fastcall freeImage(void *ptr)
{
if ( ptr )
{
free(*((void **)ptr + 1));
free(*((void **)ptr + 5));
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func2(void *ptr)
{
if ( ptr )
{
free(*((void **)ptr + 1));
free(*((void **)ptr + 5));
free(ptr);
}
}

original_code:
void freeImage(Image* img){
 if(img == ((void *)0)) return;
 free(img->comments);
 free(img->arrayRGB);
 free(img);
}

canonical_original_code:
void freeImage(struct image *img){
 if(img == ((void *)0)) return;
 free(img->comments);
 free(img->arrayRGB);
 free(img);
}

variable_types: struct image { short format; char *comments; char *name; int width; int height; int maxValue; unsigned char *arrayRGB; unsigned char *histoGrey; unsigned char *histoRGB; } *


normalizeHisto

decompiled_code:
__int64 __fastcall normalizeHisto(__int64 *a1, int a2)
{
__int64 result; // rax
int v3; // er12
__int64 *v4; // rbx

result = maxInTab();
if ( a2 > 0 )
{
v3 = result;
v4 = a1;
do
{
result = *v4;
if ( *v4 )
{
result = (unsigned int)(int)ceil((double)(int)result / (double)v3 * 100.0);
*v4 = result;
}
++v4;
}
while ( v4 != &a1[(unsigned int)(a2 - 1) + 1] );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 *a1, int a2)
{
__int64 result; // rax
int v3; // er12
__int64 *v4; // rbx

result = maxInTab();
if ( a2 > 0 )
{
v3 = result;
v4 = a1;
do
{
result = *v4;
if ( *v4 )
{
result = (unsigned int)(int)ceil((double)(int)result / (double)v3 * 100.0);
*v4 = result;
}
++v4;
}
while ( v4 != &a1[(unsigned int)(a2 - 1) + 1] );
}
return result;
}

original_code:
void normalizeHisto(long int* histo, int size){
 int i = 0;
 long int max = maxInTab(histo, size);
 for(i = 0; i < size; ++i){
  if(histo[i] == 0) continue;
  histo[i] = (long int) ceil(((double)((double)histo[i] / (double)max)) * 100.0);
 }
}

canonical_original_code:
void normalizeHisto(long *histo, int size){
 int i = 0;
 long max = maxInTab(histo, size);
 for(i = 0; i < size; ++i){
  if(histo[i] == 0) continue;
  histo[i] = (long) ceil(((double)((double)histo[i] / (double)max)) * 100.0);
 }
}

variable_types:
histo
long *

variable_types: size int

variable_types: max long


dumpImage

decompiled_code:
int __fastcall dumpImage(__int64 a1)
{
const char *v1; // rsi
const char *v2; // rsi

if ( !a1 )
return puts("Tentative de dump d'une image NULL.");
printf("--Image (Adresse %p)\n", (const void *)a1);
v1 = *(const char **)(a1 + 16);
if ( v1 )
printf("Nom : %s\n", v1);
v2 = *(const char **)(a1 + 8);
if ( v2 )
printf("Commentaires : %s\n", v2);
return printf("Width : %d\nHeight : %d\n", *(unsigned int *)(a1 + 24), *(unsigned int *)(a1 + 28));
}

canonical_decompiled_code:
int __fastcall func9(__int64 a1)
{
const char *v1; // rsi
const char *v2; // rsi

if ( !a1 )
return puts("Tentative de dump d'une image NULL.");
printf("--Image (Adresse %p)\n", (const void *)a1);
v1 = *(const char **)(a1 + 16);
if ( v1 )
printf("Nom : %s\n", v1);
v2 = *(const char **)(a1 + 8);
if ( v2 )
printf("Commentaires : %s\n", v2);
return printf("Width : %d\nHeight : %d\n", *(unsigned int *)(a1 + 24), *(unsigned int *)(a1 + 28));
}

original_code:
void dumpImage(Image* img){
 if(img == ((void *)0)){
  printf("Tentative de dump d'une image NULL.\n");
  return;
 }
 printf("--Image (Adresse %p)\n", img);
 if(img->name) printf("Nom : %s\n", img->name);
 if(img->comments) printf("Commentaires : %s\n", img->comments);
 printf("Width : %d\nHeight : %d\n", img->width, img->height);
}

canonical_original_code:
void dumpImage(struct image *img){
 if(img == ((void *)0)){
  printf("Tentative de dump d'une image NULL.\n");
  return;
 }
 printf("--Image (Adresse %p)\n", img);
 if(img->name) printf("Nom : %s\n", img->name);
 if(img->comments) printf("Commentaires : %s\n", img->comments);
 printf("Width : %d\nHeight : %d\n", img->width, img->height);
}

user_defined_types: struct image { short format; char *comments; char *name; int width; int height; int maxValue; unsigned char *arrayRGB; unsigned char *histoGrey; unsigned char *histoRGB; }


invertPPMArray

original_code:
void invertPPMArray(unsigned char array[], long int width, long int height){
      long i = 0, j= 0;
      long int nPix = width*height;
      unsigned char* invertedArray = (unsigned char*) calloc(nPix*3,sizeof(unsigned char));
      int k = 0;
 for(i = height*(width-1)*3; i >= 0; i = i - (width*3)){
  for(j = 0; j < width*3; j++){
   invertedArray[k++] = array[i+j];
  }
 }
 memcpy(array, invertedArray, nPix*3*sizeof(unsigned char));
 free(invertedArray);
}

canonical_original_code:
void invertPPMArray(unsigned char array[], long width, long height){
      long i = 0; long j = 0;
      long nPix = width*height;
      unsigned char *invertedArray = (unsigned char*) calloc(nPix*3,sizeof(unsigned char));
      int k = 0;
 for(i = height*(width-1)*3; i >= 0; i = i - (width*3)){
  for(j = 0; j < width*3; j++){
   invertedArray[k++] = array[i+j];
  }
 }
 memcpy(array, invertedArray, nPix*3*sizeof(unsigned char));
 free(invertedArray);
}

variable_types:
array
unsigned char []

variable_types: width long

variable_types: height long

variable_types: i long

variable_types: j long

variable_types: nPix long

variable_types:
invertedArray
unsigned char *

variable_types: k int


clearStdin

decompiled_code:
int clearStdin()
{
int result; // eax

do
result = getchar();
while ( (_BYTE)result != 10 && (_BYTE)result != 0xFF );
return result;
}

canonical_decompiled_code:
int func4()
{
int result; // eax

do
result = getchar();
while ( (_BYTE)result != 10 && (_BYTE)result != 0xFF );
return result;
}

original_code:
void clearStdin(){
 char c;
 do {
   c = getchar();
 } while (c != '\n' && c != (-1));
}

variable_types: c char


readStdin

decompiled_code:
char *__fastcall readStdin(char *s, int a2)
{
char *v2; // rbx
char *v3; // rax

v2 = fgets(s, a2, stdin);
if ( v2 )
{
v3 = strchr(s, 10);
if ( v3 )
*v3 = 0;
else
clearStdin();
}
return v2;
}

canonical_decompiled_code:
char *__fastcall func5(char *s, int a2)
{
char *v2; // rbx
char *v3; // rax

v2 = fgets(s, a2, stdin);
if ( v2 )
{
v3 = strchr(s, 10);
if ( v3 )
*v3 = 0;
else
func4();
}
return v2;
}

original_code:
char * readStdin(char * buffer, size_t taille){
 char * result = fgets(buffer, taille, stdin);
 if (result != ((void *)0)){
  char * lf = strchr(buffer, '\n');
  if (lf != ((void *)0))
   *lf = '\0';
  else
   clearStdin();
 }
 return result;
}

canonical_original_code:
char *readStdin(char *buffer, unsigned long taille){
 char *result = fgets(buffer, taille, stdin);
 if (result != ((void *)0)){
  char *lf = strchr(buffer, '\n');
  if (lf != ((void *)0))
   *lf = '\0';
  else
   clearStdin();
 }
 return result;
}

variable_types:
buffer
char *

variable_types:
taille
unsigned long

variable_types:
result
char *

variable_types:
lf
char *

return_type: char *


minInTab

original_code:
long int minInTab(long int* tab, int size){
 if(tab == ((void *)0)) return 0;
 int i = 0;
 long int min = tab[0];
 for(i = 1; i < size; ++i){
  if(tab[i] < min)
   min = tab[i];
 }
 return min;
}

canonical_original_code:
long minInTab(long *tab, int size){
 if(tab == ((void *)0)) return 0;
 int i = 0;
 long min = tab[0];
 for(i = 1; i < size; ++i){
  if(tab[i] < min)
   min = tab[i];
 }
 return min;
}

variable_types:
tab
long *

variable_types: i int

variable_types: min long

return_type: long


maxInTab

original_code:
long int maxInTab(long int* tab, int size){
 if(tab == ((void *)0)) return 0;
 int i = 0;
 long int max = tab[0];
 for(i = 1; i < size; ++i){
  if(tab[i] > max)
   max = tab[i];
 }
 return max;
}

canonical_original_code:
long maxInTab(long *tab, int size){
 if(tab == ((void *)0)) return 0;
 int i = 0;
 long max = tab[0];
 for(i = 1; i < size; ++i){
  if(tab[i] > max)
   max = tab[i];
 }
 return max;
}

variable_types: size int

variable_types: max long


min

decompiled_code:
__int64 __fastcall min(unsigned int a1, unsigned int a2)
{
__int64 result; // rax

result = a2;
if ( (int)a1 <= (int)a2 )
result = a1;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(unsigned int a1, unsigned int a2)
{
__int64 result; // rax

result = a2;
if ( (int)a1 <= (int)a2 )
result = a1;
return result;
}

original_code:
int min(int a, int b){
 if(a >= b) return b;
 else return a;
}

variable_types: a int

variable_types: b int

return_type: int


decompiled_code:
__int64 clickMouse_GLIMAGIMP()
{
if ( fct_clic_souris_user )
fct_clic_souris_user();
else
puts(LC0);
return glutPostRedisplay();
}

canonical_decompiled_code:
__int64 func0()
{
if ( fct_clic_souris_user )
fct_clic_souris_user();
else
puts(LC0);
return glutPostRedisplay();
}

original_code:
void clickMouse_GLIMAGIMP(int button,int state,int x,int y) {
 if (fct_clic_souris_user != ((void *)0)) {
  (*fct_clic_souris_user)(button,state,x,y);
 }
 else {
  printf("Fonction souris non fixée\n");
 }
 glutPostRedisplay();
}

canonical_original_code:
void clickMouse_GLIMAGIMP(int button, int state, int x, int y) {
 if (fct_clic_souris_user != ((void *)0)) {
  (*fct_clic_souris_user)(button,state,x,y);
 }
 else {
  printf("Fonction souris non fixée\n");
 }
 glutPostRedisplay();
}

variable_types: button int

variable_types: state int

variable_types: x int

variable_types: y int


decompiled_code:
__int64 kbdSpFunc_GLIMAGIMP()
{
if ( fct_clavier_spe_user )
fct_clavier_spe_user();
else
puts(LC1);
return glutPostRedisplay();
}

canonical_decompiled_code:
__int64 func1()
{
if ( fct_clavier_spe_user )
fct_clavier_spe_user();
else
puts(LC1);
return glutPostRedisplay();
}

original_code:
void kbdSpFunc_GLIMAGIMP(int c, int x, int y) {
 if (fct_clavier_spe_user != ((void *)0)) {
  (*fct_clavier_spe_user)(c,x,y);
 }
 else {
  printf("Fonction clavier touche spéciales non fixée\n");
 }
 glutPostRedisplay();
}

variable_types: c int


decompiled_code:
__int64 __fastcall kbdFunc_GLIMAGIMP(unsigned __int8 a1)
{
if ( fct_clavier_user )
fct_clavier_user(a1);
else
puts(LC2);
return glutPostRedisplay();
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned __int8 a1)
{
if ( fct_clavier_user )
fct_clavier_user(a1);
else
puts(LC2);
return glutPostRedisplay();
}

original_code:
void kbdFunc_GLIMAGIMP(unsigned char c, int x, int y) {
 if (fct_clavier_user != ((void *)0)) {
  (*fct_clavier_user)(c,x,y);
 }
 else {
  printf("Fonction clavier non fixée\n");
 }
 glutPostRedisplay();
}

variable_types:
c
unsigned char


reshapeFunc

decompiled_code:
__int64 reshapeFunc()
{
glutReshapeWindow(width_ecran, height_ecran);
printf("Nouvelle taille %d %d\n", width_ecran, height_ecran);
glViewport(0LL, 0LL, width_ecran, height_ecran);
glMatrixMode(5889LL);
glLoadIdentity();
gluOrtho2D(0.0, 1.0, 0.0, 1.0);
glMatrixMode(5888LL);
glLoadIdentity();
modified_tampon = 1;
return glutPostRedisplay();
}

canonical_decompiled_code:
__int64 func3()
{
glutReshapeWindow(width_ecran, height_ecran);
printf("Nouvelle taille %d %d\n", width_ecran, height_ecran);
glViewport(0LL, 0LL, width_ecran, height_ecran);
glMatrixMode(5889LL);
glLoadIdentity();
gluOrtho2D(0.0, 1.0, 0.0, 1.0);
glMatrixMode(5888LL);
glLoadIdentity();
modified_tampon = 1;
return glutPostRedisplay();
}

original_code:
void reshapeFunc(int width,int height) {
 glutReshapeWindow(width_ecran,height_ecran);
 printf("Nouvelle taille %d %d\n",width_ecran,height_ecran);
 glViewport( 0, 0, (GLint)width_ecran, (GLint)height_ecran );
 glMatrixMode( 0x1701 );
 glLoadIdentity();
 gluOrtho2D(0.0,1.0,0.0,1.0);
 glMatrixMode( 0x1700 );
 glLoadIdentity();
 modified_tampon = 1;
 glutPostRedisplay();
}

canonical_original_code:
void reshapeFunc(int width, int height) {
 glutReshapeWindow(width_ecran,height_ecran);
 printf("Nouvelle taille %d %d\n",width_ecran,height_ecran);
 glViewport( 0, 0, (int)width_ecran, (int)height_ecran );
 glMatrixMode( 0x1701 );
 glLoadIdentity();
 gluOrtho2D(0.0,1.0,0.0,1.0);
 glMatrixMode( 0x1700 );
 glLoadIdentity();
 modified_tampon = 1;
 glutPostRedisplay();
}

variable_types: width int

variable_types: height int


idleFunc

decompiled_code:
__int64 idleFunc()
{
__int64 result; // rax
int v1; // ebx

result = (unsigned int)++cptidletime;
if ( flag_test )
{
if ( (_DWORD)result == 100 * ((unsigned int)result / 0x64) )
{
v1 = glutGet(700LL);
printf("FPS : %f\n", 100.0 / ((double)(v1 - instantPrec) / 1000.0));
instantPrec = v1;
result = glutPostRedisplay();
}
}
return result;
}

canonical_decompiled_code:
__int64 func4()
{
__int64 result; // rax
int v1; // ebx

result = (unsigned int)++cptidletime;
if ( flag_test )
{
if ( (_DWORD)result == 100 * ((unsigned int)result / 0x64) )
{
v1 = glutGet(700LL);
printf("FPS : %f\n", 100.0 / ((double)(v1 - instantPrec) / 1000.0));
instantPrec = v1;
result = glutPostRedisplay();
}
}
return result;
}

original_code:
void idleFunc(void)
{
 cptidletime++;
 if (flag_test && 1 && (cptidletime%100 == 0)) {
  int instant = glutGet(0x02BC);
  double t=(instant-instantPrec)/1000.0;
  printf("FPS : %f\n",100/t);
  instantPrec = instant;
  glutPostRedisplay();
 }
}

canonical_original_code:
void idleFunc()
{
 cptidletime++;
 if (flag_test && 1 && (cptidletime%100 == 0)) {
  int instant = glutGet(0x02BC);
  double t = (instant-instantPrec)/1000.0;
  printf("FPS : %f\n",100/t);
  instantPrec = instant;
  glutPostRedisplay();
 }
}

variable_types: instant int

variable_types: t double


decompiled_code:
__int64 drawScene_GLIMAGIMP()
{
modified_tampon = 1;
glMatrixMode(5888LL);
glLoadIdentity();
glClearColor(0.0, 0.0, 0.0);
glClear(16640LL);
glDrawPixels(width_image, height_image, 6407LL, 5121LL, image_src);
if ( fct_dessin_user )
fct_dessin_user();
if ( flag_fichier )
printf("Sauvegarde dans le fichier");
return glutSwapBuffers();
}

canonical_decompiled_code:
__int64 func5()
{
modified_tampon = 1;
glMatrixMode(5888LL);
glLoadIdentity();
glClearColor(0.0, 0.0, 0.0);
glClear(16640LL);
glDrawPixels(width_image, height_image, 6407LL, 5121LL, image_src);
if ( fct_dessin_user )
fct_dessin_user();
if ( flag_fichier )
printf("Sauvegarde dans le fichier");
return glutSwapBuffers();
}

original_code:
void drawScene_GLIMAGIMP(void) {
 modified_tampon = 1;
 glMatrixMode( 0x1700 );
 glLoadIdentity();
 glClearColor(0.0,0.0,0.0,0.0);
 glClear(0x00004000 | 0x00000100);
 glDrawPixels(width_image,height_image,0x1907,0x1401,image_src);
 if (fct_dessin_user != ((void *)0)) {
  (*fct_dessin_user)();
 }
 if (flag_fichier) {
  printf("Sauvegarde dans le fichier");
 }
 glutSwapBuffers();
}

canonical_original_code:
void drawScene_GLIMAGIMP() {
 modified_tampon = 1;
 glMatrixMode( 0x1700 );
 glLoadIdentity();
 glClearColor(0.0,0.0,0.0,0.0);
 glClear(0x00004000 | 0x00000100);
 glDrawPixels(width_image,height_image,0x1907,0x1401,image_src);
 if (fct_dessin_user != ((void *)0)) {
  (*fct_dessin_user)();
 }
 if (flag_fichier) {
  printf("Sauvegarde dans le fichier");
 }
 glutSwapBuffers();
}


initDisplay

decompiled_code:
__int64 initDisplay()
{
flag_dessin[0] = 1;
flag_dessin[1] = 0;
flag_dessin[2] = 0;
flag_dessin[3] = 0;
flag_dessin[4] = 0;
instantPrec = glutGet(700LL);
glDisable(3553LL);
glActiveTextureARB(33984LL);
glBindTexture(3553LL, 0LL);
glDisable(3553LL);
glDisable(2977LL);
glDisable(2929LL);
glDisable(2884LL);
glMatrixMode(5890LL);
glLoadIdentity();
glMatrixMode(5888LL);
glShadeModel(7425LL);
glDisable(3042LL);
glDisable(2912LL);
glBindTexture(3553LL, 0LL);
glDisable(3553LL);
return _check_gl(0xC0u, (__int64)"src/interface.c");
}

canonical_decompiled_code:
__int64 func7()
{
flag_dessin[0] = 1;
flag_dessin[1] = 0;
flag_dessin[2] = 0;
flag_dessin[3] = 0;
flag_dessin[4] = 0;
instantPrec = glutGet(700LL);
glDisable(3553LL);
glActiveTextureARB(33984LL);
glBindTexture(3553LL, 0LL);
glDisable(3553LL);
glDisable(2977LL);
glDisable(2929LL);
glDisable(2884LL);
glMatrixMode(5890LL);
glLoadIdentity();
glMatrixMode(5888LL);
glShadeModel(7425LL);
glDisable(3042LL);
glDisable(2912LL);
glBindTexture(3553LL, 0LL);
glDisable(3553LL);
return func6(0xC0u, (__int64)"src/interface.c");
}

original_code:
void initDisplay() {
 flag_dessin[0] = 1;
 flag_dessin[1] = 0;
 flag_dessin[2] = 0;
 flag_dessin[3] = 0;
 flag_dessin[4] = 0;
 instantPrec = glutGet(0x02BC);
 glDisable(0x0DE1);
 glActiveTextureARB(0x84C0);
 glBindTexture(0x0DE1,0);
 glDisable(0x0DE1);
 glDisable(0x0BA1);
 glDisable(0x0B71);
 glDisable(0x0B44);
 glMatrixMode(0x1702);
  glLoadIdentity();
 glMatrixMode(0x1700);
 glShadeModel(0x1D01);
 glDisable(0x0BE2);
 glDisable(0x0B60);
 glBindTexture(0x0DE1,0);
 glDisable(0x0DE1);
 __check_gl(192, "src/interface.c");
}


decompiled_code:
__int64 __fastcall initGLIMAGIMP_IHM(unsigned int a1, unsigned int a2, __int64 a3, unsigned int a4, unsigned int a5)
{
_QWORD *v5; // rbx
_QWORD *v6; // rax
int v8[3]; // [rsp+Ch] [rbp-Ch] BYREF

cptidletime = 0;
flag_test = 0;
flag_fichier = 0;
width_ecran = a4;
height_ecran = a5;
width_image = a1;
height_image = a2;
if ( a5 < a2 || a4 < a1 )
{
printf("ERREUR : la taille de l'image est plus grande que la taille ecran");
exit(1);
}
image_src = a3;
glPixelStorei(3317LL, 1LL);
initDisplay();
v8[0] = 0;
v5 = malloc(8uLL);
v6 = calloc(0x14uLL, 1uLL);
*v5 = v6;
*v6 = 0x706D6967616D69LL;
glutInit(v8, v5);
glutInitDisplayMode(18LL);
glutInitWindowPosition(0LL, 0LL);
glutInitWindowSize(width_ecran, height_ecran);
if ( !(unsigned int)glutCreateWindow("IMAGIMP") )
{
puts(LC15);
exit(1);
}
glutReshapeFunc(reshapeFunc);
glutDisplayFunc(drawScene_GLIMAGIMP);
glutMouseFunc(clickMouse_GLIMAGIMP);
glutKeyboardFunc(kbdFunc_GLIMAGIMP);
glutSpecialFunc(kbdSpFunc_GLIMAGIMP);
glutIdleFunc(idleFunc);
return glutMainLoop();
}

canonical_decompiled_code:
__int64 __fastcall func8(unsigned int a1, unsigned int a2, __int64 a3, unsigned int a4, unsigned int a5)
{
_QWORD *v5; // rbx
_QWORD *v6; // rax
int v8[3]; // [rsp+Ch] [rbp-Ch] BYREF

cptidletime = 0;
flag_test = 0;
flag_fichier = 0;
width_ecran = a4;
height_ecran = a5;
width_image = a1;
height_image = a2;
if ( a5 < a2 || a4 < a1 )
{
printf("ERREUR : la taille de l'image est plus grande que la taille ecran");
exit(1);
}
image_src = a3;
glPixelStorei(3317LL, 1LL);
func7();
v8[0] = 0;
v5 = malloc(8uLL);
v6 = calloc(0x14uLL, 1uLL);
*v5 = v6;
*v6 = 0x706D6967616D69LL;
glutInit(v8, v5);
glutInitDisplayMode(18LL);
glutInitWindowPosition(0LL, 0LL);
glutInitWindowSize(width_ecran, height_ecran);
if ( !(unsigned int)glutCreateWindow("IMAGIMP") )
{
puts(LC15);
exit(1);
}
glutReshapeFunc(reshapeFunc);
glutDisplayFunc(drawScene_GLIMAGIMP);
glutMouseFunc(clickMouse_GLIMAGIMP);
glutKeyboardFunc(kbdFunc_GLIMAGIMP);
glutSpecialFunc(kbdSpFunc_GLIMAGIMP);
glutIdleFunc(idleFunc);
return glutMainLoop();
}

original_code:
void initGLIMAGIMP_IHM(unsigned int w_im,unsigned int h_im,unsigned char *tabRVB,
           unsigned int w_ecran,unsigned int h_ecran)
{
 cptidletime = 0;
 flag_test = 0;
 flag_fichier = 0;
 width_ecran = w_ecran;
 height_ecran = h_ecran;
 width_image = w_im;
 height_image = h_im;
 if ((width_image>width_ecran) || (height_image>height_ecran)) {
  printf("ERREUR : la taille de l'image est plus grande que la taille ecran");
  exit(1);
 }
 image_src = tabRVB;
 glPixelStorei(0x0CF5,1);
 initDisplay();
 int argc = 0;
 char** argv = (char**) malloc(sizeof(char*));
 argv[0] = (char*) calloc(20,sizeof(char));
 sprintf(argv[0],"imagimp");
 glutInit(&argc, argv);
 glutInitDisplayMode(0x0000 | 0x0010 | 0x0002);
 glutInitWindowPosition(0, 0);
 glutInitWindowSize(width_ecran, height_ecran);
 if (glutCreateWindow("IMAGIMP") == 0) {
  printf("Impossible de créer la fenetre GL\n");
  exit(1);
 }
 glutReshapeFunc(reshapeFunc);
 glutDisplayFunc(drawScene_GLIMAGIMP);
 glutMouseFunc(clickMouse_GLIMAGIMP);
 glutKeyboardFunc(kbdFunc_GLIMAGIMP);
 glutSpecialFunc(kbdSpFunc_GLIMAGIMP);
 glutIdleFunc(idleFunc);
 glutMainLoop();
}

canonical_original_code:
void initGLIMAGIMP_IHM(unsigned int w_im, unsigned int h_im, unsigned char *tabRVB, unsigned int w_ecran, unsigned int h_ecran)
{
 cptidletime = 0;
 flag_test = 0;
 flag_fichier = 0;
 width_ecran = w_ecran;
 height_ecran = h_ecran;
 width_image = w_im;
 height_image = h_im;
 if ((width_image>width_ecran) || (height_image>height_ecran)) {
  printf("ERREUR : la taille de l'image est plus grande que la taille ecran");
  exit(1);
 }
 image_src = tabRVB;
 glPixelStorei(0x0CF5,1);
 initDisplay();
 int argc = 0;
 char **argv = (char**) malloc(sizeof(char*));
 argv[0] = (char *) calloc(20,sizeof(char));
 sprintf(argv[0],"imagimp");
 glutInit(&argc, argv);
 glutInitDisplayMode(0x0000 | 0x0010 | 0x0002);
 glutInitWindowPosition(0, 0);
 glutInitWindowSize(width_ecran, height_ecran);
 if (glutCreateWindow("IMAGIMP") == 0) {
  printf("Impossible de créer la fenetre GL\n");
  exit(1);
 }
 glutReshapeFunc(reshapeFunc);
 glutDisplayFunc(drawScene_GLIMAGIMP);
 glutMouseFunc(clickMouse_GLIMAGIMP);
 glutKeyboardFunc(kbdFunc_GLIMAGIMP);
 glutSpecialFunc(kbdSpFunc_GLIMAGIMP);
 glutIdleFunc(idleFunc);
 glutMainLoop();
}

variable_types:
tabRVB
unsigned char *

variable_types: argc int

variable_types:
argv
char **


initGLIMAGIMP

decompiled_code:
__int64 __fastcall initGLIMAGIMP(unsigned int a1, unsigned int a2, __int64 a3)
{
return initGLIMAGIMP_IHM(a1, a2, a3, a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func9(unsigned int a1, unsigned int a2, __int64 a3)
{
return func8(a1, a2, a3, a1, a2);
}

original_code:
void initGLIMAGIMP(unsigned int w,unsigned int h,unsigned char *tabRVB)
{
 initGLIMAGIMP_IHM(w,h,tabRVB,w,h);
}

canonical_original_code:
void initGLIMAGIMP(unsigned int w, unsigned int h, unsigned char *tabRVB)
{
 initGLIMAGIMP_IHM(w,h,tabRVB,w,h);
}

variable_types:
w
unsigned int

variable_types:
h
unsigned int


printInfo

decompiled_code:
int printInfo()
{
putchar(10);
puts("**************************************");
puts(" INFORMATIONS ");
printf("Taille ecran : %d/%d", width_ecran, height_ecran);
printf("Taille image : %d/%d", width_image, height_image);
printf("Fonction dessin ");
if ( !fct_dessin_user )
printf("non");
puts(LC22);
printf("Fonction souris ");
if ( !fct_clic_souris_user )
printf("non");
puts(LC22);
printf("Fonction clavier ");
if ( !fct_clavier_user )
printf("non");
puts(LC22);
printf("Fonction clavier speciale ");
if ( !fct_clavier_spe_user )
printf("non");
puts(LC22);
return puts("**************************************");
}

canonical_decompiled_code:
int func10()
{
putchar(10);
puts("**************************************");
puts(" INFORMATIONS ");
printf("Taille ecran : %d/%d", width_ecran, height_ecran);
printf("Taille image : %d/%d", width_image, height_image);
printf("Fonction dessin ");
if ( !fct_dessin_user )
printf("non");
puts(LC22);
printf("Fonction souris ");
if ( !fct_clic_souris_user )
printf("non");
puts(LC22);
printf("Fonction clavier ");
if ( !fct_clavier_user )
printf("non");
puts(LC22);
printf("Fonction clavier speciale ");
if ( !fct_clavier_spe_user )
printf("non");
puts(LC22);
return puts("**************************************");
}

original_code:
void printInfo() {
 printf("\n");
 printf("**************************************\n");
 printf("              INFORMATIONS            \n");
 printf("Taille ecran : %d/%d",width_ecran,height_ecran);
 printf("Taille image : %d/%d",width_image,height_image);
 printf("Fonction dessin ");
 if (fct_dessin_user == ((void *)0)) printf("non");
 printf(" fixée\n");
 printf("Fonction souris ");
 if (fct_clic_souris_user == ((void *)0)) printf("non");
 printf(" fixée\n");
 printf("Fonction clavier ");
 if (fct_clavier_user == ((void *)0)) printf("non");
 printf(" fixée\n");
 printf("Fonction clavier speciale ");
 if (fct_clavier_spe_user == ((void *)0)) printf("non");
 printf(" fixée\n");
 printf("**************************************\n");
}


writeString

decompiled_code:
__int64 __fastcall writeString(_BYTE *a1)
{
_BYTE *v1; // rbx
char v2; // si

v1 = a1;
((void (*)(void))glRasterPos2f)();
v2 = *a1;
if ( *a1 )
{
do
{
glutBitmapCharacter(&glutBitmap8By13, (unsigned int)v2);
v2 = *++v1;
}
while ( *v1 );
}
return glRasterPos2f(0.0);
}

canonical_decompiled_code:
__int64 __fastcall func0(_BYTE *a1)
{
_BYTE *v1; // rbx
char v2; // si

v1 = a1;
((void (*)(void))glRasterPos2f)();
v2 = *a1;
if ( *a1 )
{
do
{
glutBitmapCharacter(&glutBitmap8By13, (unsigned int)v2);
v2 = *++v1;
}
while ( *v1 );
}
return glRasterPos2f(0.0);
}

original_code:
void writeString(float x, float y, char* s)
{
  char* c;
  glRasterPos2f(x, y);
  for (c=s; *c != '\0'; c++)
   glutBitmapCharacter(((void *) &glutBitmap8By13), *c );
  glRasterPos2f(0, 0);
}

canonical_original_code:
void writeString(float x, float y, char *s)
{
  char *c;
  glRasterPos2f(x, y);
  for (c=s; *c != '\0'; c++)
   glutBitmapCharacter(((void *) &glutBitmap8By13), *c );
  glRasterPos2f(0, 0);
}

variable_types: x float

variable_types: y float

variable_types:
s
char *

variable_types:
c
char *


fixeCouleur

decompiled_code:
__int64 fixeCouleur()
{
return glColor3f();
}

canonical_decompiled_code:
__int64 func1()
{
return glColor3f();
}

original_code:
void fixeCouleur(float r,float v,float b) {
 glColor3f(r,v,b);
}

canonical_original_code:
void fixeCouleur(float r, float v, float b) {
 glColor3f(r,v,b);
}

variable_types: r float

variable_types: v float

variable_types: b float


drawLigne

decompiled_code:
__int64 __fastcall drawLigne(float a1, float a2, float a3, float a4)
{
glBegin(1LL);
glVertex3f(a1, a2, 0.0);
glVertex3f(a3, a4, 0.0);
return glEnd();
}

canonical_decompiled_code:
__int64 __fastcall func2(float a1, float a2, float a3, float a4)
{
glBegin(1LL);
glVertex3f(a1, a2, 0.0);
glVertex3f(a3, a4, 0.0);
return glEnd();
}

original_code:
void drawLigne(float depart_x,float depart_y,float fin_x,float fin_y) {
 glBegin(0x0001);
  glVertex3f(depart_x,depart_y,0.0);
  glVertex3f(fin_x,fin_y,0.0);
 glEnd();
}

canonical_original_code:
void drawLigne(float depart_x, float depart_y, float fin_x, float fin_y) {
 glBegin(0x0001);
  glVertex3f(depart_x,depart_y,0.0);
  glVertex3f(fin_x,fin_y,0.0);
 glEnd();
}


drawCarre

decompiled_code:
__int64 __fastcall drawCarre(float a1, float a2, float a3, float a4)
{
glBegin(7LL);
glVertex3f(a1, a2, 0.0);
glVertex3f(a3, a2, 0.0);
glVertex3f(a3, a4, 0.0);
glVertex3f(a1, a4, 0.0);
return glEnd();
}

canonical_decompiled_code:
__int64 __fastcall func3(float a1, float a2, float a3, float a4)
{
glBegin(7LL);
glVertex3f(a1, a2, 0.0);
glVertex3f(a3, a2, 0.0);
glVertex3f(a3, a4, 0.0);
glVertex3f(a1, a4, 0.0);
return glEnd();
}

original_code:
void drawCarre(float coin_inf_gauche_x,float coin_inf_gauche_y,
        float coin_sup_droit_x,float coin_sup_droit_y) {
 glBegin(0x0007);
  glVertex3f(coin_inf_gauche_x,coin_inf_gauche_y,0.0);
  glVertex3f(coin_sup_droit_x,coin_inf_gauche_y,0.0);
  glVertex3f(coin_sup_droit_x,coin_sup_droit_y,0.0);
  glVertex3f(coin_inf_gauche_x,coin_sup_droit_y,0.0);
 glEnd();
}

canonical_original_code:
void drawCarre(float coin_inf_gauche_x, float coin_inf_gauche_y, float coin_sup_droit_x, float coin_sup_droit_y) {
 glBegin(0x0007);
  glVertex3f(coin_inf_gauche_x,coin_inf_gauche_y,0.0);
  glVertex3f(coin_sup_droit_x,coin_inf_gauche_y,0.0);
  glVertex3f(coin_sup_droit_x,coin_sup_droit_y,0.0);
  glVertex3f(coin_inf_gauche_x,coin_sup_droit_y,0.0);
 glEnd();
}


drawCarreVide

decompiled_code:
__int64 __fastcall drawCarreVide(float a1, float a2, float a3, float a4)
{
glBegin(2LL);
glVertex3f(a1, a2, 0.0);
glVertex3f(a3, a2, 0.0);
glVertex3f(a3, a4, 0.0);
glVertex3f(a1, a4, 0.0);
return glEnd();
}

canonical_decompiled_code:
__int64 __fastcall func4(float a1, float a2, float a3, float a4)
{
glBegin(2LL);
glVertex3f(a1, a2, 0.0);
glVertex3f(a3, a2, 0.0);
glVertex3f(a3, a4, 0.0);
glVertex3f(a1, a4, 0.0);
return glEnd();
}

original_code:
void drawCarreVide(float coin_inf_gauche_x,float coin_inf_gauche_y,
        float coin_sup_droit_x,float coin_sup_droit_y) {
 glBegin(0x0002);
  glVertex3f(coin_inf_gauche_x,coin_inf_gauche_y,0.0);
  glVertex3f(coin_sup_droit_x,coin_inf_gauche_y,0.0);
  glVertex3f(coin_sup_droit_x,coin_sup_droit_y,0.0);
  glVertex3f(coin_inf_gauche_x,coin_sup_droit_y,0.0);
 glEnd();
}

canonical_original_code:
void drawCarreVide(float coin_inf_gauche_x, float coin_inf_gauche_y, float coin_sup_droit_x, float coin_sup_droit_y) {
 glBegin(0x0002);
  glVertex3f(coin_inf_gauche_x,coin_inf_gauche_y,0.0);
  glVertex3f(coin_sup_droit_x,coin_inf_gauche_y,0.0);
  glVertex3f(coin_sup_droit_x,coin_sup_droit_y,0.0);
  glVertex3f(coin_inf_gauche_x,coin_sup_droit_y,0.0);
 glEnd();
}


drawDisque

decompiled_code:
__int64 __fastcall drawDisque(float a1, float a2, float a3)
{
__m128i v3; // xmm1
__m128i v4; // xmm5
float v5; // ebx
double v6; // r14
int v7; // ebx
float v8; // xmm0_4
float v9; // xmm1_4
float v11; // [rsp+0h] [rbp-48h]
double cosx; // [rsp+10h] [rbp-38h] BYREF
double sinx[6]; // [rsp+18h] [rbp-30h] BYREF

v3 = 0LL;
*(float *)v3.m128i_i32 = (float)width_ecran;
v4 = v3;
*(float *)v4.m128i_i32 = (float)width_ecran / (float)height_ecran;
v5 = COERCE_FLOAT(_mm_cvtsi128_si32(v4));
glBegin(6LL);
glVertex3f(a1, a2, 0.0);
v6 = (float)(v5 * a3);
v7 = 129;
v11 = 0.0;
do
{
sincos(v11, sinx, &cosx);
v8 = a3 * cosx + a1;
v9 = v6 * sinx[0] + a2;
glVertex3f(v8, v9, 0.0);
v11 = v11 + 0.049087387;
--v7;
}
while ( v7 );
return glEnd();
}

canonical_decompiled_code:
__int64 __fastcall func5(float a1, float a2, float a3)
{
__m128i v3; // xmm1
__m128i v4; // xmm5
float v5; // ebx
double v6; // r14
int v7; // ebx
float v8; // xmm0_4
float v9; // xmm1_4
float v11; // [rsp+0h] [rbp-48h]
double cosx; // [rsp+10h] [rbp-38h] BYREF
double sinx[6]; // [rsp+18h] [rbp-30h] BYREF

v3 = 0LL;
*(float *)v3.m128i_i32 = (float)width_ecran;
v4 = v3;
*(float *)v4.m128i_i32 = (float)width_ecran / (float)height_ecran;
v5 = COERCE_FLOAT(_mm_cvtsi128_si32(v4));
glBegin(6LL);
glVertex3f(a1, a2, 0.0);
v6 = (float)(v5 * a3);
v7 = 129;
v11 = 0.0;
do
{
sincos(v11, sinx, &cosx);
v8 = a3 * cosx + a1;
v9 = v6 * sinx[0] + a2;
glVertex3f(v8, v9, 0.0);
v11 = v11 + 0.049087387;
--v7;
}
while ( v7 );
return glEnd();
}

original_code:
void drawDisque(float centre_x,float centre_y,float rayon) {
 unsigned int i;
 float pas_rad = 2.*3.14159265358979323846/128.;
 float r = width_ecran/(float)height_ecran;
 float pas_cour = 0.0;
 glBegin(0x0006);
  glVertex3f(centre_x,centre_y,0.0);
  for(i=0;i<=128;i++) {
   glVertex3f(centre_x+rayon*cos(pas_cour),centre_y+r*rayon*sin(pas_cour),0.0);
   pas_cour += pas_rad;
  }
 glEnd();
}

canonical_original_code:
void drawDisque(float centre_x, float centre_y, float rayon) {
 unsigned int i;
 float pas_rad = 2.*3.14159265358979323846/128.;
 float r = width_ecran/(float)height_ecran;
 float pas_cour = 0.0;
 glBegin(0x0006);
  glVertex3f(centre_x,centre_y,0.0);
  for(i=0;i<=128;i++) {
   glVertex3f(centre_x+rayon*cos(pas_cour),centre_y+r*rayon*sin(pas_cour),0.0);
   pas_cour += pas_rad;
  }
 glEnd();
}

variable_types: rayon float

variable_types:
i
unsigned int


drawCercle

decompiled_code:
__int64 __fastcall drawCercle(float a1, float a2, float a3)
{
__m128i v3; // xmm1
double v4; // r14
int v5; // ebx
float v6; // xmm0_4
float v7; // xmm1_4
float v9; // [rsp+0h] [rbp-48h]
double cosx; // [rsp+10h] [rbp-38h] BYREF
double sinx[6]; // [rsp+18h] [rbp-30h] BYREF

v3 = 0LL;
*(float *)v3.m128i_i32 = (float)width_ecran / (float)height_ecran;
glBegin(3LL);
v4 = (float)(COERCE_FLOAT(_mm_cvtsi128_si32(v3)) * a3);
v5 = 129;
v9 = 0.0;
do
{
sincos(v9, sinx, &cosx);
v6 = a3 * cosx + a1;
v7 = v4 * sinx[0] + a2;
glVertex3f(v6, v7, 0.0);
v9 = v9 + 0.049087387;
--v5;
}
while ( v5 );
return glEnd();
}

canonical_decompiled_code:
__int64 __fastcall func6(float a1, float a2, float a3)
{
__m128i v3; // xmm1
double v4; // r14
int v5; // ebx
float v6; // xmm0_4
float v7; // xmm1_4
float v9; // [rsp+0h] [rbp-48h]
double cosx; // [rsp+10h] [rbp-38h] BYREF
double sinx[6]; // [rsp+18h] [rbp-30h] BYREF

v3 = 0LL;
*(float *)v3.m128i_i32 = (float)width_ecran / (float)height_ecran;
glBegin(3LL);
v4 = (float)(COERCE_FLOAT(_mm_cvtsi128_si32(v3)) * a3);
v5 = 129;
v9 = 0.0;
do
{
sincos(v9, sinx, &cosx);
v6 = a3 * cosx + a1;
v7 = v4 * sinx[0] + a2;
glVertex3f(v6, v7, 0.0);
v9 = v9 + 0.049087387;
--v5;
}
while ( v5 );
return glEnd();
}

original_code:
void drawCercle(float centre_x,float centre_y,float rayon) {
 unsigned int i;
 float pas_rad = 2.0*3.14159265358979323846/128.;
 float r = width_ecran/(float)height_ecran;
 float pas_cour = 0.0;
 glBegin(0x0003);
  for(i=0;i<=128;i++) {
   glVertex3f(centre_x+rayon*cos(pas_cour),centre_y+r*rayon*sin(pas_cour),0.0);
   pas_cour += pas_rad;
  }
 glEnd();
}

canonical_original_code:
void drawCercle(float centre_x, float centre_y, float rayon) {
 unsigned int i;
 float pas_rad = 2.0*3.14159265358979323846/128.;
 float r = width_ecran/(float)height_ecran;
 float pas_cour = 0.0;
 glBegin(0x0003);
  for(i=0;i<=128;i++) {
   glVertex3f(centre_x+rayon*cos(pas_cour),centre_y+r*rayon*sin(pas_cour),0.0);
   pas_cour += pas_rad;
  }
 glEnd();
}


printSavedLut

decompiled_code:
int __fastcall printSavedLut(__int64 a1)
{
int result; // eax
const char *v2; // rsi

switch ( *(_DWORD *)(a1 + 8) )
{
case 1:
puts("Inversion");
break;
case 2:
printf(aAjoutDeLuminos, *(unsigned int *)(a1 + 12));
break;
case 3:
printf(aDiminutionDeLu, *(unsigned int *)(a1 + 12));
break;
case 4:
printf("Augmentation du contraste : %d\n", *(unsigned int *)(a1 + 12));
break;
case 5:
printf("Diminution du contraste : %d\n", *(unsigned int *)(a1 + 12));
break;
case 6:
puts(aEffetS);
break;
case 7:
puts("Conversion de l'image en noirs et blancs");
break;
default:
fwrite("Fonction LUT inconnue.\n", 1uLL, 0x17uLL, stderr);
break;
}
result = printf("\tSur le calque d'id n°%d\n", *(unsigned int *)(a1 + 20));
v2 = *(const char **)(a1 + 24);
if ( v2 )
result = printf("\tD'image source %s\n", v2);
return result;
}

canonical_decompiled_code:
int __fastcall func3(__int64 a1)
{
int result; // eax
const char *v2; // rsi

switch ( *(_DWORD *)(a1 + 8) )
{
case 1:
puts("Inversion");
break;
case 2:
printf(aAjoutDeLuminos, *(unsigned int *)(a1 + 12));
break;
case 3:
printf(aDiminutionDeLu, *(unsigned int *)(a1 + 12));
break;
case 4:
printf("Augmentation du contraste : %d\n", *(unsigned int *)(a1 + 12));
break;
case 5:
printf("Diminution du contraste : %d\n", *(unsigned int *)(a1 + 12));
break;
case 6:
puts(aEffetS);
break;
case 7:
puts("Conversion de l'image en noirs et blancs");
break;
default:
fwrite("Fonction LUT inconnue.\n", 1uLL, 0x17uLL, stderr);
break;
}
result = printf("\tSur le calque d'id n°%d\n", *(unsigned int *)(a1 + 20));
v2 = *(const char **)(a1 + 24);
if ( v2 )
result = printf("\tD'image source %s\n", v2);
return result;
}

original_code:
void printSavedLut(SavedLut* sL){
 switch(sL->function){
 case INVERT :
  printf("Inversion\n");
 break;
 case ADDLUM :
  printf("Ajout de luminosité : %d\n", sL->functionValue);
 break;
 case DIMLUM :
  printf("Diminution de luminosité : %d\n", sL->functionValue);
 break;
 case ADDCON :
  printf("Augmentation du contraste : %d\n", sL->functionValue);
 break;
 case DIMCON :
  printf("Diminution du contraste : %d\n", sL->functionValue);
 break;
 case SEPIA :
  printf("Effet sépia\n");
 break;
 case GRAY :
  printf("Conversion de l'image en noirs et blancs\n");
 break;
 default : fprintf(stderr,"Fonction LUT inconnue.\n");
 break;
 }
 printf("\tSur le calque d'id n°%d\n", sL->ownerId);
 if(sL->imgName != ((void *)0))
  printf("\tD'image source %s\n", sL->imgName);
}

canonical_original_code:
void printSavedLut(struct saved_lut *sL){
 switch(sL->function){
 case INVERT :
  printf("Inversion\n");
 break;
 case ADDLUM :
  printf("Ajout de luminosité : %d\n", sL->functionValue);
 break;
 case DIMLUM :
  printf("Diminution de luminosité : %d\n", sL->functionValue);
 break;
 case ADDCON :
  printf("Augmentation du contraste : %d\n", sL->functionValue);
 break;
 case DIMCON :
  printf("Diminution du contraste : %d\n", sL->functionValue);
 break;
 case SEPIA :
  printf("Effet sépia\n");
 break;
 case GRAY :
  printf("Conversion de l'image en noirs et blancs\n");
 break;
 default : fprintf(stderr,"Fonction LUT inconnue.\n");
 break;
 }
 printf("\tSur le calque d'id n°%d\n", sL->ownerId);
 if(sL->imgName != ((void *)0))
  printf("\tD'image source %s\n", sL->imgName);
}

variable_types: struct saved_lut { struct layer { int id; struct image { short format; char *comments; char *name; int width; int height; int maxValue; unsigned char *arrayRGB; unsigned char *histoGrey; unsigned char *histoRGB; } *imgSource; struct image *imgFinale; struct image *histoSource; struct image *histoFinal; double opacity; enum layer_operation { SUM=1, MULTIPLICATION=2 } operation; struct list { struct cell { struct cell *next; struct cell *previous; void *userData; } *head; struct cell *cursor; struct cell *bottom; int size; int position; enum list_type { LAYER=0, LUT=1, REVIEW=2, UNKNOWN=3 } type; } *lutList; } *owner; enum lut_function { INVERT=1, ADDLUM=2, DIMLUM=3, ADDCON=4, DIMCON=5, SEPIA=6, GRAY=7, NEUTRAL=0 } function; int functionValue; int maxValue; int ownerId; char *imgName; } *

user_defined_types: struct saved_lut { struct layer *owner; enum lut_function function; int functionValue; int maxValue; int ownerId; char *imgName; }

user_defined_types: struct layer { int id; struct image *imgSource; struct image *imgFinale; struct image *histoSource; struct image *histoFinal; double opacity; enum layer_operation operation; struct list *lutList; }

user_defined_types: struct list { struct cell *head; struct cell *cursor; struct cell *bottom; int size; int position; enum list_type type; }


freeReview

decompiled_code:
__int64 freeReview()
{
return freeListComplete(review);
}

canonical_decompiled_code:
__int64 func7()
{
return freeListComplete(review);
}

original_code:
void freeReview(){
 freeListComplete(review);
}


initReview

decompiled_code:
__int64 initReview()
{
__int64 result; // rax

if ( review )
{
freeReview();
review = 0LL;
}
result = createEmptyList(2LL);
review = result;
return result;
}

canonical_decompiled_code:
__int64 func8()
{
__int64 result; // rax

if ( review )
{
func7();
review = 0LL;
}
result = createEmptyList(2LL);
review = result;
return result;
}

original_code:
void initReview(){
 if(review != ((void *)0)){
  freeReview(review);
  review = ((void *)0);
 }
 review = createEmptyList(REVIEW);
}


regenerateLut

decompiled_code:
size_t __fastcall regenerateLut(__int64 *a1, __int64 a2)
{
__int64 v2; // rdi
size_t result; // rax

if ( a1 )
{
v2 = *a1;
if ( v2 )
{
switch ( *(_DWORD *)(v2 + 20) )
{
case 0:
case 7:
result = neutral(v2, a2);
break;
case 1:
result = invertLut(v2, a2);
break;
case 2:
result = addLum(v2, a2);
break;
case 3:
result = dimLum(v2, a2);
break;
case 4:
case 5:
result = changeContrast(v2, a2);
break;
case 6:
result = sepia(v2);
break;
default:
result = fwrite("Fonction LUT inconnue.\n", 1uLL, 0x17uLL, stderr);
break;
}
}
}
return result;
}

canonical_decompiled_code:
size_t __fastcall func0(__int64 *a1, __int64 a2)
{
__int64 v2; // rdi
size_t result; // rax

if ( a1 )
{
v2 = *a1;
if ( v2 )
{
switch ( *(_DWORD *)(v2 + 20) )
{
case 0:
case 7:
result = neutral(v2, a2);
break;
case 1:
result = invertLut(v2, a2);
break;
case 2:
result = addLum(v2, a2);
break;
case 3:
result = dimLum(v2, a2);
break;
case 4:
case 5:
result = changeContrast(v2, a2);
break;
case 6:
result = sepia(v2);
break;
default:
result = fwrite("Fonction LUT inconnue.\n", 1uLL, 0x17uLL, stderr);
break;
}
}
}
return result;
}

original_code:
void regenerateLut(Lut** lt, Channels* input, Image* img){
 if(lt == ((void *)0) || *lt == ((void *)0))
  return;
 switch((*lt)->function){
  case NEUTRAL : neutral(*lt, input);
  break;
  case INVERT : invertLut(*lt, input);
  break;
  case ADDLUM : addLum (*lt, input);
  break;
  case DIMLUM : dimLum (*lt, input);
  break;
  case ADDCON : changeContrast (*lt, input);
  break;
  case DIMCON :
   changeContrast (*lt, input);
  break;
  case SEPIA :
   sepia(*lt);
  break;
  case GRAY :
   neutral(*lt, input);
  break;
  default : fprintf(stderr,"Fonction LUT inconnue.\n");
  break;
 }
}

canonical_original_code:
void regenerateLut(struct lut **lt, struct Channels *input, struct image *img){
 if(lt == ((void *)0) || *lt == ((void *)0))
  return;
 switch((*lt)->function){
  case NEUTRAL : neutral(*lt, input);
  break;
  case INVERT : invertLut(*lt, input);
  break;
  case ADDLUM : addLum (*lt, input);
  break;
  case DIMLUM : dimLum (*lt, input);
  break;
  case ADDCON : changeContrast (*lt, input);
  break;
  case DIMCON :
   changeContrast (*lt, input);
  break;
  case SEPIA :
   sepia(*lt);
  break;
  case GRAY :
   neutral(*lt, input);
  break;
  default : fprintf(stderr,"Fonction LUT inconnue.\n");
  break;
 }
}

variable_types: struct lut { struct Channels { unsigned char *chan1; unsigned char *chan2; unsigned char *chan3; int size; } *channels; long size; int maxValue; enum lut_function { INVERT=1, ADDLUM=2, DIMLUM=3, ADDCON=4, DIMCON=5, SEPIA=6, GRAY=7, NEUTRAL=0 } function; int valueEffect; } **

variable_types:
input
struct Channels *

variable_types: struct image { short format; char *comments; char *name; int width; int height; int maxValue; unsigned char *arrayRGB; unsigned char *histoGrey; unsigned char *histoRGB; } *


applyLutToImg

original_code:
void applyLutToImg(Image* imgSource, Image* imgFinale, Lut* lut){
 int i;
 if (imgSource==((void *)0) || imgFinale == ((void *)0) || lut==((void *)0) ) return;
 for(i=0; i<(imgSource->width)*(imgSource->height)*3; i+=3){
  imgFinale->arrayRGB[i] = lut->channels->chan1[imgSource->arrayRGB[i]];
  imgFinale->arrayRGB[i+1] = lut->channels->chan2[imgSource->arrayRGB[i+1]];
  imgFinale->arrayRGB[i+2] = lut->channels->chan3[imgSource->arrayRGB[i+2]];
 }
}

canonical_original_code:
void applyLutToImg(struct image *imgSource, struct image *imgFinale, struct lut *lut){
 int i;
 if (imgSource==((void *)0) || imgFinale == ((void *)0) || lut==((void *)0) ) return;
 for(i=0; i<(imgSource->width)*(imgSource->height)*3; i+=3){
  imgFinale->arrayRGB[i] = lut->channels->chan1[imgSource->arrayRGB[i]];
  imgFinale->arrayRGB[i+1] = lut->channels->chan2[imgSource->arrayRGB[i+1]];
  imgFinale->arrayRGB[i+2] = lut->channels->chan3[imgSource->arrayRGB[i+2]];
 }
}

variable_types:
imgFinale
struct image *

variable_types: struct lut { struct Channels { unsigned char *chan1; unsigned char *chan2; unsigned char *chan3; int size; } *channels; long size; int maxValue; enum lut_function { INVERT=1, ADDLUM=2, DIMLUM=3, ADDCON=4, DIMCON=5, SEPIA=6, GRAY=7, NEUTRAL=0 } function; int valueEffect; } *

variable_types: i int


dumpLut

decompiled_code:
int __fastcall dumpLut(_DWORD *a1)
{
int result; // eax

if ( a1 )
{
puts("\n----AFFICHAGE LUT-------");
printf("Adresse : %p\n", a1);
printf("Fonction : ");
switch ( a1[5] )
{
case 0:
puts("Neutre");
break;
case 1:
puts("Inversion");
break;
case 2:
puts("ADDLUM");
break;
case 3:
puts("DIMLUM");
break;
case 4:
puts("ADDCON");
break;
case 5:
puts("DIMCON");
break;
case 6:
puts("SEPIA");
break;
default:
fwrite("Fonction LUT inconnue.\n", 1uLL, 0x17uLL, stderr);
break;
}
result = printf("Valeur : %d\n", (unsigned int)a1[6]);
}
return result;
}

canonical_decompiled_code:
int __fastcall func2(_DWORD *a1)
{
int result; // eax

if ( a1 )
{
puts("\n----AFFICHAGE LUT-------");
printf("Adresse : %p\n", a1);
printf("Fonction : ");
switch ( a1[5] )
{
case 0:
puts("Neutre");
break;
case 1:
puts("Inversion");
break;
case 2:
puts("ADDLUM");
break;
case 3:
puts("DIMLUM");
break;
case 4:
puts("ADDCON");
break;
case 5:
puts("DIMCON");
break;
case 6:
puts("SEPIA");
break;
default:
fwrite("Fonction LUT inconnue.\n", 1uLL, 0x17uLL, stderr);
break;
}
result = printf("Valeur : %d\n", (unsigned int)a1[6]);
}
return result;
}

original_code:
void dumpLut(Lut* lt){
 if(lt == ((void *)0)) return;
 printf("\n----AFFICHAGE LUT-------\n");
 printf("Adresse : %p\n", lt);
 printf("Fonction : ");
 switch(lt->function){
   case NEUTRAL : printf("Neutre\n");
   break;
   case INVERT : printf("Inversion\n");
   break;
   case ADDLUM : printf("ADDLUM\n");
   break;
   case DIMLUM : printf("DIMLUM\n");
   break;
   case ADDCON : printf("ADDCON\n");
   break;
   case DIMCON : printf("DIMCON\n");
   break;
   case SEPIA : printf("SEPIA\n");
   break;
   default : fprintf(stderr,"Fonction LUT inconnue.\n");
   break;
 }
 printf("Valeur : %d\n", lt->valueEffect);
}

canonical_original_code:
void dumpLut(struct lut *lt){
 if(lt == ((void *)0)) return;
 printf("\n----AFFICHAGE LUT-------\n");
 printf("Adresse : %p\n", lt);
 printf("Fonction : ");
 switch(lt->function){
   case NEUTRAL : printf("Neutre\n");
   break;
   case INVERT : printf("Inversion\n");
   break;
   case ADDLUM : printf("ADDLUM\n");
   break;
   case DIMLUM : printf("DIMLUM\n");
   break;
   case ADDCON : printf("ADDCON\n");
   break;
   case DIMCON : printf("DIMCON\n");
   break;
   case SEPIA : printf("SEPIA\n");
   break;
   default : fprintf(stderr,"Fonction LUT inconnue.\n");
   break;
 }
 printf("Valeur : %d\n", lt->valueEffect);
}


freeChannels

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

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

original_code:
void freeChannels(Channels* chan){
 free(chan->chan1);
 free(chan->chan2);
 free(chan->chan3);
 free(chan);
}

canonical_original_code:
void freeChannels(struct Channels *chan){
 free(chan->chan1);
 free(chan->chan2);
 free(chan->chan3);
 free(chan);
}

variable_types: struct Channels { unsigned char *chan1; unsigned char *chan2; unsigned char *chan3; int size; } *


freeLut

decompiled_code:
void __fastcall freeLut(void *ptr)
{
if ( ptr )
{
freeChannels(*(void **)ptr);
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func4(void *ptr)
{
if ( ptr )
{
func3(*(void **)ptr);
free(ptr);
}
}

original_code:
void freeLut(Lut* lt){
 if(lt == ((void *)0)) return;
 freeChannels(lt->channels);
 free(lt);
}

canonical_original_code:
void freeLut(struct lut *lt){
 if(lt == ((void *)0)) return;
 freeChannels(lt->channels);
 free(lt);
}


RLdebug

decompiled_code:
int __fastcall RLdebug(__int64 a1)
{
__int64 v1; // rbx
int result; // eax

if ( *(_DWORD *)(a1 + 2048) )
{
printf("%g", *(float *)a1);
if ( *(int *)(a1 + 2048) > 1 )
{
v1 = 1LL;
do
printf(", %g", *(float *)(a1 + 8 * v1++));
while ( *(_DWORD *)(a1 + 2048) > (int)v1 );
}
result = putchar(10);
}
return result;
}

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

if ( *(_DWORD *)(a1 + 2048) )
{
printf("%g", *(float *)a1);
if ( *(int *)(a1 + 2048) > 1 )
{
v1 = 1LL;
do
printf(", %g", *(float *)(a1 + 8 * v1++));
while ( *(_DWORD *)(a1 + 2048) > (int)v1 );
}
result = putchar(10);
}
return result;
}

original_code:
void RLdebug(stack *st) {
    if(st->len == 0) return;
    printf("%g", st->arr[0].f);
    for(int i = 1; i < st->len; i++) {
        printf(", %g", st->arr[i].f);
    }
    printf("\n");
}

canonical_original_code:
void RLdebug(struct stack *st) {
    if(st->len == 0) return;
    printf("%g", st->arr[0].f);
    for(int i = 1; i < st->len; i++) {
        printf(", %g", st->arr[i].f);
    }
    printf("\n");
}

variable_types: struct stack { union item { float f; char *s; } arr[256]; int len; } *

user_defined_types: struct stack { union item arr[256]; int len; }


push

decompiled_code:
size_t __fastcall push(__int64 a1, __int64 a2)
{
int v2; // eax
size_t result; // rax

v2 = *(_DWORD *)(a1 + 2048);
if ( v2 == 256 )
return fwrite("stack overflow\n", 1uLL, 0xFuLL, stderr);
*(_QWORD *)(a1 + 8LL * v2) = a2;
result = (unsigned int)(v2 + 1);
*(_DWORD *)(a1 + 2048) = result;
return result;
}

canonical_decompiled_code:
size_t __fastcall func8(__int64 a1, __int64 a2)
{
int v2; // eax
size_t result; // rax

v2 = *(_DWORD *)(a1 + 2048);
if ( v2 == 256 )
return fwrite("stack overflow\n", 1uLL, 0xFuLL, stderr);
*(_QWORD *)(a1 + 8LL * v2) = a2;
result = (unsigned int)(v2 + 1);
*(_DWORD *)(a1 + 2048) = result;
return result;
}

original_code:
void push(stack *st, item n) {
    if(st->len == 256) {
        fprintf(stderr, "stack overflow\n");
        return;
    }
    st->arr[st->len] = n;
    st->len++;
}

canonical_original_code:
void push(struct stack *st, union item n) {
    if(st->len == 256) {
        fprintf(stderr, "stack overflow\n");
        return;
    }
    st->arr[st->len] = n;
    st->len++;
}

variable_types:
n
union item


RLlshift

original_code:
void RLlshift(stack *st) {
    if(st->len == 0 || st->len == 1) return;
    item n = st->arr[0];
    st->len--;
    for(int i = 1; i <= st->len; i++) {
        st->arr[i - 1] = st->arr[i];
    }
    push(st, n);
}

canonical_original_code:
void RLlshift(struct stack *st) {
    if(st->len == 0 || st->len == 1) return;
    union item n = st->arr[0];
    st->len--;
    for(int i = 1; i <= st->len; i++) {
        st->arr[i - 1] = st->arr[i];
    }
    push(st, n);
}

variable_types:
n
union item { float f; char *s; }


pop

original_code:
item pop(stack *st) {
    if(st->len == 0)
        return (item) {0};
    st->len--;
    item n = st->arr[st->len];
    st->arr[st->len] = (item) {0};
    return n;
}

canonical_original_code:
union item pop(struct stack *st) {
    if(st->len == 0)
        return (union item) {0};
    st->len--;
    union item n = st->arr[st->len];
    st->arr[st->len] = (union item) {0};
    return n;
}

variable_types: struct stack { union item arr[256]; int len; } *

return_type: union item { float f; char *s; }


RLdrop

decompiled_code:
// attributes: thunk
__int64 __fastcall RLdrop(__int64 a1)
{
return pop(a1);
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1)
{
return func10(a1);
}

original_code:
void RLdrop(stack *st) {
    pop(st);
}

canonical_original_code:
void RLdrop(struct stack *st) {
    pop(st);
}


RLtype

decompiled_code:
int __fastcall RLtype(__int64 a1)
{
const char *v1; // rax

v1 = (const char *)pop(a1);
return puts(v1);
}

canonical_decompiled_code:
int __fastcall func12(__int64 a1)
{
const char *v1; // rax

v1 = (const char *)func10(a1);
return puts(v1);
}

original_code:
void RLtype(stack *st) {
    printf("%s\n", pop(st).s);
}

canonical_original_code:
void RLtype(struct stack *st) {
    printf("%s\n", pop(st).s);
}


RLrshift

original_code:
void RLrshift(stack *st) {
    if(st->len == 0 || st->len == 1) return;
    item n = pop(st);
    for(int i = st->len; i >= 0; i--) {
        st->arr[i + 1] = st->arr[i];
    }
    st->len++;
    st->arr[0] = n;
}

canonical_original_code:
void RLrshift(struct stack *st) {
    if(st->len == 0 || st->len == 1) return;
    union item n = pop(st);
    for(int i = st->len; i >= 0; i--) {
        st->arr[i + 1] = st->arr[i];
    }
    st->len++;
    st->arr[0] = n;
}


RLfind

decompiled_code:
int __fastcall RLfind(char *s1, __int64 a2)
{
__int64 i; // rbx
int result; // eax

for ( i = 0LL; i != 80; i += 16LL )
{
result = strcasecmp(s1, *(const char **)((char *)&RLwordlist + i));
if ( result < 0 )
break;
if ( !result )
result = (*(int (__fastcall **)(__int64))((char *)&off_402328 + i))(a2);
}
return result;
}

canonical_decompiled_code:
int __fastcall func14(char *s1, __int64 a2)
{
__int64 i; // rbx
int result; // eax

for ( i = 0LL; i != 80; i += 16LL )
{
result = strcasecmp(s1, *(const char **)((char *)&RLwordlist + i));
if ( result < 0 )
break;
if ( !result )
result = (*(int (__fastcall **)(__int64))((char *)&off_402328 + i))(a2);
}
return result;
}

original_code:
void RLfind(char *word, stack *st) {
    int n;
    for(int i = 0; i < sizeof(RLwordlist)/sizeof(*RLwordlist); i++) {
        n = strcasecmp(word, RLwordlist[i].word);
        if(n < 0) break;
        if(n == 0) (*(RLwordlist[i].func))(st);
    }
}

canonical_original_code:
void RLfind(char *word, struct stack *st) {
    int n;
    for(int i = 0; i < sizeof(RLwordlist)/sizeof(*RLwordlist); i++) {
        n = strcasecmp(word, RLwordlist[i].word);
        if(n < 0) break;
        if(n == 0) (*(RLwordlist[i].func))(st);
    }
}

variable_types:
word
char *

variable_types: n int


interpret

decompiled_code:
int __fastcall interpret(char *a1, __int64 a2, double a3, double a4, double a5, double a6)
{
char v6; // al
char *v7; // rax
__m128i v8; // xmm4
__m128i v9; // xmm5
__m128i v10; // xmm6
__m128i v11; // xmm7
__m128i v12; // xmm0
__m128i v13; // xmm0
double v14; // xmm0_8
float v16; // [rsp+18h] [rbp-20h]
float v17; // [rsp+18h] [rbp-20h]
float v18; // [rsp+18h] [rbp-20h]
float v19; // [rsp+18h] [rbp-20h]
float v20; // [rsp+18h] [rbp-20h]
float v21; // [rsp+18h] [rbp-20h]
float v22; // [rsp+18h] [rbp-20h]
float v23; // [rsp+18h] [rbp-20h]
float v24; // [rsp+18h] [rbp-20h]
__int64 v25; // [rsp+18h] [rbp-20h]
float v26; // [rsp+18h] [rbp-20h]

__isoc99_sscanf();
v6 = *a1;
if ( *a1 == 48 )
{
LODWORD(v7) = push(a2, 0LL);
}
else if ( v6 == 34 )
{
strtok(0LL, "\"");
a1[strlen(a1)] = 32;
LODWORD(v7) = push(a2, (__int64)(a1 + 1));
}
else if ( a1[1] )
{
LABEL_53:
LODWORD(v7) = RLfind(a1, a2);
}
else
{
switch ( v6 )
{
case '!':
if ( COERCE_FLOAT(pop(a2)) == 0.0 )
v13 = (__m128i)0xBF800000;
else
v13 = 0LL;
push(a2, (unsigned int)_mm_cvtsi128_si32(v13));
goto LABEL_32;
case '&':
LODWORD(v22) = pop(a2);
if ( COERCE_FLOAT(pop(a2)) == 0.0 )
{
v12 = 0LL;
}
else if ( v22 == 0.0 )
{
v12 = 0LL;
}
else
{
v12 = (__m128i)0xBF800000;
}
goto LABEL_35;
case '*':
v18 = COERCE_FLOAT(pop(a2));
v10 = _mm_cvtsi32_si128(pop(a2));
*(float *)v10.m128i_i32 = *(float *)v10.m128i_i32 * v18;
LODWORD(v7) = push(a2, (unsigned int)_mm_cvtsi128_si32(v10));
return (int)v7;
case '+':
v16 = COERCE_FLOAT(pop(a2));
v8 = _mm_cvtsi32_si128(pop(a2));
*(float *)v8.m128i_i32 = *(float *)v8.m128i_i32 + v16;
LODWORD(v7) = push(a2, (unsigned int)_mm_cvtsi128_si32(v8));
return (int)v7;
case ',':
LODWORD(v7) = pop(a2);
return (int)v7;
case '-':
v17 = COERCE_FLOAT(pop(a2));
v9 = _mm_cvtsi32_si128(pop(a2));
*(float *)v9.m128i_i32 = *(float *)v9.m128i_i32 - v17;
LODWORD(v7) = push(a2, (unsigned int)_mm_cvtsi128_si32(v9));
return (int)v7;
case '.':
v14 = COERCE_FLOAT(pop(a2));
LODWORD(v7) = printf("%g\n", v14);
return (int)v7;
case '/':
v19 = COERCE_FLOAT(pop(a2));
v11 = _mm_cvtsi32_si128(pop(a2));
*(float *)v11.m128i_i32 = *(float *)v11.m128i_i32 / v19;
LODWORD(v7) = push(a2, (unsigned int)_mm_cvtsi128_si32(v11));
return (int)v7;
case '<':
v21 = COERCE_FLOAT(pop(a2));
v12 = (__m128i)0xBF800000;
if ( v21 <= COERCE_FLOAT(pop(a2)) )
v12 = 0LL;
goto LABEL_35;
case '=':
LABEL_32:
v24 = COERCE_FLOAT(pop(a2));
if ( COERCE_FLOAT(pop(a2)) == v24 )
v12 = (__m128i)0xBF800000;
else
v12 = 0LL;
goto LABEL_35;
case '>':
v20 = COERCE_FLOAT(pop(a2));
v12 = (__m128i)0xBF800000;
if ( COERCE_FLOAT(pop(a2)) <= v20 )
v12 = 0LL;
goto LABEL_35;
case '?':
LODWORD(v26) = pop(a2);
v7 = strtok(0LL, asc_40201F);
if ( !v7 )
return (int)v7;
break;
case '_':
v25 = pop(a2);
push(a2, v25);
LODWORD(v7) = push(a2, v25);
return (int)v7;
case '|':
LODWORD(v23) = pop(a2);
if ( COERCE_FLOAT(pop(a2)) == 0.0 )
{
v12 = 0LL;
if ( v23 != 0.0 )
v12 = (__m128i)0xBF800000;
}
else
{
v12 = (__m128i)0xBF800000;
}
LABEL_35:
LODWORD(v7) = push(a2, (unsigned int)_mm_cvtsi128_si32(v12));
return (int)v7;
default:
goto LABEL_53;
}
while ( *v7 != 58 || v7[1] )
{
a5 = 0.0;
if ( v26 != 0.0 )
interpret(v7, a2, 0.0, a4, 0.0, a6);
v7 = strtok(0LL, asc_40201F);
if ( !v7 )
return (int)v7;
}
do
{
if ( *v7 == 59 && !v7[1] )
break;
if ( v26 == 0.0 )
interpret(v7, a2, 0.0, a4, a5, 0.0);
v7 = strtok(0LL, asc_40201F);
}
while ( v7 );
}
return (int)v7;
}

canonical_decompiled_code:
int __fastcall func15(char *a1, __int64 a2, double a3, double a4, double a5, double a6)
{
char v6; // al
char *v7; // rax
__m128i v8; // xmm4
__m128i v9; // xmm5
__m128i v10; // xmm6
__m128i v11; // xmm7
__m128i v12; // xmm0
__m128i v13; // xmm0
double v14; // xmm0_8
float v16; // [rsp+18h] [rbp-20h]
float v17; // [rsp+18h] [rbp-20h]
float v18; // [rsp+18h] [rbp-20h]
float v19; // [rsp+18h] [rbp-20h]
float v20; // [rsp+18h] [rbp-20h]
float v21; // [rsp+18h] [rbp-20h]
float v22; // [rsp+18h] [rbp-20h]
float v23; // [rsp+18h] [rbp-20h]
float v24; // [rsp+18h] [rbp-20h]
__int64 v25; // [rsp+18h] [rbp-20h]
float v26; // [rsp+18h] [rbp-20h]

__isoc99_sscanf();
v6 = *a1;
if ( *a1 == 48 )
{
LODWORD(v7) = func8(a2, 0LL);
}
else if ( v6 == 34 )
{
strtok(0LL, "\"");
a1[strlen(a1)] = 32;
LODWORD(v7) = func8(a2, (__int64)(a1 + 1));
}
else if ( a1[1] )
{
LABEL_53:
LODWORD(v7) = func14(a1, a2);
}
else
{
switch ( v6 )
{
case '!':
if ( COERCE_FLOAT(pop(a2)) == 0.0 )
v13 = (__m128i)0xBF800000;
else
v13 = 0LL;
func8(a2, (unsigned int)_mm_cvtsi128_si32(v13));
goto LABEL_32;
case '&':
LODWORD(v22) = func10(a2);
if ( COERCE_FLOAT(pop(a2)) == 0.0 )
{
v12 = 0LL;
}
else if ( v22 == 0.0 )
{
v12 = 0LL;
}
else
{
v12 = (__m128i)0xBF800000;
}
goto LABEL_35;
case '*':
v18 = COERCE_FLOAT(pop(a2));
v10 = _mm_cvtsi32_si128(pop(a2));
*(float *)v10.m128i_i32 = *(float *)v10.m128i_i32 * v18;
LODWORD(v7) = func8(a2, (unsigned int)_mm_cvtsi128_si32(v10));
return (int)v7;
case '+':
v16 = COERCE_FLOAT(pop(a2));
v8 = _mm_cvtsi32_si128(pop(a2));
*(float *)v8.m128i_i32 = *(float *)v8.m128i_i32 + v16;
LODWORD(v7) = func8(a2, (unsigned int)_mm_cvtsi128_si32(v8));
return (int)v7;
case ',':
LODWORD(v7) = func10(a2);
return (int)v7;
case '-':
v17 = COERCE_FLOAT(pop(a2));
v9 = _mm_cvtsi32_si128(pop(a2));
*(float *)v9.m128i_i32 = *(float *)v9.m128i_i32 - v17;
LODWORD(v7) = func8(a2, (unsigned int)_mm_cvtsi128_si32(v9));
return (int)v7;
case '.':
v14 = COERCE_FLOAT(pop(a2));
LODWORD(v7) = printf("%g\n", v14);
return (int)v7;
case '/':
v19 = COERCE_FLOAT(pop(a2));
v11 = _mm_cvtsi32_si128(pop(a2));
*(float *)v11.m128i_i32 = *(float *)v11.m128i_i32 / v19;
LODWORD(v7) = func8(a2, (unsigned int)_mm_cvtsi128_si32(v11));
return (int)v7;
case '<':
v21 = COERCE_FLOAT(pop(a2));
v12 = (__m128i)0xBF800000;
if ( v21 <= COERCE_FLOAT(pop(a2)) )
v12 = 0LL;
goto LABEL_35;
case '=':
LABEL_32:
v24 = COERCE_FLOAT(pop(a2));
if ( COERCE_FLOAT(pop(a2)) == v24 )
v12 = (__m128i)0xBF800000;
else
v12 = 0LL;
goto LABEL_35;
case '>':
v20 = COERCE_FLOAT(pop(a2));
v12 = (__m128i)0xBF800000;
if ( COERCE_FLOAT(pop(a2)) <= v20 )
v12 = 0LL;
goto LABEL_35;
case '?':
LODWORD(v26) = func10(a2);
v7 = strtok(0LL, asc_40201F);
if ( !v7 )
return (int)v7;
break;
case '_':
v25 = func10(a2);
func8(a2, v25);
LODWORD(v7) = func8(a2, v25);
return (int)v7;
case '|':
LODWORD(v23) = func10(a2);
if ( COERCE_FLOAT(pop(a2)) == 0.0 )
{
v12 = 0LL;
if ( v23 != 0.0 )
v12 = (__m128i)0xBF800000;
}
else
{
v12 = (__m128i)0xBF800000;
}
LABEL_35:
LODWORD(v7) = func8(a2, (unsigned int)_mm_cvtsi128_si32(v12));
return (int)v7;
default:
goto LABEL_53;
}
while ( *v7 != 58 || v7[1] )
{
a5 = 0.0;
if ( v26 != 0.0 )
func15(v7, a2, 0.0, a4, 0.0, a6);
v7 = strtok(0LL, asc_40201F);
if ( !v7 )
return (int)v7;
}
do
{
if ( *v7 == 59 && !v7[1] )
break;
if ( v26 == 0.0 )
func15(v7, a2, 0.0, a4, a5, 0.0);
v7 = strtok(0LL, asc_40201F);
}
while ( v7 );
}
return (int)v7;
}

original_code:
void interpret(char *word, stack *st) {
    item n = {0};
    char *r;
    sscanf(word, "%g", &n.f);
    if(n.f != 0 || *word == '0') {
        push(st, n);
        return;
    }
    if(*word == '"') {
        strtok(((void *)0), "\"");
        word[strlen(word)] = ' ';
        word++;
        push(st, (item) {.s = word});
        return;
    }
    if(word[1] == 0)
    switch(*word) {
        case '+': n = pop(st); push(st, (item) {pop(st).f + n.f}); return;
        case '-': n = pop(st); push(st, (item) {pop(st).f - n.f}); return;
        case '*': n = pop(st); push(st, (item) {pop(st).f * n.f}); return;
        case '/': n = pop(st); push(st, (item) {pop(st).f / n.f}); return;
        case '>': n = pop(st); push(st, (item) {pop(st).f > n.f ? -1 : 0}); return;
        case '<': n = pop(st); push(st, (item) {pop(st).f < n.f ? -1 : 0}); return;
        case '&': n = pop(st); push(st, (item) {pop(st).f && n.f ? -1 : 0}); return;
        case '|': n = pop(st); push(st, (item) {pop(st).f || n.f ? -1 : 0}); return;
        case '!': push(st, (item) {!pop(st).f ? -1 : 0});
        case '=': n = pop(st); push(st, (item) {pop(st).f == n.f ? -1 : 0}); return;
        case '_':
            n = pop(st);
            push(st, n); push(st, n);
            return;
        case ',':
            pop(st);
            return;
        case '.':
            printf("%g\n", pop(st).f);
            return;
        case '?':
            n = pop(st);
            r = strtok(((void *)0), " \t\n\v\f\r");
            while(r != ((void *)0)) {
                if(*r == ':' && r[1] == 0) break;
                if(n.f) interpret(r, st);
                r = strtok(((void *)0), " \t\n\v\f\r");
            }
            while(r != ((void *)0)) {
                if(*r == ';' && r[1] == 0) break;
                if(!n.f) interpret(r, st);
                r = strtok(((void *)0), " \t\n\v\f\r");
            }
            return;
    }
    RLfind(word, st);
}

canonical_original_code:
void interpret(char *word, struct stack *st) {
    union item n = {0};
    char *r;
    sscanf(word, "%g", &n.f);
    if(n.f != 0 || *word == '0') {
        push(st, n);
        return;
    }
    if(*word == '"') {
        strtok(((void *)0), "\"");
        word[strlen(word)] = ' ';
        word++;
        push(st, (union item) {.s = word});
        return;
    }
    if(word[1] == 0)
    switch(*word) {
        case '+': n = pop(st); push(st, (union item) {pop(st).f + n.f}); return;
        case '-': n = pop(st); push(st, (union item) {pop(st).f - n.f}); return;
        case '*': n = pop(st); push(st, (union item) {pop(st).f * n.f}); return;
        case '/': n = pop(st); push(st, (union item) {pop(st).f / n.f}); return;
        case '>': n = pop(st); push(st, (union item) {pop(st).f > n.f ? -1 : 0}); return;
        case '<': n = pop(st); push(st, (union item) {pop(st).f < n.f ? -1 : 0}); return;
        case '&': n = pop(st); push(st, (union item) {pop(st).f && n.f ? -1 : 0}); return;
        case '|': n = pop(st); push(st, (union item) {pop(st).f || n.f ? -1 : 0}); return;
        case '!': push(st, (union item) {!pop(st).f ? -1 : 0});
        case '=': n = pop(st); push(st, (union item) {pop(st).f == n.f ? -1 : 0}); return;
        case '_':
            n = pop(st);
            push(st, n); push(st, n);
            return;
        case ',':
            pop(st);
            return;
        case '.':
            printf("%g\n", pop(st).f);
            return;
        case '?':
            n = pop(st);
            r = strtok(((void *)0), " \t\n\v\f\r");
            while(r != ((void *)0)) {
                if(*r == ':' && r[1] == 0) break;
                if(n.f) interpret(r, st);
                r = strtok(((void *)0), " \t\n\v\f\r");
            }
            while(r != ((void *)0)) {
                if(*r == ';' && r[1] == 0) break;
                if(!n.f) interpret(r, st);
                r = strtok(((void *)0), " \t\n\v\f\r");
            }
            return;
    }
    RLfind(word, st);
}

variable_types:
r
char *


eval

decompiled_code:
char *__fastcall eval(char *a1, __int64 a2, double a3, double a4, double a5, double a6)
{
char *result; // rax
char *i; // rdi

result = strtok(a1, asc_40201F);
for ( i = result; result; i = result )
{
interpret(i, a2, a3, a4, a5, a6);
result = strtok(0LL, asc_40201F);
}
return result;
}

canonical_decompiled_code:
char *__fastcall func16(char *a1, __int64 a2, double a3, double a4, double a5, double a6)
{
char *result; // rax
char *i; // rdi

result = strtok(a1, asc_40201F);
for ( i = result; result; i = result )
{
func15(i, a2, a3, a4, a5, a6);
result = strtok(0LL, asc_40201F);
}
return result;
}

original_code:
void eval(char input[], stack *st) {
    char *r = ((void *)0);
    r = strtok(input, " \t\n\v\f\r");
    while(r != ((void *)0)) {
        interpret(r, st);
        r = strtok(((void *)0), " \t\n\v\f\r");
    }
}

canonical_original_code:
void eval(char input[], struct stack *st) {
    char *r = ((void *)0);
    r = strtok(input, " \t\n\v\f\r");
    while(r != ((void *)0)) {
        interpret(r, st);
        r = strtok(((void *)0), " \t\n\v\f\r");
    }
}

variable_types:
input
char []


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
double v3; // xmm0_8
double v4; // xmm1_8
double v5; // xmm2_8
double v6; // xmm3_8
char v8[1024]; // [rsp+0h] [rbp-C18h] BYREF
char v9[2048]; // [rsp+400h] [rbp-818h] BYREF
int v10; // [rsp+C00h] [rbp-18h]

v10 = 0;
if ( argc == 1 )
{
while ( fgets(v8, 1024, stdin) )
eval(v8, (__int64)v9, v3, v4, v5, v6);
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
double v3; // xmm0_8
double v4; // xmm1_8
double v5; // xmm2_8
double v6; // xmm3_8
char v8[1024]; // [rsp+0h] [rbp-C18h] BYREF
char v9[2048]; // [rsp+400h] [rbp-818h] BYREF
int v10; // [rsp+C00h] [rbp-18h]

v10 = 0;
if ( argc == 1 )
{
while ( fgets(v8, 1024, stdin) )
func16(v8, (__int64)v9, v3, v4, v5, v6);
}
return 0;
}

original_code:
int main(int argc, char *argv[]) {
    stack stack;
    stack.len = 0;
    if(argc == 1) {
        char input[1024];
        while(fgets(input, 1024, stdin) != ((void *)0)) {
            eval(input, &stack);
        }
    }
}

canonical_original_code:
int main(int argc, char *argv[]) {
    struct stack stack;
    stack.len = 0;
    if(argc == 1) {
        char input[1024];
        while(fgets(input, 1024, stdin) != ((void *)0)) {
            eval(input, &stack);
        }
    }
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: struct stack { union item { float f; char *s; } arr[256]; int len; }

variable_types:
input
char [1024]


repo: LCAV/SparseFHT

decompiled_code:
void __fastcall gf2_free_mat(void *ptr)
{
void *v2; // rdi

if ( ptr )
{
v2 = *(void **)ptr;
if ( v2 )
free(v2);
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func0(void *ptr)
{
void *v2; // rdi

if ( ptr )
{
v2 = *(void **)ptr;
if ( v2 )
free(v2);
free(ptr);
}
}

original_code:
void gf2_free_mat(gf2_matrix_t *U)
{
  if (U != ((void *)0) && U->rows != ((void *)0))
    free(U->rows);
  if (U != ((void *)0))
    free(U);
}

canonical_original_code:
void gf2_free_mat(struct gf2_matrix_t *U)
{
  if (U != ((void *)0) && U->rows != ((void *)0))
    free(U->rows);
  if (U != ((void *)0))
    free(U);
}

variable_types: struct gf2_matrix_t { unsigned int *rows; unsigned long size; } *


original_code:
void gf2_rand_nonsing(gf2_matrix_t *A)
{
  int a, t;
  gf2_matrix_t *T = gf2_alloc_mat(A->size);
  T->size = A->size;
  for (t = 0 ; t < T->size ; t++)
  {
    T->rows[t] = 0;
    A->rows[t] = 0;
  }
  for (a = 0 ; a < A->size ; a++)
  {
    gf2_vector_t v = (random() % ((1 << (A->size - a)) - 1)) + 1;
    int r = -1;
    for (t = 0 ; t < T->size ; t++)
    {
      if (T->rows[t] != 0)
        continue;
      if (v & 1)
      {
        if (r < 0)
        {
          r = t;
          A->rows[a] = t;
        }
        T->rows[r] |= 1 << t;
      }
      v >>= 1;
    }
  }
  for (a = 0 ; a < A->size ; a++)
    A->rows[a] = T->rows[A->rows[a]];
  gf2_free_mat(T);
}

canonical_original_code:
void gf2_rand_nonsing(struct gf2_matrix_t *A)
{
  int a; int t;
  struct gf2_matrix_t *T = gf2_alloc_mat(A->size);
  T->size = A->size;
  for (t = 0 ; t < T->size ; t++)
  {
    T->rows[t] = 0;
    A->rows[t] = 0;
  }
  for (a = 0 ; a < A->size ; a++)
  {
    unsigned int v = (random() % ((1 << (A->size - a)) - 1)) + 1;
    int r = -1;
    for (t = 0 ; t < T->size ; t++)
    {
      if (T->rows[t] != 0)
        continue;
      if (v & 1)
      {
        if (r < 0)
        {
          r = t;
          A->rows[a] = t;
        }
        T->rows[r] |= 1 << t;
      }
      v >>= 1;
    }
  }
  for (a = 0 ; a < A->size ; a++)
    A->rows[a] = T->rows[A->rows[a]];
  gf2_free_mat(T);
}

variable_types: a int

variable_types: t int

variable_types:
v
unsigned int

variable_types: r int

user_defined_types: struct gf2_matrix_t { unsigned int *rows; unsigned long size; }


original_code:
void gf2_transpose(gf2_matrix_t *U)
{
  int r, c;
  gf2_matrix_t *C = gf2_alloc_mat(U->size);
  C->size = U->size;
  for (r = 0 ; r < U->size ; r++)
  {
    C->rows[r] = U->rows[r];
    U->rows[r] = 0;
  }
  for (r = 0 ; r < U->size ; r++)
    for (c = 0 ; c < U->size ; c++)
    {
      U->rows[c] |= (C->rows[r] & 1) << r;
      C->rows[r] >>= 1;
    }
  gf2_free_mat(C);
}

canonical_original_code:
void gf2_transpose(struct gf2_matrix_t *U)
{
  int r; int c;
  struct gf2_matrix_t *C = gf2_alloc_mat(U->size);
  C->size = U->size;
  for (r = 0 ; r < U->size ; r++)
  {
    C->rows[r] = U->rows[r];
    U->rows[r] = 0;
  }
  for (r = 0 ; r < U->size ; r++)
    for (c = 0 ; c < U->size ; c++)
    {
      U->rows[c] |= (C->rows[r] & 1) << r;
      C->rows[r] >>= 1;
    }
  gf2_free_mat(C);
}

variable_types: c int


decompiled_code:
__int64 __fastcall gf2_parity(int a1)
{
return (unsigned __int8)ParityTable256[(unsigned __int8)(BYTE2(a1) ^ a1 ^ ((unsigned __int16)(HIWORD(a1) ^ a1) >> 8))];
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1)
{
return (unsigned __int8)ParityTable256[(unsigned __int8)(BYTE2(a1) ^ a1 ^ ((unsigned __int16)(HIWORD(a1) ^ a1) >> 8))];
}

original_code:
int gf2_parity(gf2_vector_t V)
{
  V ^= (V >> 16);
  V ^= (V >> 8);
  return ParityTable256[V & 0xff];
}

canonical_original_code:
int gf2_parity(unsigned int V)
{
  V ^= (V >> 16);
  V ^= (V >> 8);
  return ParityTable256[V & 0xff];
}

variable_types:
V
unsigned int


decompiled_code:
__int64 __fastcall gf2_mat_vec(__int64 *a1, unsigned int a2)
{
__int64 v2; // r13
__int64 v3; // r14
__int64 v4; // rbx
unsigned int v5; // ebp

v2 = a1[1];
if ( !v2 )
return 0;
v3 = *a1;
v4 = 0LL;
v5 = 0;
do
{
v5 |= (unsigned int)gf2_parity(*(_DWORD *)(v3 + 4 * v4) & a2) << v4;
++v4;
}
while ( v2 != v4 );
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 *a1, unsigned int a2)
{
__int64 v2; // r13
__int64 v3; // r14
__int64 v4; // rbx
unsigned int v5; // ebp

v2 = a1[1];
if ( !v2 )
return 0;
v3 = *a1;
v4 = 0LL;
v5 = 0;
do
{
v5 |= (unsigned int)func3(*(_DWORD *)(v3 + 4 * v4) & a2) << v4;
++v4;
}
while ( v2 != v4 );
return v5;
}

original_code:
gf2_vector_t gf2_mat_vec(gf2_matrix_t *U, gf2_vector_t V)
{
  int r;
  gf2_vector_t p = 0;
  for (r = 0 ; r < U->size ; r++)
  {
    p |= gf2_parity(U->rows[r] & V) << r;
  }
  return p;
}

canonical_original_code:
unsigned int gf2_mat_vec(struct gf2_matrix_t *U, unsigned int V)
{
  int r;
  unsigned int p = 0;
  for (r = 0 ; r < U->size ; r++)
  {
    p |= gf2_parity(U->rows[r] & V) << r;
  }
  return p;
}

variable_types:
p
unsigned int

return_type: unsigned int


decompiled_code:
unsigned __int64 __fastcall gf2_copy(_QWORD *a1, _QWORD *a2)
{
unsigned __int64 result; // rax

result = a1[1];
a2[1] = result;
if ( a1[1] )
{
result = 0LL;
do
{
*(_DWORD *)(*a2 + 4 * result) = *(_DWORD *)(*a1 + 4 * result);
++result;
}
while ( a1[1] > result );
}
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func5(_QWORD *a1, _QWORD *a2)
{
unsigned __int64 result; // rax

result = a1[1];
a2[1] = result;
if ( a1[1] )
{
result = 0LL;
do
{
*(_DWORD *)(*a2 + 4 * result) = *(_DWORD *)(*a1 + 4 * result);
++result;
}
while ( a1[1] > result );
}
return result;
}

original_code:
void gf2_copy(gf2_matrix_t *U, gf2_matrix_t *V)
{
  int r;
  V->size = U->size;
  for (r = 0 ; r < U->size ; r++)
    V->rows[r] = U->rows[r];
}

canonical_original_code:
void gf2_copy(struct gf2_matrix_t *U, struct gf2_matrix_t *V)
{
  int r;
  V->size = U->size;
  for (r = 0 ; r < U->size ; r++)
    V->rows[r] = U->rows[r];
}

variable_types:
V
struct gf2_matrix_t *


decompiled_code:
void __fastcall gf2_mat_vec_array(__int64 *a1, unsigned int *a2, __int64 a3)
{
unsigned int *v3; // rbx
unsigned int *v4; // rbp

if ( a3 )
{
v3 = &a2[a3 - 1];
do
{
v4 = v3;
*v3 = gf2_mat_vec(a1, *v3);
--v3;
}
while ( v4 != a2 );
}
}

canonical_decompiled_code:
void __fastcall func6(__int64 *a1, unsigned int *a2, __int64 a3)
{
unsigned int *v3; // rbx
unsigned int *v4; // rbp

if ( a3 )
{
v3 = &a2[a3 - 1];
do
{
v4 = v3;
*v3 = func4(a1, *v3);
--v3;
}
while ( v4 != a2 );
}
}

original_code:
void gf2_mat_vec_array(gf2_matrix_t *U, gf2_vector_t *V, size_t len)
{
  while (len-- > 0)
    V[len] = gf2_mat_vec(U, V[len]);
}

canonical_original_code:
void gf2_mat_vec_array(struct gf2_matrix_t *U, unsigned int *V, unsigned long len)
{
  while (len-- > 0)
    V[len] = gf2_mat_vec(U, V[len]);
}

variable_types:
V
unsigned int *

variable_types:
len
unsigned long


decompiled_code:
int __fastcall gf2_print_vec(unsigned int a1, unsigned __int64 a2)
{
unsigned __int64 v3; // rbp

v3 = a2;
printf("[ ");
if ( a2 > 1 )
{
do
{
printf("%d ", a1 & 1);
a1 >>= 1;
--v3;
}
while ( v3 != 1 );
}
return printf("%d ]\n", a1 & 1);
}

canonical_decompiled_code:
int __fastcall func7(unsigned int a1, unsigned __int64 a2)
{
unsigned __int64 v3; // rbp

v3 = a2;
printf("[ ");
if ( a2 > 1 )
{
do
{
printf("%d ", a1 & 1);
a1 >>= 1;
--v3;
}
while ( v3 != 1 );
}
return printf("%d ]\n", a1 & 1);
}

original_code:
void gf2_print_vec(gf2_vector_t V, size_t N)
{
  printf("[ ");
  while (N > 1)
  {
    printf("%d ", V & 1);
    V >>= 1;
    N--;
  }
  printf("%d ]\n", V & 1);
}

canonical_original_code:
void gf2_print_vec(unsigned int V, unsigned long N)
{
  printf("[ ");
  while (N > 1)
  {
    printf("%d ", V & 1);
    V >>= 1;
    N--;
  }
  printf("%d ]\n", V & 1);
}

variable_types:
N
unsigned long


decompiled_code:
int __fastcall gf2_print_mat(_QWORD *a1)
{
unsigned __int64 v1; // rsi
unsigned __int64 i; // rbx
int result; // eax

v1 = a1[1];
if ( v1 )
{
for ( i = 0LL; i < v1; ++i )
{
result = gf2_print_vec(*(_DWORD *)(*a1 + 4 * i), v1);
v1 = a1[1];
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func8(_QWORD *a1)
{
unsigned __int64 v1; // rsi
unsigned __int64 i; // rbx
int result; // eax

v1 = a1[1];
if ( v1 )
{
for ( i = 0LL; i < v1; ++i )
{
result = func7(*(_DWORD *)(*a1 + 4 * i), v1);
v1 = a1[1];
}
}
return result;
}

original_code:
void gf2_print_mat(gf2_matrix_t *U)
{
  int r;
  for (r = 0 ; r < U->size ; r++)
    gf2_print_vec(U->rows[r], U->size);
}

canonical_original_code:
void gf2_print_mat(struct gf2_matrix_t *U)
{
  int r;
  for (r = 0 ; r < U->size ; r++)
    gf2_print_vec(U->rows[r], U->size);
}


fht

original_code:
void fht(double *x, size_t n)
{
  if (n == 1)
    return;
  fht(x, n/2);
  fht(x+n/2, n/2);
  int i;
  for (i = 0 ; i < n/2 ; i++)
  {
    double tmp = x[i];
    x[i] = tmp + x[n/2+i];
    x[n/2+i] = tmp - x[n/2+i];
  }
  return;
}

canonical_original_code:
void fht(double *x, unsigned long n)
{
  if (n == 1)
    return;
  fht(x, n/2);
  fht(x+n/2, n/2);
  int i;
  for (i = 0 ; i < n/2 ; i++)
  {
    double tmp = x[i];
    x[i] = tmp + x[n/2+i];
    x[n/2+i] = tmp - x[n/2+i];
  }
  return;
}

variable_types:
x
double *

variable_types:
n
unsigned long

variable_types: i int

variable_types: tmp double


quicksort

original_code:
void quicksort(int *array, int l, int r)
{
  int i,j;
  int key;
  if( l < r)
  {
    int tmp = array[r];
    array[r] = array[(l+r)/2];
    array[(l+r)/2] = tmp;
    key = array[r];
    i = l;
    j = r-1;
    while(i <= j)
    {
      while (i <= r && array[i] <= key)
      {
        i++;
        continue;
      }
      while (j >= l && array[j] > key)
      {
        j--;
        continue;
      }
      if (i < j)
      {
        int t_ind = array[i];
        array[i] = array[j];
        array[j] = t_ind;
      }
    }
    tmp = array[r];
    array[r] = array[j+1];
    array[j+1] = tmp;
    quicksort(array, l, j);
    quicksort(array, j+2, r);
  }
}

canonical_original_code:
void quicksort(int *array, int l, int r)
{
  int i; int j;
  int key;
  if( l < r)
  {
    int tmp = array[r];
    array[r] = array[(l+r)/2];
    array[(l+r)/2] = tmp;
    key = array[r];
    i = l;
    j = r-1;
    while(i <= j)
    {
      while (i <= r && array[i] <= key)
      {
        i++;
        continue;
      }
      while (j >= l && array[j] > key)
      {
        j--;
        continue;
      }
      if (i < j)
      {
        int t_ind = array[i];
        array[i] = array[j];
        array[j] = t_ind;
      }
    }
    tmp = array[r];
    array[r] = array[j+1];
    array[j+1] = tmp;
    quicksort(array, l, j);
    quicksort(array, j+2, r);
  }
}

variable_types:
array
int *

variable_types: l int

variable_types: j int

variable_types: key int

variable_types: tmp int


original_code:
void swap2(double* value, gf2_vector_t *index, int k, int l)
{
  double t1 = value[k];
  value[k] = value[l];
  value[l] = t1;
  gf2_vector_t t2 = index[k];
  index[k] = index[l];
  index[l] = t2;
}

canonical_original_code:
void swap2(double *value, unsigned int *index, int k, int l)
{
  double t1 = value[k];
  value[k] = value[l];
  value[l] = t1;
  unsigned int t2 = index[k];
  index[k] = index[l];
  index[l] = t2;
}

variable_types:
value
double *

variable_types:
index
unsigned int *

variable_types: k int


decompiled_code:
void __fastcall sparse_quicksort(__int64 a1, __int64 a2, int a3, int a4)
{
unsigned int v6; // er12
int v7; // ebx
int v8; // ebp
unsigned int *v9; // rax
unsigned int *v10; // rax

if ( a3 < a4 )
{
swap2(a1, a2, (a3 + a4) / 2, a4);
v6 = *(_DWORD *)(a2 + 4LL * a4);
v7 = a4 - 1;
v8 = a3;
if ( a3 <= a4 - 1 )
{
do
{
while ( 1 )
{
if ( a4 >= v8 )
{
v10 = (unsigned int *)(a2 + 4LL * v8);
do
{
if ( *v10 > v6 )
break;
++v8;
++v10;
}
while ( a4 >= v8 );
}
if ( a3 <= v7 )
{
v9 = (unsigned int *)(a2 + 4LL * v7);
do
{
if ( *v9 <= v6 )
break;
--v7;
--v9;
}
while ( a3 <= v7 );
}
if ( v8 >= v7 )
break;
swap2(a1, a2, v8, v7);
}
}
while ( v8 == v7 );
}
swap2(a1, a2, v7 + 1, a4);
sparse_quicksort(a1, a2, (unsigned int)a3, (unsigned int)v7);
sparse_quicksort(a1, a2, (unsigned int)(v7 + 2), (unsigned int)a4);
}
}

canonical_decompiled_code:
void __fastcall func2(__int64 a1, __int64 a2, int a3, int a4)
{
unsigned int v6; // er12
int v7; // ebx
int v8; // ebp
unsigned int *v9; // rax
unsigned int *v10; // rax

if ( a3 < a4 )
{
func1(a1, a2, (a3 + a4) / 2, a4);
v6 = *(_DWORD *)(a2 + 4LL * a4);
v7 = a4 - 1;
v8 = a3;
if ( a3 <= a4 - 1 )
{
do
{
while ( 1 )
{
if ( a4 >= v8 )
{
v10 = (unsigned int *)(a2 + 4LL * v8);
do
{
if ( *v10 > v6 )
break;
++v8;
++v10;
}
while ( a4 >= v8 );
}
if ( a3 <= v7 )
{
v9 = (unsigned int *)(a2 + 4LL * v7);
do
{
if ( *v9 <= v6 )
break;
--v7;
--v9;
}
while ( a3 <= v7 );
}
if ( v8 >= v7 )
break;
func1(a1, a2, v8, v7);
}
}
while ( v8 == v7 );
}
func1(a1, a2, v7 + 1, a4);
func2(a1, a2, (unsigned int)a3, (unsigned int)v7);
func2(a1, a2, (unsigned int)(v7 + 2), (unsigned int)a4);
}
}

original_code:
void sparse_quicksort(double *value, gf2_vector_t *index, int l, int r)
{
  int i,j;
  gf2_vector_t key;
  if( l < r)
  {
    swap2(value, index, (l+r)/2, r);
    key = index[r];
    i = l;
    j = r-1;
    while(i <= j)
    {
      while (i <= r && index[i] <= key)
        i++;
      while (j >= l && index[j] > key)
        j--;
      if (i < j)
        swap2(value, index, i, j);
    }
    swap2(value, index, j+1, r);
    sparse_quicksort(value, index, l, j);
    sparse_quicksort(value, index, j+2, r);
  }
}

canonical_original_code:
void sparse_quicksort(double *value, unsigned int *index, int l, int r)
{
  int i; int j;
  unsigned int key;
  if( l < r)
  {
    swap2(value, index, (l+r)/2, r);
    key = index[r];
    i = l;
    j = r-1;
    while(i <= j)
    {
      while (i <= r && index[i] <= key)
        i++;
      while (j >= l && index[j] > key)
        j--;
      if (i < j)
        swap2(value, index, i, j);
    }
    swap2(value, index, j+1, r);
    sparse_quicksort(value, index, l, j);
    sparse_quicksort(value, index, j+2, r);
  }
}

variable_types: r int

variable_types:
key
unsigned int


getpos

repo: LFenske/rwany

original_code:
long
getpos(char *arg, int fd, long prev)
{
  long value;
  long rel;
  int sign = 1;
  int relative = 0;
  switch (*arg) {
  case '+':
    rel = prev;
    relative = 1;
    arg++;
    break;
  case '-':
  {
    struct stat buf;
    if (0 != fstat(fd, &buf)) {
      perror("fstat");
      exit(2);
    }
    rel = buf.st_size;
    sign = -1;
    relative = 1;
    arg++;
    break;
  }
  default:
    rel = 0;
    break;
  }
  if (strchr(arg, ':') || strchr(arg, '.')) {
    int hour = 0, min = 0, sec = 0, frame = 0;
    char *p = arg;
    long curval = 0;
    while (1) {
      if (*p == ':' || *p == '.' || *p == '\0') {
        hour = min ;
        min = sec ;
        sec = curval;
        curval = 0;
        if (*p == '.') {
          frame = atoi(p+1);
          break;
        }
        if (*p == '\0') {
          break;
        }
      } else {
        curval = curval*10 + *p - '0';
      }
      p++;
    }
    value = (relative ? 0 : 44) + (((hour*60+min)*60+sec)*75+frame)*2352;
  } else {
    value = strtol(arg, (char **)((void *)0), 0);
  }
  return rel + sign*value;
}

canonical_original_code:
long getpos(char *arg, int fd, long prev)
{
  long value;
  long rel;
  int sign = 1;
  int relative = 0;
  switch (*arg) {
  case '+':
    rel = prev;
    relative = 1;
    arg++;
    break;
  case '-':
  {
    struct stat buf;
    if (0 != fstat(fd, &buf)) {
      perror("fstat");
      exit(2);
    }
    rel = buf.st_size;
    sign = -1;
    relative = 1;
    arg++;
    break;
  }
  default:
    rel = 0;
    break;
  }
  if (strchr(arg, ':') || strchr(arg, '.')) {
    int hour = 0; int min = 0; int sec = 0; int frame = 0;
    char *p = arg;
    long curval = 0;
    while (1) {
      if (*p == ':' || *p == '.' || *p == '\0') {
        hour = min ;
        min = sec ;
        sec = curval;
        curval = 0;
        if (*p == '.') {
          frame = atoi(p+1);
          break;
        }
        if (*p == '\0') {
          break;
        }
      } else {
        curval = curval*10 + *p - '0';
      }
      p++;
    }
    value = (relative ? 0 : 44) + (((hour*60+min)*60+sec)*75+frame)*2352;
  } else {
    value = strtol(arg, (char **)((void *)0), 0);
  }
  return rel + sign*value;
}

variable_types:
arg
char *

variable_types: fd int

variable_types: prev long

variable_types: value long

variable_types: rel long

variable_types: sign int

variable_types: relative int

variable_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec { long tv_sec; long tv_nsec; } st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }

variable_types: hour int

variable_types: min int

variable_types: sec int

variable_types: frame int

variable_types:
p
char *

variable_types: curval long

user_defined_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }


receiveData

repo: LMG/testRTS

decompiled_code:
void *__fastcall receiveData(void *a1)
{
*(_DWORD *)(*((_QWORD *)a1 + 1) + 4LL) = 1;
return 0LL;
}

canonical_decompiled_code:
void *__fastcall func7(void *a1)
{
*(_DWORD *)(*((_QWORD *)a1 + 1) + 4LL) = 1;
return 0LL;
}

original_code:
void* receiveData(void* threadData)
{
 struct threadData *data=(struct threadData*)threadData;
 data->flags->mapModified = 1;
 return ((void *)0);
}

canonical_original_code:
void *receiveData(void *threadData)
{
 struct threadData *data = (struct threadData*)threadData;
 data->flags->mapModified = 1;
 return ((void *)0);
}

variable_types:
threadData
void *

variable_types: struct threadData { struct map { struct SDL_Rect { short x; unsigned short w; } origin; int sizeX; int sizeY; struct tile { int id; struct entitie { int id; int x; int y; struct entitie *next; } *entitie; } **tile; } *map; struct flags { int modifyingMap; int mapModified; } *flags; int sock; } *

return_type: void *

user_defined_types: struct threadData { struct map *map; struct flags *flags; int sock; }

user_defined_types: struct map { struct SDL_Rect origin; int sizeX; int sizeY; struct tile **tile; }

user_defined_types: struct tile { int id; struct entitie *entitie; }


initNetwork

decompiled_code:
__int64 initNetwork()
{
unsigned int v0; // ebx
struct sockaddr v2; // [rsp+0h] [rbp-18h] BYREF

v0 = socket(2, 1, 0);
*(_DWORD *)&v2.sa_data[2] = inet_addr("127.0.0.1");
v2.sa_family = 2;
*(_WORD *)v2.sa_data = _bswap_16(2300);
while ( connect(v0, &v2, 0x10u) == -1 )
{
puts("Connexion error");
sleep(1u);
}
return v0;
}

canonical_decompiled_code:
__int64 func9()
{
unsigned int v0; // ebx
struct sockaddr v2; // [rsp+0h] [rbp-18h] BYREF

v0 = socket(2, 1, 0);
*(_DWORD *)&v2.sa_data[2] = inet_addr("127.0.0.1");
v2.sa_family = 2;
*(_WORD *)v2.sa_data = func8(2300);
while ( connect(v0, &v2, 0x10u) == -1 )
{
puts("Connexion error");
sleep(1u);
}
return v0;
}

original_code:
SOCKET initNetwork()
{
    SOCKET sock = socket(2, SOCK_STREAM, 0);
    SOCKADDR_IN sin;
    sin.sin_addr.s_addr = inet_addr("127.0.0.1");
    sin.sin_family = 2;
    sin.sin_port = htons(2300);
    while(connect(sock, (SOCKADDR*)&sin, sizeof(sin)) == -1)
    {
     printf("Connexion error\n");
     sleep(1);
    }
    return sock;
}

canonical_original_code:
int initNetwork()
{
    int sock = socket(2, SOCK_STREAM, 0);
    struct sockaddr_in sin;
    sin.sin_addr.s_addr = inet_addr("127.0.0.1");
    sin.sin_family = 2;
    sin.sin_port = htons(2300);
    while(connect(sock, (struct sockaddr *)&sin, sizeof(sin)) == -1)
    {
     printf("Connexion error\n");
     sleep(1);
    }
    return sock;
}

variable_types: sock int

variable_types: struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; }

user_defined_types: struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr sin_addr; unsigned char sin_zero[-1]; }

user_defined_types: struct sockaddr { unsigned short sa_family; char sa_data[14]; }


identify

repo: LachlanGunn/oic

decompiled_code:
__int64 __fastcall identify(__int64 a1, __int64 a2)
{
puts("OIC,0.1,SCPI Test,0");
scpi_free_tokens(a2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
puts("OIC,0.1,SCPI Test,0");
scpi_free_tokens(a2);
return 0LL;
}

original_code:
scpi_error_t identify(struct scpi_parser_context* ctx, struct scpi_token* command)
{
 printf("OIC,0.1,SCPI Test,0\n");
 scpi_free_tokens(command);
 return SCPI_SUCCESS;
}

canonical_original_code:
enum scpi_error_codes identify(struct scpi_parser_context *ctx, struct scpi_token *command)
{
 printf("OIC,0.1,SCPI Test,0\n");
 scpi_free_tokens(command);
 return SCPI_SUCCESS;
}

variable_types: struct scpi_parser_context { struct scpi_command { char *long_name; unsigned long long_name_length; char *short_name; unsigned long short_name_length; struct scpi_command *next; struct scpi_command *children; enum scpi_error_codes { SCPI_SUCCESS=0, SCPI_COMMAND_NOT_FOUND=-1, SCPI_NO_CALLBACK=-2 } (*callback)(struct scpi_parser_context *, struct scpi_token { unsigned char type; char *value; unsigned long length; struct scpi_token *next; } *); } *command_tree; struct scpi_error { int id; char *description; unsigned long length; struct scpi_error *next; } *error_queue_head; struct scpi_error *error_queue_tail; } *

variable_types:
command
struct scpi_token *

user_defined_types: struct scpi_parser_context { struct scpi_command *command_tree; struct scpi_error *error_queue_head; struct scpi_error *error_queue_tail; }

user_defined_types: struct scpi_command { char *long_name; unsigned long long_name_length; char *short_name; unsigned long short_name_length; struct scpi_command *next; struct scpi_command *children; enum scpi_error_codes (*callback)(struct scpi_parser_context *, struct scpi_token *); }


decompiled_code:
__int64 __fastcall measure_callback(__int64 a1, __int64 a2)
{
double v2; // xmm0_8

v2 = 0.0;
if ( voltage_on )
v2 = *(float *)&voltage;
printf("%e\n", v2);
scpi_free_tokens(a2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
double v2; // xmm0_8

v2 = 0.0;
if ( voltage_on )
v2 = *(float *)&voltage;
printf("%e\n", v2);
scpi_free_tokens(a2);
return 0LL;
}

original_code:
scpi_error_t measure_callback(struct scpi_parser_context* ctx, struct scpi_token* command)
{
 printf("%e\n", voltage_on ? voltage : 0.0f);
 scpi_free_tokens(command);
 return SCPI_SUCCESS;
}

canonical_original_code:
enum scpi_error_codes measure_callback(struct scpi_parser_context *ctx, struct scpi_token *command)
{
 printf("%e\n", voltage_on ? voltage : 0.0f);
 scpi_free_tokens(command);
 return SCPI_SUCCESS;
}

return_type: enum scpi_error_codes { SCPI_SUCCESS=0, SCPI_COMMAND_NOT_FOUND=-1, SCPI_NO_CALLBACK=-2 }

user_defined_types: struct scpi_error { int id; char *description; unsigned long length; struct scpi_error *next; }

user_defined_types: struct scpi_token { unsigned char type; char *value; unsigned long length; struct scpi_token *next; }


decompiled_code:
__int64 __fastcall get_output(__int64 a1, __int64 a2)
{
printf("%d\n", (unsigned int)voltage_on);
scpi_free_tokens(a2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
printf("%d\n", (unsigned int)voltage_on);
scpi_free_tokens(a2);
return 0LL;
}

original_code:
scpi_error_t get_output(struct scpi_parser_context* ctx, struct scpi_token* command)
{
 printf("%d\n", voltage_on);
 scpi_free_tokens(command);
 return SCPI_SUCCESS;
}

canonical_original_code:
enum scpi_error_codes get_output(struct scpi_parser_context *ctx, struct scpi_token *command)
{
 printf("%d\n", voltage_on);
 scpi_free_tokens(command);
 return SCPI_SUCCESS;
}

user_defined_types: enum scpi_error_codes { SCPI_SUCCESS=0, SCPI_COMMAND_NOT_FOUND=-1, SCPI_NO_CALLBACK=-2 }


decompiled_code:
__int64 __fastcall set_voltage(__int64 a1, __int64 a2)
{
__int64 v2; // rax
int v4[10]; // [rsp+0h] [rbp-28h] BYREF

v2 = a2;
if ( a2 )
{
while ( !*(_BYTE *)v2 )
{
v2 = *(_QWORD *)(v2 + 24);
if ( !v2 )
goto LABEL_4;
}
scpi_parse_numeric(v4, *(_QWORD *)(v2 + 8), *(_QWORD *)(v2 + 16), 0.0, 0.0, 100000.0);
voltage = v4[0];
}
else
{
LABEL_4:
puts("ERROR: No argument.");
}
scpi_free_tokens(a2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2)
{
__int64 v2; // rax
int v4[10]; // [rsp+0h] [rbp-28h] BYREF

v2 = a2;
if ( a2 )
{
while ( !*(_BYTE *)v2 )
{
v2 = *(_QWORD *)(v2 + 24);
if ( !v2 )
goto LABEL_4;
}
scpi_parse_numeric(v4, *(_QWORD *)(v2 + 8), *(_QWORD *)(v2 + 16), 0.0, 0.0, 100000.0);
voltage = v4[0];
}
else
{
LABEL_4:
puts("ERROR: No argument.");
}
scpi_free_tokens(a2);
return 0LL;
}

original_code:
scpi_error_t set_voltage(struct scpi_parser_context* ctx, struct scpi_token* command)
{
 struct scpi_token* args;
 args = command;
 while(args != ((void *)0) && args->type == 0)
 {
  args = args->next;
 }
 if(args == ((void *)0))
 {
  printf("ERROR: No argument.\n");
 }
 else
 {
  voltage = scpi_parse_numeric(args->value, args->length, 0.0f, 0.0f,1.0e5f).value;
 }
 scpi_free_tokens(command);
 return SCPI_SUCCESS;
}

canonical_original_code:
enum scpi_error_codes set_voltage(struct scpi_parser_context *ctx, struct scpi_token *command)
{
 struct scpi_token *args;
 args = command;
 while(args != ((void *)0) && args->type == 0)
 {
  args = args->next;
 }
 if(args == ((void *)0))
 {
  printf("ERROR: No argument.\n");
 }
 else
 {
  voltage = scpi_parse_numeric(args->value, args->length, 0.0f, 0.0f,1.0e5f).value;
 }
 scpi_free_tokens(command);
 return SCPI_SUCCESS;
}

variable_types: struct scpi_token { unsigned char type; char *value; unsigned long length; struct scpi_token *next; } *


original_code:
scpi_error_t set_output(struct scpi_parser_context* ctx, struct scpi_token* command)
{
 struct scpi_token* args;
 args = command;
 while(args != ((void *)0) && args->type == 0)
 {
  args = args->next;
 }
 if(args == ((void *)0))
 {
  printf("ERROR: No argument.\n");
 }
 else
 {
  if(args->length == 2 && args->value[0] == 'O' && args->value[1] == 'N')
  {
   voltage_on = 1;
  }
  else if(args->length == 3 &&
   args->value[0] == 'O' && args->value[1] == 'F' && args->value[2] == 'F')
  {
   voltage_on = 0;
  }
  else
  {
   voltage_on = (int)(0.5+scpi_parse_numeric(args->value, args->length, 0.0f, 0.0f, 1.0f).value) ? 1 : 0;
  }
 }
 scpi_free_tokens(command);
 return SCPI_SUCCESS;
}

canonical_original_code:
enum scpi_error_codes set_output(struct scpi_parser_context *ctx, struct scpi_token *command)
{
 struct scpi_token *args;
 args = command;
 while(args != ((void *)0) && args->type == 0)
 {
  args = args->next;
 }
 if(args == ((void *)0))
 {
  printf("ERROR: No argument.\n");
 }
 else
 {
  if(args->length == 2 && args->value[0] == 'O' && args->value[1] == 'N')
  {
   voltage_on = 1;
  }
  else if(args->length == 3 &&
   args->value[0] == 'O' && args->value[1] == 'F' && args->value[2] == 'F')
  {
   voltage_on = 0;
  }
  else
  {
   voltage_on = (int)(0.5+scpi_parse_numeric(args->value, args->length, 0.0f, 0.0f, 1.0f).value) ? 1 : 0;
  }
 }
 scpi_free_tokens(command);
 return SCPI_SUCCESS;
}


decompiled_code:
int __fastcall status_message(const char *a1)
{
return printf("[ %s ]\n", a1);
}

canonical_decompiled_code:
int __fastcall func5(const char *a1)
{
return printf("[ %s ]\n", a1);
}

original_code:
void status_message(char* str)
{
 printf("[ %s ]\n", str);
}

canonical_original_code:
void status_message(char *str)
{
 printf("[ %s ]\n", str);
}

variable_types:
str
char *