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

globals = 800;
*(&globals + 1) = 600;
*(&globals + 2) = 32;
*((_QWORD *)&globals + 2) = 0LL;
*(&globals + 6) = 1;
result = (unsigned int)SDL_GetTicks();
*((_QWORD *)&globals + 4) = (unsigned int)result;
*((_QWORD *)&globals + 5) = 0LL;
*((_QWORD *)&globals + 6) = 0LL;
*(&globals + 14) = 0;
*((_QWORD *)&globals + 8) = 0LL;
return result;
}

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

globals = 800;
*(&globals + 1) = 600;
*(&globals + 2) = 32;
*((_QWORD *)&globals + 2) = 0LL;
*(&globals + 6) = 1;
result = (unsigned int)SDL_GetTicks();
*((_QWORD *)&globals + 4) = (unsigned int)result;
*((_QWORD *)&globals + 5) = 0LL;
*((_QWORD *)&globals + 6) = 0LL;
*(&globals + 14) = 0;
*((_QWORD *)&globals + 8) = 0LL;
return result;
}

original_code:
void init_globals()
{
 globals.window.width = 800;
 globals.window.height = 600;
 globals.window.bpp = 32;
 globals.screen = ((void *)0);
 globals.bRun = 1;
 globals.time.start = SDL_GetTicks();
 globals.time.sinceStart = 0;
 globals.time.delta = 0;
 globals.time.deltaf = 0.0f;
 globals.time.last = 0;
}


main

canonical_name: main

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

if ( argc == 3 )
{
if ( atoi(argv[1]) == 1 && (unsigned int)atoi(argv[2]) <= 1 )
{
rs485_set_model(1);
result = 0;
}
else
{
fwrite(
"Usage: ./rs485 argv[1] argv[2] here argv[1] must specified to 1 and argv[2] must in 0 or 1\n",
1uLL,
0x5BuLL,
stdout);
fwrite("argv[1] = 1,set rs485 work model and argv[2] specified model\n", 1uLL, 0x3DuLL, stdout);
result = -1;
}
}
else if ( argc == 2 )
{
if ( atoi(argv[1]) == 2 )
{
rs485_get_stats();
result = 0;
}
else
{
fwrite("Usage: ./rs485 argv[1] argv[1] must to be given 2 to pecified the rs read model\n", 1uLL, 0x50uLL, stdout);
result = -1;
}
}
else
{
fwrite("Usage: ./rs485 [argv[1]] <argv[2]>\n", 1uLL, 0x23uLL, stdout);
result = -1;
}
return result;
}

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

if ( argc == 3 )
{
if ( atoi(argv[1]) == 1 && (unsigned int)atoi(argv[2]) <= 1 )
{
func9(1);
result = 0;
}
else
{
fwrite(
"Usage: ./rs485 argv[1] argv[2] here argv[1] must specified to 1 and argv[2] must in 0 or 1\n",
1uLL,
0x5BuLL,
stdout);
fwrite("argv[1] = 1,set rs485 work model and argv[2] specified model\n", 1uLL, 0x3DuLL, stdout);
result = -1;
}
}
else if ( argc == 2 )
{
if ( atoi(argv[1]) == 2 )
{
func10();
result = 0;
}
else
{
fwrite("Usage: ./rs485 argv[1] argv[1] must to be given 2 to pecified the rs read model\n", 1uLL, 0x50uLL, stdout);
result = -1;
}
}
else
{
fwrite("Usage: ./rs485 [argv[1]] <argv[2]>\n", 1uLL, 0x23uLL, stdout);
result = -1;
}
return result;
}

original_code:
int main(int argc,char **argv)
{
 if(argc == 3)
 {
  if(atoi(argv[1]) == 0x1)
  {
   if((atoi(argv[2]) != 0x0) && (atoi(argv[2]) != 0x1))
   {
    fprintf(stdout,"Usage: ./rs485 argv[1] argv[2] here argv[1] must specified to 1 and argv[2] must in 0 or 1\n");
    fprintf(stdout,"argv[1] = 1,set rs485 work model and argv[2] specified model\n");
    return -1;
   }
   else if(argv[2] == 0)
   {
    rs485_set_model(0);
   }
   else
   {
    rs485_set_model(1);
   }
  }
  else
  {
   fprintf(stdout,"Usage: ./rs485 argv[1] argv[2] here argv[1] must specified to 1 and argv[2] must in 0 or 1\n");
   fprintf(stdout,"argv[1] = 1,set rs485 work model and argv[2] specified model\n");
   return -1;
  }
 }
 else if(argc == 2)
 {
  if(atoi(argv[1]) != 0x2)
  {
   fprintf(stdout,"Usage: ./rs485 argv[1] argv[1] must to be given 2 to pecified the rs read model\n");
   return -1;
  }
  else
  {
   rs485_get_stats();
  }
 }
 else
 {
  fprintf(stdout,"Usage: ./rs485 [argv[1]] <argv[2]>\n");
  return -1;
 }
 return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
 if(argc == 3)
 {
  if(atoi(argv[1]) == 0x1)
  {
   if((atoi(argv[2]) != 0x0) && (atoi(argv[2]) != 0x1))
   {
    fprintf(stdout,"Usage: ./rs485 argv[1] argv[2] here argv[1] must specified to 1 and argv[2] must in 0 or 1\n");
    fprintf(stdout,"argv[1] = 1,set rs485 work model and argv[2] specified model\n");
    return -1;
   }
   else if(argv[2] == 0)
   {
    rs485_set_model(0);
   }
   else
   {
    rs485_set_model(1);
   }
  }
  else
  {
   fprintf(stdout,"Usage: ./rs485 argv[1] argv[2] here argv[1] must specified to 1 and argv[2] must in 0 or 1\n");
   fprintf(stdout,"argv[1] = 1,set rs485 work model and argv[2] specified model\n");
   return -1;
  }
 }
 else if(argc == 2)
 {
  if(atoi(argv[1]) != 0x2)
  {
   fprintf(stdout,"Usage: ./rs485 argv[1] argv[1] must to be given 2 to pecified the rs read model\n");
   return -1;
  }
  else
  {
   rs485_get_stats();
  }
 }
 else
 {
  fprintf(stdout,"Usage: ./rs485 [argv[1]] <argv[2]>\n");
  return -1;
 }
 return 0;
}

variable_types: argc int

variable_types:
argv
char **

return_type: int


decompiled_code:
__int64 __fastcall nb_egalites(float *a1, int a2, float a3)
{
float *v3; // rax
unsigned int v4; // edx

if ( a2 <= 0 )
return 0;
v3 = a1;
v4 = 0;
do
{
if ( a3 == *v3 )
++v4;
++v3;
}
while ( v3 != &a1[a2 - 1 + 1] );
return v4;
}

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

if ( a2 <= 0 )
return 0;
v3 = a1;
v4 = 0;
do
{
if ( a3 == *v3 )
++v4;
++v3;
}
while ( v3 != &a1[a2 - 1 + 1] );
return v4;
}

original_code:
int nb_egalites(float tab[], int longueur, float maximum){
 int i;
 int acc = 0;
 for (i=0; i<longueur; i++)
  if (tab[i] == maximum)
   acc ++;
 return acc;
}

variable_types:
tab
float []

variable_types: longueur int

variable_types: maximum float

variable_types: i int

variable_types: acc int


max

decompiled_code:
__int64 __fastcall max(__int64 a1, int a2)
{
__int64 v2; // rax
unsigned int v3; // edx

if ( a2 <= 1 )
return 0;
v2 = 1LL;
v3 = 0;
do
{
if ( *(float *)(a1 + 4 * v2) > *(float *)(a1 + 4LL * (int)v3) )
v3 = v2;
++v2;
}
while ( v2 != a2 );
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, int a2)
{
__int64 v2; // rax
unsigned int v3; // edx

if ( a2 <= 1 )
return 0;
v2 = 1LL;
v3 = 0;
do
{
if ( *(float *)(a1 + 4 * v2) > *(float *)(a1 + 4LL * (int)v3) )
v3 = v2;
++v2;
}
while ( v2 != a2 );
return v3;
}

original_code:
int max(float tab[], int longueur){
 int acc,i;
  acc = 0;
 for (i = 1; i < longueur; i++){
  if (tab[i] > tab[acc])
  acc = i;
 }
 return acc;
}

canonical_original_code:
int max(float tab[], int longueur){
 int acc; int i;
  acc = 0;
 for (i = 1; i < longueur; i++){
  if (tab[i] > tab[acc])
  acc = i;
 }
 return acc;
}


alea

decompiled_code:
__int64 __fastcall alea(int a1)
{
return (unsigned int)(rand() % (a1 + 1));
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
return (unsigned int)(rand() % (a1 + 1));
}

original_code:
int alea (int m){
        return rand() % (m+1) ;
}

canonical_original_code:
int alea(int m){
        return rand() % (m+1) ;
}

variable_types: m int


decompiled_code:
int tracer_ligne()
{
int v0; // ebx

putchar(124);
v0 = 7;
do
{
printf("---|");
--v0;
}
while ( v0 );
return putchar(10);
}

canonical_decompiled_code:
int func0()
{
int v0; // ebx

putchar(124);
v0 = 7;
do
{
printf("---|");
--v0;
}
while ( v0 );
return putchar(10);
}

original_code:
void tracer_ligne( int largeur ){
 int i;
 printf("|");
 for (i=0; i<7; i++)
 {
  printf("---|");
 }
 printf("\n");
}

canonical_original_code:
void tracer_ligne(int largeur){
 int i;
 printf("|");
 for (i=0; i<7; i++)
 {
  printf("---|");
 }
 printf("\n");
}

variable_types: largeur int

return_type: void


decompiled_code:
int effacer_grille()
{
return printf("\n\x1B[%dA", 17LL);
}

canonical_decompiled_code:
int func3()
{
return printf("\n\x1B[%dA", 17LL);
}

original_code:
void effacer_grille(){
  printf("\n\e[%dA",17);
 }


decompiled_code:
__int64 demander_coup_joueur()
{
int v0; // eax

puts(s);
do
v0 = getchar();
while ( (unsigned int)(v0 - 49) > 6 && v0 != 117 );
return (unsigned int)(v0 - 48);
}

canonical_decompiled_code:
__int64 func4()
{
int v0; // eax

puts(s);
do
v0 = getchar();
while ( (unsigned int)(v0 - 49) > 6 && v0 != 117 );
return (unsigned int)(v0 - 48);
}

original_code:
bool demander_coup_joueur(){
 bool coup_valide = -1;
 int indice = 0;
 printf("Rentrez l'indice de la colonne où jouer(entre 1 et 7, inclus) u pour annuler:\n");
 do{
  indice = getchar();
  coup_valide = (((indice>'0')&&(indice<'8'))||(indice == 'u'));
 }while(!(coup_valide));
 return (indice-'0');
  }

canonical_original_code:
int demander_coup_joueur(){
 int coup_valide = -1;
 int indice = 0;
 printf("Rentrez l'indice de la colonne où jouer(entre 1 et 7, inclus) u pour annuler:\n");
 do{
  indice = getchar();
  coup_valide = (((indice>'0')&&(indice<'8'))||(indice == 'u'));
 }while(!(coup_valide));
 return (indice-'0');
  }

variable_types: indice int


repo: tehn/aleph

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

result = a1;
if ( a1 )
{
if ( *(_QWORD *)(a1 + 8) != -1LL )
_InterlockedAdd64((volatile signed __int64 *)(a1 + 8), 1uLL);
}
return result;
}

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

result = a1;
if ( a1 )
{
if ( *(_QWORD *)(a1 + 8) != -1LL )
_InterlockedAdd64((volatile signed __int64 *)(a1 + 8), 1uLL);
}
return result;
}

original_code:
static inline
json_t *json_incref(json_t *json)
{
    if(json && json->refcount != (size_t)-1)
        __atomic_add_fetch(&json->refcount, 1, 2);
    return json;
}

canonical_original_code:
static inline struct json_t *json_incref(struct json_t *json)
{
    if(json && json->refcount != (unsigned long)-1)
        __atomic_add_fetch(&json->refcount, 1, 2);
    return json;
}

variable_types:
json
struct json_t *

return_type: struct json_t { enum json_type { JSON_OBJECT=0, JSON_ARRAY=1, JSON_STRING=2, JSON_INTEGER=3, JSON_REAL=4, JSON_TRUE=5, JSON_FALSE=6, JSON_NULL=7 } type; unsigned long refcount; } *

user_defined_types: struct json_t { enum json_type type; unsigned long refcount; }


decompiled_code:
__int64 net_write_json_scene()
{
__int64 v0; // rbx
__int64 v1; // rax
__int64 v2; // rax
__int64 v3; // rbp
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rbp
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // rax

v0 = json_object();
v1 = json_string(sceneData);
json_object_set(v0, (__int64)"sceneName", v1);
v2 = json_string(sceneData + 24LL);
json_object_set(v0, (__int64)"moduleName", v2);
v3 = json_object();
v4 = json_integer(*(unsigned __int8 *)(sceneData + 48LL));
json_object_set(v3, (__int64)"maj", v4);
v5 = json_integer(*(unsigned __int8 *)(sceneData + 49LL));
json_object_set(v3, (__int64)"min", v5);
v6 = json_integer(*(unsigned __int16 *)(sceneData + 50LL));
json_object_set(v3, (__int64)"rev", v6);
json_object_set(v0, (__int64)"moduleVersion", v3);
v7 = json_object();
v8 = json_integer(*(unsigned __int8 *)(sceneData + 52LL));
json_object_set(v7, (__int64)"maj", v8);
v9 = json_integer(*(unsigned __int8 *)(sceneData + 53LL));
json_object_set(v7, (__int64)"min", v9);
v10 = json_integer(*(unsigned __int16 *)(sceneData + 54LL));
json_object_set(v7, (__int64)"rev", v10);
json_object_set(v0, (__int64)"beesVersion", v7);
return v0;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 v0; // rbx
__int64 v1; // rax
__int64 v2; // rax
__int64 v3; // rbp
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rbp
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // rax

v0 = json_object();
v1 = json_string(sceneData);
func2(v0, (__int64)"sceneName", v1);
v2 = json_string(sceneData + 24LL);
func2(v0, (__int64)"moduleName", v2);
v3 = json_object();
v4 = json_integer(*(unsigned __int8 *)(sceneData + 48LL));
func2(v3, (__int64)"maj", v4);
v5 = json_integer(*(unsigned __int8 *)(sceneData + 49LL));
func2(v3, (__int64)"min", v5);
v6 = json_integer(*(unsigned __int16 *)(sceneData + 50LL));
func2(v3, (__int64)"rev", v6);
func2(v0, (__int64)"moduleVersion", v3);
v7 = json_object();
v8 = json_integer(*(unsigned __int8 *)(sceneData + 52LL));
func2(v7, (__int64)"maj", v8);
v9 = json_integer(*(unsigned __int8 *)(sceneData + 53LL));
func2(v7, (__int64)"min", v9);
v10 = json_integer(*(unsigned __int16 *)(sceneData + 54LL));
func2(v7, (__int64)"rev", v10);
func2(v0, (__int64)"beesVersion", v7);
return v0;
}

original_code:
static json_t* net_write_json_scene(void) {
  json_t* o = json_object();
  json_t* p;
  json_object_set(o, "sceneName", json_string(sceneData->desc.sceneName));
  json_object_set(o, "moduleName", json_string(sceneData->desc.moduleName));
  p = json_object();
  json_object_set(p, "maj", json_integer(sceneData->desc.moduleVersion.maj));
  json_object_set(p, "min", json_integer(sceneData->desc.moduleVersion.min));
  json_object_set(p, "rev", json_integer(sceneData->desc.moduleVersion.rev));
  json_object_set(o, "moduleVersion", p);
  p = json_object();
  json_object_set(p, "maj", json_integer(sceneData->desc.beesVersion.maj));
  json_object_set(p, "min", json_integer(sceneData->desc.beesVersion.min));
  json_object_set(p, "rev", json_integer(sceneData->desc.beesVersion.rev));
  json_object_set(o, "beesVersion", p);
  return o;
}

canonical_original_code:
static struct json_t *net_write_json_scene() {
  struct json_t *o = json_object();
  struct json_t *p;
  json_object_set(o, "sceneName", json_string(sceneData->desc.sceneName));
  json_object_set(o, "moduleName", json_string(sceneData->desc.moduleName));
  p = json_object();
  json_object_set(p, "maj", json_integer(sceneData->desc.moduleVersion.maj));
  json_object_set(p, "min", json_integer(sceneData->desc.moduleVersion.min));
  json_object_set(p, "rev", json_integer(sceneData->desc.moduleVersion.rev));
  json_object_set(o, "moduleVersion", p);
  p = json_object();
  json_object_set(p, "maj", json_integer(sceneData->desc.beesVersion.maj));
  json_object_set(p, "min", json_integer(sceneData->desc.beesVersion.min));
  json_object_set(p, "rev", json_integer(sceneData->desc.beesVersion.rev));
  json_object_set(o, "beesVersion", p);
  return o;
}

variable_types: struct json_t { enum json_type { JSON_OBJECT=0, JSON_ARRAY=1, JSON_STRING=2, JSON_INTEGER=3, JSON_REAL=4, JSON_TRUE=5, JSON_FALSE=6, JSON_NULL=7 } type; unsigned long refcount; } *


original_code:
static json_t* net_write_json_ops(void) {
  json_t* ops = json_array();
  int i, j;
  u8 bin[0x10000];
  u8* dst;
  int binCount;
  for(i=0; i<net->numOps; ++i) {
    op_t* op = net->ops[i];
    json_t* o;
    json_t* p;
    json_t* q;
    json_t* ins = json_array();
    json_t* outs = json_array();
    json_t* state = json_array();
    o = json_object();
    json_object_set(o, "index", json_integer(i));
    json_object_set(o, "class", json_integer(op->type));
    json_object_set(o, "name", json_string(op->opString));
    for(j=0; j< (op->numInputs); ++j) {
      int inIdx = net_op_in_idx(i, j);
      p = json_object();
      json_object_set(p, "name", json_string( net_in_name(inIdx) ) );
      json_object_set(p, "value", json_integer(net_get_in_value(inIdx)) );
      json_array_append(ins, p);
    }
    for(j=0; j<op->numOutputs; ++j) {
      int outIdx = net_op_out_idx(i, j);
      int target = net_get_target(outIdx);
      p = json_object();
      q = json_object();
      json_object_set(p, "name", json_string( net_out_name(outIdx) ) );
      if(target == -1) {
 json_object_set(q, "inIdx", json_integer( -1 ) );
      } else {
 int inOpIdx = net_in_op_idx(target);
 if(inOpIdx < 0) {
   json_object_set( q, "paramName", json_string( net_in_name(target) ) );
 } else {
   json_object_set( q, "opIdx", json_integer( inOpIdx ) );
   json_object_set( q, "opName", json_string( net_op_name(net_in_op_idx(target)) ) );
   json_object_set( q, "opInIdx", json_integer( net->ins[target].opInIdx ) );
   json_object_set( q, "opInName", json_string( net_in_name(target) ) );
 }
      }
      json_object_set(p, "target", q);
      json_array_append(outs, p);
    }
    if(op->pickle == ((void *)0)) {
      binCount = 0;
    } else {
      dst = bin;
      dst = (*(op->pickle))(op, dst);
      binCount = (size_t)dst - (size_t)(bin);
    }
    for(j=0; j<binCount; j++) {
      json_array_append(state, json_integer(bin[j]));
    }
    json_object_set(o, "ins", ins);
    json_object_set(o, "outs", outs);
    json_object_set(o, "state", state);
    json_array_append(ops, o);
  }
  return ops;
}

canonical_original_code:
static struct json_t *net_write_json_ops() {
  struct json_t *ops = json_array();
  int i; int j;
  unsigned char bin[65536];
  unsigned char *dst;
  int binCount;
  for(i=0; i<net->numOps; ++i) {
    struct op_struct *op = net->ops[i];
    struct json_t *o;
    struct json_t *p;
    struct json_t *q;
    struct json_t *ins = json_array();
    struct json_t *outs = json_array();
    struct json_t *state = json_array();
    o = json_object();
    json_object_set(o, "index", json_integer(i));
    json_object_set(o, "class", json_integer(op->type));
    json_object_set(o, "name", json_string(op->opString));
    for(j=0; j< (op->numInputs); ++j) {
      int inIdx = net_op_in_idx(i, j);
      p = json_object();
      json_object_set(p, "name", json_string( net_in_name(inIdx) ) );
      json_object_set(p, "value", json_integer(net_get_in_value(inIdx)) );
      json_array_append(ins, p);
    }
    for(j=0; j<op->numOutputs; ++j) {
      int outIdx = net_op_out_idx(i, j);
      int target = net_get_target(outIdx);
      p = json_object();
      q = json_object();
      json_object_set(p, "name", json_string( net_out_name(outIdx) ) );
      if(target == -1) {
 json_object_set(q, "inIdx", json_integer( -1 ) );
      } else {
 int inOpIdx = net_in_op_idx(target);
 if(inOpIdx < 0) {
   json_object_set( q, "paramName", json_string( net_in_name(target) ) );
 } else {
   json_object_set( q, "opIdx", json_integer( inOpIdx ) );
   json_object_set( q, "opName", json_string( net_op_name(net_in_op_idx(target)) ) );
   json_object_set( q, "opInIdx", json_integer( net->ins[target].opInIdx ) );
   json_object_set( q, "opInName", json_string( net_in_name(target) ) );
 }
      }
      json_object_set(p, "target", q);
      json_array_append(outs, p);
    }
    if(op->pickle == ((void *)0)) {
      binCount = 0;
    } else {
      dst = bin;
      dst = (*(op->pickle))(op, dst);
      binCount = (unsigned long)dst - (unsigned long)(bin);
    }
    for(j=0; j<binCount; j++) {
      json_array_append(state, json_integer(bin[j]));
    }
    json_object_set(o, "ins", ins);
    json_object_set(o, "outs", outs);
    json_object_set(o, "state", state);
    json_array_append(ops, o);
  }
  return ops;
}

variable_types: j int

variable_types:
bin
unsigned char [65536]

variable_types:
dst
unsigned char *

variable_types: binCount int

variable_types: struct op_struct { unsigned char numInputs; unsigned char numOutputs; void (*inc_fn)(void *op, short idx, short inc); void (**in_fn)(void *op, short input); unsigned char *(*pickle)(void *op, unsigned char *dst); unsigned char *(*unpickle)(void *op, unsigned char *src); short **in_val; short *out; char *opString; char *inString; char *outString; unsigned int type; unsigned int flags; void *child; } *

variable_types: inIdx int

variable_types: outIdx int

variable_types: target int

variable_types: inOpIdx int

user_defined_types: enum json_type { JSON_OBJECT=0, JSON_ARRAY=1, JSON_STRING=2, JSON_INTEGER=3, JSON_REAL=4, JSON_TRUE=5, JSON_FALSE=6, JSON_NULL=7 }


decompiled_code:
__int64 net_write_json_params()
{
__int64 v0; // r13
__int64 v1; // rax
__int64 v2; // r12
__int64 v3; // rdx
__int64 v4; // rbx
__int64 v5; // rax
__int64 v6; // rbp
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // rax
__int64 v11; // rax

v0 = json_array();
v1 = json_integer(*(unsigned __int16 *)(net + 263186LL));
json_object_set(v0, (__int64)"count", v1);
if ( *(_WORD *)(net + 263186LL) )
{
v2 = 0LL;
do
{
v4 = json_object();
v5 = json_string(net + (v2 << 6) + 267288);
json_object_set(v4, (__int64)"name", v5);
v6 = (__int64)(int)v2 << 6;
v7 = json_integer(*(unsigned int *)(net + v6 + 267304));
json_object_set(v4, (__int64)"type", v7);
v8 = json_integer(*(int *)(net + v6 + 267308));
json_object_set(v4, (__int64)"min", v8);
v9 = json_integer(*(int *)(net + v6 + 267312));
json_object_set(v4, (__int64)"max", v9);
v10 = json_integer(*(unsigned __int8 *)(net + v6 + 267316));
json_object_set(v4, (__int64)"radix", v10);
v11 = json_integer(*(int *)(net + v6 + 267317));
json_object_set(v4, (__int64)"value", v11);
if ( (unsigned __int8)net_get_in_play((unsigned int)v2 + *(unsigned __int16 *)(net + 263182LL)) )
v3 = json_true();
else
v3 = json_false();
json_object_set(v4, (__int64)"play", v3);
json_array_append(v0, v4);
++v2;
}
while ( *(unsigned __int16 *)(net + 263186LL) > (int)v2 );
}
return v0;
}

original_code:
static json_t* net_write_json_params(void) {
  json_t *params = json_array();
  json_t* o;
  int i;
  json_object_set(params, "count", json_integer(net->numParams));
  for(i=0; i<net->numParams; i++) {
    o = json_object();
    json_object_set(o, "name", json_string(net->params[i].desc.label));
    json_object_set(o, "type", json_integer(net->params[i].desc.type));
    json_object_set(o, "min", json_integer(net->params[i].desc.min));
    json_object_set(o, "max", json_integer(net->params[i].desc.max));
    json_object_set(o, "radix", json_integer(net->params[i].desc.radix));
    json_object_set(o, "value", json_integer(net->params[i].data.value));
    json_object_set(o, "play", ((net_get_in_play(i + net->numIns)) ? json_true() : json_false()));
    json_array_append(params, o);
  }
  return params;
}

canonical_original_code:
static struct json_t *net_write_json_params() {
  struct json_t *params = json_array();
  struct json_t *o;
  int i;
  json_object_set(params, "count", json_integer(net->numParams));
  for(i=0; i<net->numParams; i++) {
    o = json_object();
    json_object_set(o, "name", json_string(net->params[i].desc.label));
    json_object_set(o, "type", json_integer(net->params[i].desc.type));
    json_object_set(o, "min", json_integer(net->params[i].desc.min));
    json_object_set(o, "max", json_integer(net->params[i].desc.max));
    json_object_set(o, "radix", json_integer(net->params[i].desc.radix));
    json_object_set(o, "value", json_integer(net->params[i].data.value));
    json_object_set(o, "play", ((net_get_in_play(i + net->numIns)) ? json_true() : json_false()));
    json_array_append(params, o);
  }
  return params;
}


decompiled_code:
__int64 net_write_json_presets()
{
__int64 v0; // rbp
__int64 v1; // rax
__int64 v2; // rax
unsigned int j; // ebx
__int64 v4; // r12
int v5; // eax
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // rax
__int64 v11; // rax
unsigned int k; // ebx
__int64 v13; // rax
__int64 v14; // rax
__int64 v15; // rax
__int64 v16; // rax
__int64 v17; // rax
__int64 v18; // rax
__int16 v19; // ax
__int64 v20; // rax
__int16 v21; // ax
__int64 v22; // rax
__int64 v23; // rax
__int64 v24; // rax
__int64 v25; // rax
__int64 v26; // r12
__int64 v27; // r13
unsigned __int16 v28; // r14
int v29; // edx
__int64 v30; // rax
__int64 v31; // rax
__int64 v32; // r15
__int64 v33; // rax
__int64 v34; // rax
unsigned int i; // [rsp+Ch] [rbp-4Ch]
__int64 v37; // [rsp+10h] [rbp-48h]
__int64 v38; // [rsp+18h] [rbp-40h]

v38 = json_array();
v0 = 0LL;
for ( i = 0; i != 32; ++i )
{
v37 = json_object();
v32 = json_array();
v33 = preset_name(i);
v34 = json_string(v33);
json_object_set(v37, (__int64)"name", v34);
for ( j = 0; j != 512; ++j )
{
if ( *(_BYTE *)(v0 + presets + 4LL * (int)j + 2) )
{
v4 = json_object();
v5 = *(unsigned __int16 *)(net + 263182LL);
if ( v5 <= (int)j )
{
v1 = get_param_name(j - v5);
v2 = json_string(v1);
json_object_set(v4, (__int64)"paramName", v2);
}
else
{
v6 = json_integer(*(int *)(net + 8LL * (int)j + 263188));
json_object_set(v4, (__int64)"opIdx", v6);
v7 = net_op_name((unsigned int)*(__int16 *)(net + 8 * ((int)j + 32898LL) + 4));
v8 = json_string(v7);
json_object_set(v4, (__int64)"opName", v8);
v9 = net_in_name(j);
v10 = json_string(v9);
json_object_set(v4, (__int64)"opInName", v10);
}
v11 = json_integer(*(__int16 *)(presets + 4LL * (int)j + v0));
json_object_set(v4, (__int64)"value", v11);
json_array_append(v32, v4);
}
}
for ( k = 0; k != 256; ++k )
{
if ( *(_BYTE *)(v0 + presets + 4LL * (int)k + 2048 + 2) )
{
v26 = json_object();
v27 = json_object();
v28 = *(_WORD *)(presets + 4LL * (int)k + 2048 + v0);
if ( (v28 & 0x8000u) != 0 )
{
v13 = json_integer(-1LL);
json_object_set(v27, (__int64)"inIdx", v13);
}
else
{
v29 = *(unsigned __int16 *)(net + 263182LL);
if ( v29 > (__int16)v28 )
{
v14 = json_integer(*(int *)(net + 8LL * (__int16)v28 + 263188));
json_object_set(v27, (__int64)"opIdx", v14);
v15 = net_op_name((unsigned int)*(__int16 *)(net + 8 * ((__int16)v28 + 32898LL) + 4));
v16 = json_string(v15);
json_object_set(v27, (__int64)"opName", v16);
v17 = net_in_name(v28);
v18 = json_string(v17);
json_object_set(v27, (__int64)"opInName", v18);
}
else
{
v30 = get_param_name((unsigned int)((__int16)v28 - v29));
v31 = json_string(v30);
json_object_set(v27, (__int64)"paramName", v31);
}
v19 = net_out_op_idx(k);
v20 = json_integer(v19);
json_object_set(v26, (__int64)"opIdx", v20);
v21 = net_out_op_idx(k);
v22 = net_op_name((unsigned int)v21);
v23 = json_string(v22);
json_object_set(v26, (__int64)"opName", v23);
v24 = net_out_name(k);
v25 = json_string(v24);
json_object_set(v26, (__int64)"opOutName", v25);
json_object_set(v26, (__int64)"target", v27);
json_array_append(v32, v26);
}
}
}
json_object_set(v37, (__int64)"entries", v32);
json_array_append(v38, v37);
v0 += 3088LL;
}
return v38;
}

original_code:
static json_t* net_write_json_presets(void) {
  json_t* pres = json_array();
  int i, j;
  for(i=0; i<32; i++) {
    json_t* pre = json_object();
    json_t* l = json_array();
    json_t* o;
    json_t* p;
    json_object_set( pre, "name", json_string( preset_name(i)) );
    for(j=0; j<(256 + 256); j++) {
      if(presets[i].ins[j].enabled) {
 o = json_object();
 if(j < net->numIns) {
   json_object_set( o, "opIdx", json_integer( net->ins[j].opIdx ) );
   json_object_set( o, "opName", json_string( net_op_name(net->ins[j].opIdx) ) );
   json_object_set( o, "opInName", json_string( net_in_name(j) ) );
   json_object_set( o, "value", json_integer( presets[i].ins[j].value ) );
 } else {
   int pId = j - net->numIns;
   json_object_set( o, "paramName", json_string ( get_param_name(pId) ) ) ;
   json_object_set( o, "value", json_integer( presets[i].ins[j].value ) );
 }
 json_array_append(l, o);
      }
    }
    for(j=0; j<256; j++) {
      if(presets[i].outs[j].enabled) {
 int target;
 o = json_object();
 p = json_object();
 target = presets[i].outs[j].target;
 if(target < 0) {
   json_object_set(p, "inIdx", json_integer( -1 ) );
 } else {
   if(target >= net->numIns) {
     json_object_set( p, "paramName", json_string( get_param_name(target - net->numIns) ) ) ;
   } else {
     json_object_set( p, "opIdx", json_integer( net->ins[target].opIdx ) ) ;
     json_object_set( p, "opName", json_string( net_op_name(net->ins[target].opIdx) ) );
     json_object_set( p, "opInName", json_string( net_in_name(target) ) );
   }
   json_object_set( o, "opIdx", json_integer( net_out_op_idx(j) ) );
   json_object_set( o, "opName", json_string( net_op_name(net_out_op_idx(j) ) ) );
   json_object_set( o, "opOutName", json_string( net_out_name(j) ) );
   json_object_set( o, "target", p);
   json_array_append( l, o );
 }
      }
    }
    json_object_set(pre, "entries", l);
    json_array_append(pres, pre);
  }
  return pres;
}

canonical_original_code:
static struct json_t *net_write_json_presets() {
  struct json_t *pres = json_array();
  int i; int j;
  for(i=0; i<32; i++) {
    struct json_t *pre = json_object();
    struct json_t *l = json_array();
    struct json_t *o;
    struct json_t *p;
    json_object_set( pre, "name", json_string( preset_name(i)) );
    for(j=0; j<(256 + 256); j++) {
      if(presets[i].ins[j].enabled) {
 o = json_object();
 if(j < net->numIns) {
   json_object_set( o, "opIdx", json_integer( net->ins[j].opIdx ) );
   json_object_set( o, "opName", json_string( net_op_name(net->ins[j].opIdx) ) );
   json_object_set( o, "opInName", json_string( net_in_name(j) ) );
   json_object_set( o, "value", json_integer( presets[i].ins[j].value ) );
 } else {
   int pId = j - net->numIns;
   json_object_set( o, "paramName", json_string ( get_param_name(pId) ) ) ;
   json_object_set( o, "value", json_integer( presets[i].ins[j].value ) );
 }
 json_array_append(l, o);
      }
    }
    for(j=0; j<256; j++) {
      if(presets[i].outs[j].enabled) {
 int target;
 o = json_object();
 p = json_object();
 target = presets[i].outs[j].target;
 if(target < 0) {
   json_object_set(p, "inIdx", json_integer( -1 ) );
 } else {
   if(target >= net->numIns) {
     json_object_set( p, "paramName", json_string( get_param_name(target - net->numIns) ) ) ;
   } else {
     json_object_set( p, "opIdx", json_integer( net->ins[target].opIdx ) ) ;
     json_object_set( p, "opName", json_string( net_op_name(net->ins[target].opIdx) ) );
     json_object_set( p, "opInName", json_string( net_in_name(target) ) );
   }
   json_object_set( o, "opIdx", json_integer( net_out_op_idx(j) ) );
   json_object_set( o, "opName", json_string( net_op_name(net_out_op_idx(j) ) ) );
   json_object_set( o, "opOutName", json_string( net_out_name(j) ) );
   json_object_set( o, "target", p);
   json_array_append( l, o );
 }
      }
    }
    json_object_set(pre, "entries", l);
    json_array_append(pres, pre);
  }
  return pres;
}

variable_types: pId int


decompiled_code:
__int64 __fastcall net_write_json_native(__int64 a1)
{
__int64 v1; // rbx
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // rax
__int64 v5; // rax

v1 = json_object();
v2 = net_write_json_scene();
json_object_set(v1, (__int64)"scene", v2);
v3 = net_write_json_ops();
json_object_set(v1, (__int64)"operators", v3);
v4 = net_write_json_params();
json_object_set(v1, (__int64)"params", v4);
v5 = net_write_json_presets();
json_object_set(v1, (__int64)"presets", v5);
return json_dump_file(v1, a1, 1284LL);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
__int64 v1; // rbx
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // rax
__int64 v5; // rax

v1 = json_object();
v2 = func3();
func2(v1, (__int64)"scene", v2);
v3 = func4();
func2(v1, (__int64)"operators", v3);
v4 = func5();
func2(v1, (__int64)"params", v4);
v5 = func6();
func2(v1, (__int64)"presets", v5);
return json_dump_file(v1, a1, 1284LL);
}

original_code:
void net_write_json_native(const char* name) {
  json_t *root;
  root = json_object();
  json_object_set(root, "scene", net_write_json_scene());
  json_object_set(root, "operators", net_write_json_ops());
  json_object_set(root, "params", net_write_json_params());
  json_object_set(root, "presets", net_write_json_presets());
  json_dump_file(root, name, ((4) & 0x1F) | 0x100 | 0x400);
}

canonical_original_code:
void net_write_json_native(char *name) {
  struct json_t *root;
  root = json_object();
  json_object_set(root, "scene", net_write_json_scene());
  json_object_set(root, "operators", net_write_json_ops());
  json_object_set(root, "params", net_write_json_params());
  json_object_set(root, "presets", net_write_json_presets());
  json_dump_file(root, name, ((4) & 0x1F) | 0x100 | 0x400);
}

variable_types:
name
char *


decompiled_code:
size_t __fastcall net_write_dot(FILE *stream)
{
__int64 v1; // rax
unsigned int v2; // er13
int v3; // ebx
unsigned __int16 v4; // ax
const char *v5; // rax
int v6; // er14
unsigned __int16 v7; // ax
const char *v8; // rax
int v9; // er14
int v10; // ebx
unsigned __int8 *v11; // rbp
const char *v12; // rax
int i; // ebx
const char *v14; // rax
int v15; // ebx
unsigned __int16 v16; // ax

fwrite(
"digraph g { \t\t\t\t\r\n"
"\tgraph[rankdir=\"LR\"]; \t\t\r\n"
"\tnode[ \t\t\t\r\n"
"\tfontsize=\"10\" \t\r\n"
"\tshape= \"ellipse\" ];\t\r\n"
"\tedge[]; \t\t\r\n",
1uLL,
0x6EuLL,
stream);
v1 = net;
if ( *(_WORD *)(net + 263180LL) )
{
v2 = 0;
do
{
v11 = *(unsigned __int8 **)(v1 + 8LL * (int)v2);
v12 = (const char *)net_op_name(v2);
fprintf(stream, "\r\n \"node%d\" [ \r\n label = \"<f0> %d.%s ", v2, v2, v12);
if ( *v11 )
{
fwrite(" | ", 1uLL, 3uLL, stream);
if ( *v11 )
{
v3 = 0;
do
{
v4 = net_op_in_idx(v2, (unsigned __int16)v3);
v5 = (const char *)net_in_name(v4);
v6 = v3++;
fprintf(stream, "<f%d> -- %d.%s ", (unsigned int)v3, (unsigned int)v6, v5);
if ( *v11 - 1 > v6 )
fwrite(" | ", 1uLL, 3uLL, stream);
}
while ( v3 < *v11 );
}
}
if ( v11[1] )
{
fwrite(" | ", 1uLL, 3uLL, stream);
if ( v11[1] )
{
v10 = 0;
do
{
v7 = net_op_out_idx(v2, (unsigned __int16)v10);
v8 = (const char *)net_out_name(v7);
v9 = v10++;
fprintf(stream, "<f%d> %d.%s -- ", v10 + (unsigned int)*v11, (unsigned int)v9, v8);
if ( v11[1] - 1 > v9 )
fwrite(" | ", 1uLL, 3uLL, stream);
}
while ( v10 < v11[1] );
}
}
fwrite("\" \r\nshape = \"record\" \r\n]; \r\n", 1uLL, 0x1CuLL, stream);
++v2;
v1 = net;
}
while ( *(unsigned __int16 *)(net + 263180LL) > (int)v2 );
}
else
{
v2 = 0;
}
fwrite("\r\n", 1uLL, 2uLL, stream);
for ( i = 0; (unsigned __int16)net_num_params() > i; ++i )
{
v14 = (const char *)get_param_name((unsigned int)i);
fprintf(
stream,
"\r\n\"node%d\" [\r\n label = \"<f0> %d.%s \"\r\nshape = \"record\" \r\n ];",
v2 + i,
(unsigned int)i,
v14);
}
fwrite("\r\n", 1uLL, 2uLL, stream);
fwrite("\r\n", 1uLL, 2uLL, stream);
fwrite("\r\n", 1uLL, 2uLL, stream);
if ( *(_WORD *)(net + 263184LL) )
{
v15 = 0;
do
{
v16 = net_get_target((unsigned __int16)v15);
if ( (v16 & 0x8000u) == 0 && *(unsigned __int16 *)(net + 263182LL) > (__int16)v16 )
net_in_op_idx(v16);
++v15;
}
while ( *(unsigned __int16 *)(net + 263184LL) > v15 );
}
return fwrite("\r\n}", 1uLL, 3uLL, stream);
}

canonical_decompiled_code:
size_t __fastcall func0(FILE *stream)
{
__int64 v1; // rax
unsigned int v2; // er13
int v3; // ebx
unsigned __int16 v4; // ax
const char *v5; // rax
int v6; // er14
unsigned __int16 v7; // ax
const char *v8; // rax
int v9; // er14
int v10; // ebx
unsigned __int8 *v11; // rbp
const char *v12; // rax
int i; // ebx
const char *v14; // rax
int v15; // ebx
unsigned __int16 v16; // ax

fwrite(
"digraph g { \t\t\t\t\r\n"
"\tgraph[rankdir=\"LR\"]; \t\t\r\n"
"\tnode[ \t\t\t\r\n"
"\tfontsize=\"10\" \t\r\n"
"\tshape= \"ellipse\" ];\t\r\n"
"\tedge[]; \t\t\r\n",
1uLL,
0x6EuLL,
stream);
v1 = net;
if ( *(_WORD *)(net + 263180LL) )
{
v2 = 0;
do
{
v11 = *(unsigned __int8 **)(v1 + 8LL * (int)v2);
v12 = (const char *)net_op_name(v2);
fprintf(stream, "\r\n \"node%d\" [ \r\n label = \"<f0> %d.%s ", v2, v2, v12);
if ( *v11 )
{
fwrite(" | ", 1uLL, 3uLL, stream);
if ( *v11 )
{
v3 = 0;
do
{
v4 = net_op_in_idx(v2, (unsigned __int16)v3);
v5 = (const char *)net_in_name(v4);
v6 = v3++;
fprintf(stream, "<f%d> -- %d.%s ", (unsigned int)v3, (unsigned int)v6, v5);
if ( *v11 - 1 > v6 )
fwrite(" | ", 1uLL, 3uLL, stream);
}
while ( v3 < *v11 );
}
}
if ( v11[1] )
{
fwrite(" | ", 1uLL, 3uLL, stream);
if ( v11[1] )
{
v10 = 0;
do
{
v7 = net_op_out_idx(v2, (unsigned __int16)v10);
v8 = (const char *)net_out_name(v7);
v9 = v10++;
fprintf(stream, "<f%d> %d.%s -- ", v10 + (unsigned int)*v11, (unsigned int)v9, v8);
if ( v11[1] - 1 > v9 )
fwrite(" | ", 1uLL, 3uLL, stream);
}
while ( v10 < v11[1] );
}
}
fwrite("\" \r\nshape = \"record\" \r\n]; \r\n", 1uLL, 0x1CuLL, stream);
++v2;
v1 = net;
}
while ( *(unsigned __int16 *)(net + 263180LL) > (int)v2 );
}
else
{
v2 = 0;
}
fwrite("\r\n", 1uLL, 2uLL, stream);
for ( i = 0; (unsigned __int16)net_num_params() > i; ++i )
{
v14 = (const char *)get_param_name((unsigned int)i);
fprintf(
stream,
"\r\n\"node%d\" [\r\n label = \"<f0> %d.%s \"\r\nshape = \"record\" \r\n ];",
v2 + i,
(unsigned int)i,
v14);
}
fwrite("\r\n", 1uLL, 2uLL, stream);
fwrite("\r\n", 1uLL, 2uLL, stream);
fwrite("\r\n", 1uLL, 2uLL, stream);
if ( *(_WORD *)(net + 263184LL) )
{
v15 = 0;
do
{
v16 = net_get_target((unsigned __int16)v15);
if ( (v16 & 0x8000u) == 0 && *(unsigned __int16 *)(net + 263182LL) > (__int16)v16 )
net_in_op_idx(v16);
++v15;
}
while ( *(unsigned __int16 *)(net + 263184LL) > v15 );
}
return fwrite("\r\n}", 1uLL, 3uLL, stream);
}

original_code:
void net_write_dot(void* fp) {
  int i, j, k;
  int nId = 0;
  int eId = 0;
  int t;
  fprintf(fp,
   "digraph g { 				\r\n"
   "	graph[rankdir=\"LR\"]; 		\r\n"
   "	node[ 			\r\n"
   "	fontsize=\"10\" 	\r\n"
   "	shape= \"ellipse\" ];	\r\n"
   "	edge[]; 		\r\n"
   );
  for(i=0; i<net->numOps; ++i) {
    op_t* op = net->ops[i];
    fprintf(fp, "\r\n"
     " \"node%d\" [ \r\n"
     " label = \"<f0> %d.%s ",
     i, i, net_op_name(i));
    if(op->numInputs > 0) {
      fprintf(fp, " | ");
    }
    for(j=0; j< (op->numInputs); ++j) {
      fprintf(fp,
       "<f%d> -- %d.%s ",
       j+1, j, net_in_name(net_op_in_idx(i, j)) );
      if(j < ((op->numInputs) - 1)) {
 fprintf(fp, " | ");
      }
    }
    if(op->numOutputs > 0) {
      fprintf(fp, " | ");
    }
    for(j=0; j< (op->numOutputs); ++j) {
      fprintf(fp,
       "<f%d> %d.%s -- ",
       j+1 + op->numInputs, j, net_out_name(net_op_out_idx(i, j)));
      if(j < ((op->numOutputs) - 1)) {
 fprintf(fp, " | ");
      }
    }
    fprintf(fp,
     "\" \r\n"
     "shape = \"record\" \r\n"
     "]; \r\n" );
    nId++;
  }
  fprintf(fp, "\r\n");
  for(i=0; i<net_num_params(); i++ ) {
    fprintf(fp, "\r\n"
     "\"node%d\" [\r\n"
     " label = \"<f0> %d.%s \"\r\n"
     "shape = \"record\" \r\n ];",
     nId, i, get_param_name(i)
     );
    nId++;
  }
  fprintf(fp, "\r\n");
  fprintf(fp, "\r\n");
  fprintf(fp, "\r\n");
  for(i=0; i<net->numOuts; i++) {
    t = net_get_target(i);
    if( t > -1) {
      if( t < net->numIns) {
 j = net_in_op_idx(t);
 k = net->ins[t].opInIdx;
      } else {
      }
    }
    eId++;
  }
  fprintf(fp, "\r\n}");
}

canonical_original_code:
void net_write_dot(void *fp) {
  int i; int j; int k;
  int nId = 0;
  int eId = 0;
  int t;
  fprintf(fp,
   "digraph g { 				\r\n"
   "	graph[rankdir=\"LR\"]; 		\r\n"
   "	node[ 			\r\n"
   "	fontsize=\"10\" 	\r\n"
   "	shape= \"ellipse\" ];	\r\n"
   "	edge[]; 		\r\n"
   );
  for(i=0; i<net->numOps; ++i) {
    struct op_struct *op = net->ops[i];
    fprintf(fp, "\r\n"
     " \"node%d\" [ \r\n"
     " label = \"<f0> %d.%s ",
     i, i, net_op_name(i));
    if(op->numInputs > 0) {
      fprintf(fp, " | ");
    }
    for(j=0; j< (op->numInputs); ++j) {
      fprintf(fp,
       "<f%d> -- %d.%s ",
       j+1, j, net_in_name(net_op_in_idx(i, j)) );
      if(j < ((op->numInputs) - 1)) {
 fprintf(fp, " | ");
      }
    }
    if(op->numOutputs > 0) {
      fprintf(fp, " | ");
    }
    for(j=0; j< (op->numOutputs); ++j) {
      fprintf(fp,
       "<f%d> %d.%s -- ",
       j+1 + op->numInputs, j, net_out_name(net_op_out_idx(i, j)));
      if(j < ((op->numOutputs) - 1)) {
 fprintf(fp, " | ");
      }
    }
    fprintf(fp,
     "\" \r\n"
     "shape = \"record\" \r\n"
     "]; \r\n" );
    nId++;
  }
  fprintf(fp, "\r\n");
  for(i=0; i<net_num_params(); i++ ) {
    fprintf(fp, "\r\n"
     "\"node%d\" [\r\n"
     " label = \"<f0> %d.%s \"\r\n"
     "shape = \"record\" \r\n ];",
     nId, i, get_param_name(i)
     );
    nId++;
  }
  fprintf(fp, "\r\n");
  fprintf(fp, "\r\n");
  fprintf(fp, "\r\n");
  for(i=0; i<net->numOuts; i++) {
    t = net_get_target(i);
    if( t > -1) {
      if( t < net->numIns) {
 j = net_in_op_idx(t);
 k = net->ins[t].opInIdx;
      } else {
      }
    }
    eId++;
  }
  fprintf(fp, "\r\n}");
}

variable_types:
fp
void *

variable_types: i int

variable_types: k int

variable_types: nId int

variable_types: eId int

variable_types: t int

user_defined_types: struct op_struct { unsigned char numInputs; unsigned char numOutputs; void (*inc_fn)(void *op, short idx, short inc); void (**in_fn)(void *op, short input); unsigned char *(*pickle)(void *op, unsigned char *dst); unsigned char *(*unpickle)(void *op, unsigned char *src); short **in_val; short *out; char *opString; char *inString; char *outString; unsigned int type; unsigned int flags; void *child; }


decompiled_code:
__int64 __fastcall fix16_sin_parabola(int a1)
{
int v1; // ebx
unsigned int v2; // eax
int v3; // ebx
int v4; // eax

v1 = fix16_mul(83443LL, (unsigned int)a1);
v2 = fix16_mul(4294940736LL, (unsigned int)a1);
v3 = fix16_mul(v2, (a1 >> 31) ^ (unsigned int)(a1 + (a1 >> 31))) + v1;
v4 = fix16_mul((unsigned int)v3, (v3 >> 31) ^ (unsigned int)(v3 + (v3 >> 31)));
return v3 + (unsigned int)fix16_mul(14746LL, (unsigned int)(v4 - v3));
}

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

v1 = fix16_mul(83443LL, (unsigned int)a1);
v2 = fix16_mul(4294940736LL, (unsigned int)a1);
v3 = fix16_mul(v2, (a1 >> 31) ^ (unsigned int)(a1 + (a1 >> 31))) + v1;
v4 = fix16_mul((unsigned int)v3, (v3 >> 31) ^ (unsigned int)(v3 + (v3 >> 31)));
return v3 + (unsigned int)fix16_mul(14746LL, (unsigned int)(v4 - v3));
}

original_code:
fix16_t fix16_sin_parabola(fix16_t inAngle)
{
 fix16_t abs_inAngle, abs_retval, retval;
 fix16_t mask;
 mask = (inAngle >> (sizeof(fix16_t)*8 -1));
 abs_inAngle = (inAngle + mask) ^ mask;
 retval = fix16_mul(FOUR_DIV_PI, inAngle) + fix16_mul( fix16_mul(_FOUR_DIV_PI2, inAngle), abs_inAngle );
 mask = (retval >> (sizeof(fix16_t)*8 -1));
 abs_retval = (retval + mask) ^ mask;
 retval += fix16_mul(X4_CORRECTION_COMPONENT, fix16_mul(retval, abs_retval) - retval );
 return retval;
}

canonical_original_code:
int fix16_sin_parabola(int inAngle)
{
 int abs_inAngle; int abs_retval; int retval;
 int mask;
 mask = (inAngle >> (sizeof(fix16_t)*8 -1));
 abs_inAngle = (inAngle + mask) ^ mask;
 retval = fix16_mul(FOUR_DIV_PI, inAngle) + fix16_mul( fix16_mul(_FOUR_DIV_PI2, inAngle), abs_inAngle );
 mask = (retval >> (sizeof(fix16_t)*8 -1));
 abs_retval = (retval + mask) ^ mask;
 retval += fix16_mul(X4_CORRECTION_COMPONENT, fix16_mul(retval, abs_retval) - retval );
 return retval;
}

variable_types: inAngle int

variable_types: retval int

variable_types: mask int


decompiled_code:
__int64 __fastcall fix16_sin(int a1)
{
unsigned int v1; // ebx
int v2; // er12
unsigned int v3; // er13
unsigned int v4; // eax
unsigned int v5; // er14
unsigned int v6; // eax
unsigned int v7; // ebx
unsigned int v8; // eax
unsigned int v9; // er14
unsigned int v10; // eax
__int64 result; // rax

v1 = a1 % 411774;
if ( a1 % 411774 <= 205887 )
{
if ( (int)v1 < -205887 )
v1 += 411774;
}
else
{
v1 -= 411774;
}
v2 = (a1 >> 5) & 0xFFF;
if ( fix16_sin_cache_index[v2] == a1 )
return (unsigned int)fix16_sin_cache_value[v2];
v3 = fix16_mul(v1, v1);
v4 = fix16_mul(v1, v3);
v5 = v1 + (int)v4 / -6;
v6 = fix16_mul(v4, v3);
v7 = v5 + (int)v6 / 120;
v8 = fix16_mul(v6, v3);
v9 = v7 + (int)v8 / -5040;
v10 = fix16_mul(v8, v3);
result = (int)v10 / 362880 + v9 + (int)fix16_mul(v10, v3) / -39916800;
fix16_sin_cache_index[v2] = a1;
fix16_sin_cache_value[v2] = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
unsigned int v1; // ebx
int v2; // er12
unsigned int v3; // er13
unsigned int v4; // eax
unsigned int v5; // er14
unsigned int v6; // eax
unsigned int v7; // ebx
unsigned int v8; // eax
unsigned int v9; // er14
unsigned int v10; // eax
__int64 result; // rax

v1 = a1 % 411774;
if ( a1 % 411774 <= 205887 )
{
if ( (int)v1 < -205887 )
v1 += 411774;
}
else
{
v1 -= 411774;
}
v2 = (a1 >> 5) & 0xFFF;
if ( fix16_sin_cache_index[v2] == a1 )
return (unsigned int)fix16_sin_cache_value[v2];
v3 = fix16_mul(v1, v1);
v4 = fix16_mul(v1, v3);
v5 = v1 + (int)v4 / -6;
v6 = fix16_mul(v4, v3);
v7 = v5 + (int)v6 / 120;
v8 = fix16_mul(v6, v3);
v9 = v7 + (int)v8 / -5040;
v10 = fix16_mul(v8, v3);
result = (int)v10 / 362880 + v9 + (int)fix16_mul(v10, v3) / -39916800;
fix16_sin_cache_index[v2] = a1;
fix16_sin_cache_value[v2] = result;
return result;
}

original_code:
fix16_t fix16_sin(fix16_t inAngle) {
 fix16_t tempAngle = inAngle % (fix16_pi << 1);
 if(tempAngle > fix16_pi)
  tempAngle -= (fix16_pi << 1);
 else if(tempAngle < -fix16_pi)
  tempAngle += (fix16_pi << 1);
 fix16_t tempIndex = ((inAngle >> 5) & 0x00000FFF);
 if(_fix16_sin_cache_index[tempIndex] == inAngle)
  return _fix16_sin_cache_value[tempIndex];
 fix16_t tempAngleSq = fix16_mul(tempAngle, tempAngle);
 fix16_t tempOut = tempAngle;
 tempAngle = fix16_mul(tempAngle, tempAngleSq);
 tempOut -= (tempAngle / 6);
 tempAngle = fix16_mul(tempAngle, tempAngleSq);
 tempOut += (tempAngle / 120);
 tempAngle = fix16_mul(tempAngle, tempAngleSq);
 tempOut -= (tempAngle / 5040);
 tempAngle = fix16_mul(tempAngle, tempAngleSq);
 tempOut += (tempAngle / 362880);
 tempAngle = fix16_mul(tempAngle, tempAngleSq);
 tempOut -= (tempAngle / 39916800);
 _fix16_sin_cache_index[tempIndex] = inAngle;
 _fix16_sin_cache_value[tempIndex] = tempOut;
 return tempOut;
}

canonical_original_code:
int fix16_sin(int inAngle) {
 int tempAngle = inAngle % (fix16_pi << 1);
 if(tempAngle > fix16_pi)
  tempAngle -= (fix16_pi << 1);
 else if(tempAngle < -fix16_pi)
  tempAngle += (fix16_pi << 1);
 int tempIndex = ((inAngle >> 5) & 0x00000FFF);
 if(_fix16_sin_cache_index[tempIndex] == inAngle)
  return _fix16_sin_cache_value[tempIndex];
 int tempAngleSq = fix16_mul(tempAngle, tempAngle);
 int tempOut = tempAngle;
 tempAngle = fix16_mul(tempAngle, tempAngleSq);
 tempOut -= (tempAngle / 6);
 tempAngle = fix16_mul(tempAngle, tempAngleSq);
 tempOut += (tempAngle / 120);
 tempAngle = fix16_mul(tempAngle, tempAngleSq);
 tempOut -= (tempAngle / 5040);
 tempAngle = fix16_mul(tempAngle, tempAngleSq);
 tempOut += (tempAngle / 362880);
 tempAngle = fix16_mul(tempAngle, tempAngleSq);
 tempOut -= (tempAngle / 39916800);
 _fix16_sin_cache_index[tempIndex] = inAngle;
 _fix16_sin_cache_value[tempIndex] = tempOut;
 return tempOut;
}

variable_types: tempAngle int

variable_types: tempIndex int

variable_types: tempAngleSq int

variable_types: tempOut int


decompiled_code:
__int64 __fastcall fix16_cos(int a1)
{
return fix16_sin(a1 + 102943);
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1)
{
return func1(a1 + 102943);
}

original_code:
fix16_t fix16_cos(fix16_t inAngle) {
 return fix16_sin(inAngle + (fix16_pi >> 1));
}

canonical_original_code:
int fix16_cos(int inAngle) {
 return fix16_sin(inAngle + (fix16_pi >> 1));
}


decompiled_code:
__int64 __fastcall fix16_tan(int a1)
{
unsigned int v1; // ebp
unsigned int v2; // eax

v1 = fix16_cos(a1);
v2 = fix16_sin(a1);
return fix16_sdiv(v2, v1);
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1)
{
unsigned int v1; // ebp
unsigned int v2; // eax

v1 = func2(a1);
v2 = func1(a1);
return fix16_sdiv(v2, v1);
}

original_code:
fix16_t fix16_tan(fix16_t inAngle) {
 return fix16_sdiv(fix16_sin(inAngle), fix16_cos(inAngle));
}

canonical_original_code:
int fix16_tan(int inAngle) {
 return fix16_sdiv(fix16_sin(inAngle), fix16_cos(inAngle));
}


decompiled_code:
__int64 __fastcall fix16_atan2(int a1, int a2)
{
__int64 v3; // rbp
int v4; // edi
unsigned int v5; // er14
unsigned int v6; // eax
unsigned int v7; // eax
int v8; // ebx
__int64 result; // rax
unsigned int v10; // er14
unsigned int v11; // eax
unsigned int v12; // eax
int v13; // ebx

v3 = ((unsigned __int16)(a1 ^ a2) ^ (unsigned __int16)((unsigned __int64)(a1 ^ a2) >> 20)) & 0xFFF;
if ( fix16_atan_cache_index[v3] == a2 && dword_8380[v3] == a1 )
return (unsigned int)fix16_atan_cache_value[v3];
v4 = (a1 >> 31) ^ (a1 + (a1 >> 31));
if ( a2 < 0 )
{
v10 = fix16_div((unsigned int)(a2 + v4), (unsigned int)(v4 - a2));
v11 = fix16_mul(v10, v10);
v12 = fix16_mul(v11, v10);
v13 = fix16_mul(12864LL, v12);
result = v13 - (unsigned int)fix16_mul(64336LL, v10) + 154415;
}
else
{
v5 = fix16_div((unsigned int)(a2 - v4), (unsigned int)(a2 + v4));
v6 = fix16_mul(v5, v5);
v7 = fix16_mul(v6, v5);
v8 = fix16_mul(12864LL, v7);
result = v8 - (unsigned int)fix16_mul(64336LL, v5) + 51471;
}
if ( a1 < 0 )
result = (unsigned int)-(int)result;
fix16_atan_cache_index[v3] = a2;
dword_8380[v3] = a1;
fix16_atan_cache_value[v3] = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(int a1, int a2)
{
__int64 v3; // rbp
int v4; // edi
unsigned int v5; // er14
unsigned int v6; // eax
unsigned int v7; // eax
int v8; // ebx
__int64 result; // rax
unsigned int v10; // er14
unsigned int v11; // eax
unsigned int v12; // eax
int v13; // ebx

v3 = ((unsigned __int16)(a1 ^ a2) ^ (unsigned __int16)((unsigned __int64)(a1 ^ a2) >> 20)) & 0xFFF;
if ( fix16_atan_cache_index[v3] == a2 && dword_8380[v3] == a1 )
return (unsigned int)fix16_atan_cache_value[v3];
v4 = (a1 >> 31) ^ (a1 + (a1 >> 31));
if ( a2 < 0 )
{
v10 = fix16_div((unsigned int)(a2 + v4), (unsigned int)(v4 - a2));
v11 = fix16_mul(v10, v10);
v12 = fix16_mul(v11, v10);
v13 = fix16_mul(12864LL, v12);
result = v13 - (unsigned int)fix16_mul(64336LL, v10) + 154415;
}
else
{
v5 = fix16_div((unsigned int)(a2 - v4), (unsigned int)(a2 + v4));
v6 = fix16_mul(v5, v5);
v7 = fix16_mul(v6, v5);
v8 = fix16_mul(12864LL, v7);
result = v8 - (unsigned int)fix16_mul(64336LL, v5) + 51471;
}
if ( a1 < 0 )
result = (unsigned int)-(int)result;
fix16_atan_cache_index[v3] = a2;
dword_8380[v3] = a1;
fix16_atan_cache_value[v3] = result;
return result;
}

original_code:
fix16_t fix16_atan2(fix16_t inY , fix16_t inX) {
 fix16_t abs_inY, mask, angle, r, r_3;
 uintptr_t hash = (inX ^ inY);
 hash ^= hash >> 20;
 hash &= 0x0FFF;
 if((_fix16_atan_cache_index[0][hash] == inX) && (_fix16_atan_cache_index[1][hash] == inY))
  return _fix16_atan_cache_value[hash];
 mask = (inY >> (sizeof(fix16_t)*8 -1));
 abs_inY = (inY + mask) ^ mask;
 if (inX >= 0)
 {
  r = fix16_div( (inX - abs_inY), (inX + abs_inY));
  r_3 = fix16_mul(fix16_mul(r, r),r);
  angle = fix16_mul(0x00003240 , r_3) - fix16_mul(0x0000FB50,r) + PI_DIV_4;
 } else {
  r = fix16_div( (inX + abs_inY), (abs_inY - inX));
  r_3 = fix16_mul(fix16_mul(r, r),r);
  angle = fix16_mul(0x00003240 , r_3) - fix16_mul(0x0000FB50,r) + THREE_PI_DIV_4;
 }
 if (inY < 0)
 {
  angle = -angle;
 }
 _fix16_atan_cache_index[0][hash] = inX;
 _fix16_atan_cache_index[1][hash] = inY;
 _fix16_atan_cache_value[hash] = angle;
 return angle;
}

canonical_original_code:
int fix16_atan2(int inY, int inX) {
 int abs_inY; int mask; int angle; int r; int r_3;
 unsigned long hash = (inX ^ inY);
 hash ^= hash >> 20;
 hash &= 0x0FFF;
 if((_fix16_atan_cache_index[0][hash] == inX) && (_fix16_atan_cache_index[1][hash] == inY))
  return _fix16_atan_cache_value[hash];
 mask = (inY >> (sizeof(fix16_t)*8 -1));
 abs_inY = (inY + mask) ^ mask;
 if (inX >= 0)
 {
  r = fix16_div( (inX - abs_inY), (inX + abs_inY));
  r_3 = fix16_mul(fix16_mul(r, r),r);
  angle = fix16_mul(0x00003240 , r_3) - fix16_mul(0x0000FB50,r) + PI_DIV_4;
 } else {
  r = fix16_div( (inX + abs_inY), (abs_inY - inX));
  r_3 = fix16_mul(fix16_mul(r, r),r);
  angle = fix16_mul(0x00003240 , r_3) - fix16_mul(0x0000FB50,r) + THREE_PI_DIV_4;
 }
 if (inY < 0)
 {
  angle = -angle;
 }
 _fix16_atan_cache_index[0][hash] = inX;
 _fix16_atan_cache_index[1][hash] = inY;
 _fix16_atan_cache_value[hash] = angle;
 return angle;
}

variable_types: inY int

variable_types: inX int

variable_types: angle int

variable_types: r int

variable_types:
hash
unsigned long


decompiled_code:
__int64 __fastcall fix16_atan(int a1)
{
return fix16_atan2(a1, (int)&unk_10000);
}

canonical_decompiled_code:
__int64 __fastcall func5(int a1)
{
return func4(a1, (int)&unk_10000);
}

original_code:
fix16_t fix16_atan(fix16_t inValue) {
 return fix16_atan2(inValue, fix16_one);
}

canonical_original_code:
int fix16_atan(int inValue) {
 return fix16_atan2(inValue, fix16_one);
}

variable_types: inValue int


decompiled_code:
__int64 __fastcall fix16_asin(__int64 a1)
{
__int64 result; // rax
int v2; // eax
unsigned int v3; // eax
int v4; // eax

result = 0LL;
if ( (unsigned int)((unsigned int)&unk_10000 + a1) <= 0x20000 )
{
v2 = fix16_mul(a1, (unsigned int)a1);
v3 = fix16_sqrt((unsigned int)((_DWORD)&unk_10000 - v2));
v4 = fix16_div((unsigned int)a1, v3);
result = fix16_atan(v4);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
__int64 result; // rax
int v2; // eax
unsigned int v3; // eax
int v4; // eax

result = 0LL;
if ( (unsigned int)((unsigned int)&unk_10000 + a1) <= 0x20000 )
{
v2 = fix16_mul(a1, (unsigned int)a1);
v3 = fix16_sqrt((unsigned int)((_DWORD)&unk_10000 - v2));
v4 = fix16_div((unsigned int)a1, v3);
result = func5(v4);
}
return result;
}

original_code:
fix16_t fix16_asin(fix16_t inValue) {
 if((inValue > fix16_one) || (inValue < -fix16_one))
  return 0;
 fix16_t tempOut;
 tempOut = (fix16_one - fix16_mul(inValue, inValue));
 tempOut = fix16_div(inValue, fix16_sqrt(tempOut));
 tempOut = fix16_atan(tempOut);
 return tempOut;
}

canonical_original_code:
int fix16_asin(int inValue) {
 if((inValue > fix16_one) || (inValue < -fix16_one))
  return 0;
 int tempOut;
 tempOut = (fix16_one - fix16_mul(inValue, inValue));
 tempOut = fix16_div(inValue, fix16_sqrt(tempOut));
 tempOut = fix16_atan(tempOut);
 return tempOut;
}


decompiled_code:
__int64 __fastcall fix16_acos(__int64 a1)
{
return 102943 - (unsigned int)fix16_asin(a1);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
return 102943 - (unsigned int)func6(a1);
}

original_code:
fix16_t fix16_acos(fix16_t inValue) {
 return ((fix16_pi >> 1) - fix16_asin(inValue));
}

canonical_original_code:
int fix16_acos(int inValue) {
 return ((fix16_pi >> 1) - fix16_asin(inValue));
}


decompiled_code:
__int64 __fastcall scaler_get_value(__int64 a1, __int16 a2)
{
__int64 (__fastcall *v2)(__int64, _QWORD); // rax

print_dbg("\r\n scaler_get_value, type: ");
print_dbg_ulong(*(unsigned int *)(*(_QWORD *)a1 + 16LL));
v2 = (__int64 (__fastcall *)(__int64, _QWORD))*(&scaler_get_val_pr + *(unsigned int *)(*(_QWORD *)a1 + 16LL));
if ( v2 )
return v2(a1, (unsigned int)a2);
print_dbg("\r\n null function pointer in scaler_get_value");
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int16 a2)
{
__int64 (__fastcall *v2)(__int64, _QWORD); // rax

print_dbg("\r\n scaler_get_value, type: ");
print_dbg_ulong(*(unsigned int *)(*(_QWORD *)a1 + 16LL));
v2 = (__int64 (__fastcall *)(__int64, _QWORD))*(&scaler_get_val_pr + *(unsigned int *)(*(_QWORD *)a1 + 16LL));
if ( v2 )
return v2(a1, (unsigned int)a2);
print_dbg("\r\n null function pointer in scaler_get_value");
return 0LL;
}

original_code:
s32 scaler_get_value(ParamScaler* sc, io_t in) {
  print_dbg("\r\n scaler_get_value, type: ");
  print_dbg_ulong(sc->desc->type);
  scaler_get_value_fn fn = scaler_get_val_pr[sc->desc->type];
  if(fn != 0) {
    return (*fn)(sc, in);
  } else {
    print_dbg("\r\n null function pointer in scaler_get_value");
    return 0;
  }
}

canonical_original_code:
int scaler_get_value(struct _paramScaler *sc, short in) {
  print_dbg("\r\n scaler_get_value, type: ");
  print_dbg_ulong(sc->desc->type);
  int (*fn)(void *scaler, short in) = scaler_get_val_pr[sc->desc->type];
  if(fn != 0) {
    return (*fn)(sc, in);
  } else {
    print_dbg("\r\n null function pointer in scaler_get_value");
    return 0;
  }
}

variable_types: struct _paramScaler { struct ParamDescStruct { char label[16]; enum ParamType { eParamTypeBool=0, eParamTypeFix=1, eParamTypeAmp=2, eParamTypeIntegrator=3, eParamTypeNote=4, eParamTypeSvfFreq=5, eParamTypeFract=6, eParamTypeShort=7, eParamTypeIntegratorShort=8, eParamNumTypes=9 } type; int min; int max; unsigned char radix; } *desc; short inMin; short inMax; } *

variable_types: in short

variable_types:
fn
int (*)(void *scaler, short in)

user_defined_types: struct _paramScaler { struct ParamDescStruct *desc; short inMin; short inMax; }

user_defined_types: struct ParamDescStruct { char label[16]; enum ParamType type; int min; int max; unsigned char radix; }


decompiled_code:
__int64 __fastcall scaler_get_in(__int64 a1, int a2)
{
__int64 (*v2)(void); // rax
unsigned int v3; // ebp

v2 = (__int64 (*)(void))*(&scaler_get_in_pr + *(unsigned int *)(*(_QWORD *)a1 + 16LL));
v3 = 0;
if ( v2 )
{
v3 = v2();
print_dbg("\r\n getting input value for scaler. ");
print_dbg(" param type from desc: ");
print_dbg_ulong(*(unsigned int *)(*(_QWORD *)a1 + 16LL));
print_dbg(", default DSP value: 0x");
print_dbg_hex(a2);
print_dbg(", setting input node: 0x");
print_dbg_hex((__int16)v3);
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, int a2)
{
__int64 (*v2)(void); // rax
unsigned int v3; // ebp

v2 = (__int64 (*)(void))*(&scaler_get_in_pr + *(unsigned int *)(*(_QWORD *)a1 + 16LL));
v3 = 0;
if ( v2 )
{
v3 = v2();
print_dbg("\r\n getting input value for scaler. ");
print_dbg(" param type from desc: ");
print_dbg_ulong(*(unsigned int *)(*(_QWORD *)a1 + 16LL));
print_dbg(", default DSP value: 0x");
print_dbg_hex(a2);
print_dbg(", setting input node: 0x");
print_dbg_hex((__int16)v3);
}
return v3;
}

original_code:
io_t scaler_get_in(ParamScaler* sc, s32 value) {
  io_t val;
  scaler_get_in_fn fn = scaler_get_in_pr[sc->desc->type];
  if( fn != 0) {
    val = (*fn)(sc, value);
    print_dbg("\r\n getting input value for scaler. ");
    print_dbg(" param type from desc: ");
    print_dbg_ulong(sc->desc->type);
    print_dbg(", default DSP value: 0x");
    print_dbg_hex(value);
    print_dbg(", setting input node: 0x");
    print_dbg_hex(val);
    return val;
  } else {
    return 0;
  }
}

canonical_original_code:
short scaler_get_in(struct _paramScaler *sc, int value) {
  short val;
  short (*fn)(void *scaler, int value) = scaler_get_in_pr[sc->desc->type];
  if( fn != 0) {
    val = (*fn)(sc, value);
    print_dbg("\r\n getting input value for scaler. ");
    print_dbg(" param type from desc: ");
    print_dbg_ulong(sc->desc->type);
    print_dbg(", default DSP value: 0x");
    print_dbg_hex(value);
    print_dbg(", setting input node: 0x");
    print_dbg_hex(val);
    return val;
  } else {
    return 0;
  }
}

variable_types: value int

variable_types: val short

variable_types:
fn
short (*)(void *scaler, int value)

return_type: short

user_defined_types: enum ParamType { eParamTypeBool=0, eParamTypeFix=1, eParamTypeAmp=2, eParamTypeIntegrator=3, eParamTypeNote=4, eParamTypeSvfFreq=5, eParamTypeFract=6, eParamTypeShort=7, eParamTypeIntegratorShort=8, eParamNumTypes=9 }


decompiled_code:
__int64 __fastcall scaler_inc(__int64 a1, __int64 a2, __int16 a3)
{
__int64 (__fastcall *v4)(__int64, __int64, _QWORD); // r12

v4 = (__int64 (__fastcall *)(__int64, __int64, _QWORD))*(&scaler_inc_pr + *(unsigned int *)(*(_QWORD *)a1 + 16LL));
print_dbg("\r\n incrementing scaler at address 0x");
print_dbg_hex((unsigned int)a1);
print_dbg(" ; type: ");
print_dbg_ulong(*(unsigned int *)(*(_QWORD *)a1 + 16LL));
print_dbg(" ; inc function pointer: 0x");
print_dbg_hex((unsigned int)v4);
if ( v4 )
return v4(a1, a2, (unsigned int)a3);
print_dbg("\r\n error, null scaler increment");
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2, __int16 a3)
{
__int64 (__fastcall *v4)(__int64, __int64, _QWORD); // r12

v4 = (__int64 (__fastcall *)(__int64, __int64, _QWORD))*(&scaler_inc_pr + *(unsigned int *)(*(_QWORD *)a1 + 16LL));
print_dbg("\r\n incrementing scaler at address 0x");
print_dbg_hex((unsigned int)a1);
print_dbg(" ; type: ");
print_dbg_ulong(*(unsigned int *)(*(_QWORD *)a1 + 16LL));
print_dbg(" ; inc function pointer: 0x");
print_dbg_hex((unsigned int)v4);
if ( v4 )
return v4(a1, a2, (unsigned int)a3);
print_dbg("\r\n error, null scaler increment");
return 0LL;
}

original_code:
extern s32 scaler_inc(ParamScaler* sc, io_t * pin, io_t inc ) {
  scaler_inc_fn fn = scaler_inc_pr[sc->desc->type];
  print_dbg("\r\n incrementing scaler at address 0x");
  print_dbg_hex((u32)sc);
  print_dbg(" ; type: ");
  print_dbg_ulong((u32)sc->desc->type);
  print_dbg(" ; inc function pointer: 0x");
  print_dbg_hex((u32)fn);
  if( fn != 0) {
    return (*fn)(sc, pin, inc);
  } else {
    print_dbg("\r\n error, null scaler increment");
    return 0;
  }
}

canonical_original_code:
extern int scaler_inc(struct _paramScaler *sc, short *pin, short inc) {
  int (*fn)(void *scaler, short *pin, short inc) = scaler_inc_pr[sc->desc->type];
  print_dbg("\r\n incrementing scaler at address 0x");
  print_dbg_hex((unsigned int)sc);
  print_dbg(" ; type: ");
  print_dbg_ulong((unsigned int)sc->desc->type);
  print_dbg(" ; inc function pointer: 0x");
  print_dbg_hex((unsigned int)fn);
  if( fn != 0) {
    return (*fn)(sc, pin, inc);
  } else {
    print_dbg("\r\n error, null scaler increment");
    return 0;
  }
}

variable_types:
pin
short *

variable_types: inc short

variable_types: int (*)(void *scaler, short *pin, short inc)


decompiled_code:
__int64 __fastcall scaler_get_data_bytes(int a1)
{
return (unsigned int)(4 * scalerDataWords[a1]);
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1)
{
return (unsigned int)(4 * scalerDataWords[a1]);
}

original_code:
u32 scaler_get_data_bytes(ParamType p) {
  return scalerDataWords[p] * 4;
}

canonical_original_code:
unsigned int scaler_get_data_bytes(enum ParamType p) {
  return scalerDataWords[p] * 4;
}

variable_types: enum ParamType { eParamTypeBool=0, eParamTypeFix=1, eParamTypeAmp=2, eParamTypeIntegrator=3, eParamTypeNote=4, eParamTypeSvfFreq=5, eParamTypeFract=6, eParamTypeShort=7, eParamTypeIntegratorShort=8, eParamNumTypes=9 }

return_type: unsigned int


decompiled_code:
__int64 __fastcall scaler_get_rep_bytes(int a1)
{
return (unsigned int)(4 * scalerRepWords[a1]);
}

canonical_decompiled_code:
__int64 __fastcall func4(int a1)
{
return (unsigned int)(4 * scalerRepWords[a1]);
}

original_code:
u32 scaler_get_rep_bytes(ParamType p) {
  return scalerRepWords[p] * 4;
}

canonical_original_code:
unsigned int scaler_get_rep_bytes(enum ParamType p) {
  return scalerRepWords[p] * 4;
}


decompiled_code:
char *__fastcall scaler_get_data_path(unsigned int a1)
{
return (char *)&scalerDataPath + 32 * a1;
}

canonical_decompiled_code:
char *__fastcall func5(unsigned int a1)
{
return (char *)&scalerDataPath + 32 * a1;
}

original_code:
const char* scaler_get_data_path(ParamType p) {
  return scalerDataPath[p];
}

canonical_original_code:
char *scaler_get_data_path(enum ParamType p) {
  return scalerDataPath[p];
}

return_type: char *


decompiled_code:
char *__fastcall scaler_get_rep_path(unsigned int a1)
{
return (char *)&scalerRepPath + 32 * a1;
}

canonical_decompiled_code:
char *__fastcall func6(unsigned int a1)
{
return (char *)&scalerRepPath + 32 * a1;
}

original_code:
const char* scaler_get_rep_path(ParamType p) {
  return scalerRepPath[p];
}

canonical_original_code:
char *scaler_get_rep_path(enum ParamType p) {
  return scalerRepPath[p];
}


decompiled_code:
__int64 __fastcall scaler_get_data_offset(int a1)
{
return (unsigned int)(4 * scalerDataOffset[a1]);
}

canonical_decompiled_code:
__int64 __fastcall func7(int a1)
{
return (unsigned int)(4 * scalerDataOffset[a1]);
}

original_code:
u32 scaler_get_data_offset(ParamType p) {
    return scalerDataOffset[p] * 4;
}

canonical_original_code:
unsigned int scaler_get_data_offset(enum ParamType p) {
    return scalerDataOffset[p] * 4;
}


decompiled_code:
__int64 __fastcall scaler_get_rep_offset(int a1)
{
return (unsigned int)(4 * scalerRepOffset[a1]);
}

canonical_decompiled_code:
__int64 __fastcall func8(int a1)
{
return (unsigned int)(4 * scalerRepOffset[a1]);
}

original_code:
u32 scaler_get_rep_offset(ParamType p) {
  return scalerRepOffset[p] * 4;
}

canonical_original_code:
unsigned int scaler_get_rep_offset(enum ParamType p) {
  return scalerRepOffset[p] * 4;
}


decompiled_code:
void **__fastcall scaler_get_nv_data(int a1)
{
void **result; // rax

switch ( a1 )
{
case 2:
result = &scaler_amp_val_data;
break;
case 3:
result = &scaler_integrator_val_data;
break;
case 4:
result = &scaler_note_val_data;
break;
case 5:
result = &scaler_svf_fc_val_data;
break;
case 8:
result = &scaler_integrator_short_val_data;
break;
default:
result = 0LL;
break;
}
return result;
}

canonical_decompiled_code:
void **__fastcall func9(int a1)
{
void **result; // rax

switch ( a1 )
{
case 2:
result = &scaler_amp_val_data;
break;
case 3:
result = &scaler_integrator_val_data;
break;
case 4:
result = &scaler_note_val_data;
break;
case 5:
result = &scaler_svf_fc_val_data;
break;
case 8:
result = &scaler_integrator_short_val_data;
break;
default:
result = 0LL;
break;
}
return result;
}

original_code:
const s32* scaler_get_nv_data(ParamType p) {
  switch(p) {
  case eParamTypeAmp :
    return (s32*)scaler_amp_val_data;
    break;
  case eParamTypeIntegrator :
    return (s32*)scaler_integrator_val_data;
    break;
  case eParamTypeNote :
    return (s32*)scaler_note_val_data;
    break;
  case eParamTypeSvfFreq :
    return (s32*)scaler_svf_fc_val_data;
    break;
  case eParamTypeIntegratorShort :
    return (s32*)scaler_integrator_short_val_data;
    break;
  default:
    return 0;
  }
}

canonical_original_code:
int *scaler_get_nv_data(enum ParamType p) {
  switch(p) {
  case eParamTypeAmp :
    return (int *)scaler_amp_val_data;
    break;
  case eParamTypeIntegrator :
    return (int *)scaler_integrator_val_data;
    break;
  case eParamTypeNote :
    return (int *)scaler_note_val_data;
    break;
  case eParamTypeSvfFreq :
    return (int *)scaler_svf_fc_val_data;
    break;
  case eParamTypeIntegratorShort :
    return (int *)scaler_integrator_short_val_data;
    break;
  default:
    return 0;
  }
}

return_type: int *


decompiled_code:
void **__fastcall scaler_get_nv_rep(int a1)
{
void **result; // rax

result = (void **)&scaler_amp_rep_data;
if ( a1 != 2 )
{
result = &scaler_integrator_rep_data;
if ( a1 != 3 )
result = 0LL;
}
return result;
}

canonical_decompiled_code:
void **__fastcall func10(int a1)
{
void **result; // rax

result = (void **)&scaler_amp_rep_data;
if ( a1 != 2 )
{
result = &scaler_integrator_rep_data;
if ( a1 != 3 )
result = 0LL;
}
return result;
}

original_code:
const s32* scaler_get_nv_rep(ParamType p) {
  switch(p) {
  case eParamTypeAmp :
    return (s32*)scaler_amp_rep_data;
    break;
  case eParamTypeIntegrator :
    return (s32*)scaler_integrator_rep_data;
    break;
  default:
    return 0;
  }
}

canonical_original_code:
int *scaler_get_nv_rep(enum ParamType p) {
  switch(p) {
  case eParamTypeAmp :
    return (int *)scaler_amp_rep_data;
    break;
  case eParamTypeIntegrator :
    return (int *)scaler_integrator_rep_data;
    break;
  default:
    return 0;
  }
}


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

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

original_code: static inline uint32_t int64_lo(int64_t x) { return (x & ((1ULL << 32) - 1)); }

canonical_original_code: static inline unsigned int int64_lo(long x) { return (x & ((1ULL << 32) - 1)); }

variable_types: x long


decompiled_code:
__int64 __fastcall int64_add(__int64 a1, __int64 a2)
{
return a1 + a2;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
return a1 + a2;
}

original_code: static inline int64_t int64_add(int64_t x, int64_t y) { return (x + y); }

canonical_original_code: static inline long int64_add(long x, long y) { return (x + y); }

variable_types: y long

return_type: long


decompiled_code:
__int64 __fastcall int64_mul_i32_i32(int a1, int a2)
{
return a2 * a1;
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1, int a2)
{
return a2 * a1;
}

original_code: static inline int64_t int64_mul_i32_i32(int32_t x, int32_t y) { return (x * y); }

canonical_original_code: static inline long int64_mul_i32_i32(int x, int y) { return (x * y); }

variable_types: x int

variable_types: y int


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

result = (unsigned int)(a1 + a2);
if ( (a1 ^ a2) >= 0 && (int)(result ^ a1) < 0 )
result = 0x80000000LL;
return result;
}

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

result = (unsigned int)(a1 + a2);
if ( (a1 ^ a2) >= 0 && (int)(result ^ a1) < 0 )
result = 0x80000000LL;
return result;
}

canonical_original_code:
int fix16_add(int a, int b)
{
  unsigned int _a = a; unsigned int _b = b;
  unsigned int sum = _a + _b;
  if (!((_a ^ _b) & 0x80000000) && ((_a ^ sum) & 0x80000000))
    return fix16_overflow;
  return sum;
}

variable_types: a int

variable_types: b int

variable_types:
sum
unsigned int


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

result = (unsigned int)(a1 - a2);
if ( (a1 ^ a2) < 0 && (int)(result ^ a1) < 0 )
result = 0x80000000LL;
return result;
}

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

result = (unsigned int)(a1 - a2);
if ( (a1 ^ a2) < 0 && (int)(result ^ a1) < 0 )
result = 0x80000000LL;
return result;
}

original_code:
fix16_t fix16_sub(fix16_t a, fix16_t b)
{
  uint32_t _a = a, _b = b;
  uint32_t diff = _a - _b;
  if (((_a ^ _b) & 0x80000000) && ((_a ^ diff) & 0x80000000))
    return fix16_overflow;
  return diff;
}

canonical_original_code:
int fix16_sub(int a, int b)
{
  unsigned int _a = a; unsigned int _b = b;
  unsigned int diff = _a - _b;
  if (((_a ^ _b) & 0x80000000) && ((_a ^ diff) & 0x80000000))
    return fix16_overflow;
  return diff;
}

variable_types:
diff
unsigned int


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

result = fix16_add(a1, a2);
if ( (_DWORD)result == 0x80000000 && a1 > 0 )
result = 0x7FFFFFFFLL;
return result;
}

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

result = func4(a1, a2);
if ( (_DWORD)result == 0x80000000 && a1 > 0 )
result = 0x7FFFFFFFLL;
return result;
}

original_code:
fix16_t fix16_sadd(fix16_t a, fix16_t b)
{
  fix16_t result = fix16_add(a, b);
  if (result == fix16_overflow)
    return (a > 0) ? fix16_max : fix16_min;
  return result;
}

canonical_original_code:
int fix16_sadd(int a, int b)
{
  int result = fix16_add(a, b);
  if (result == fix16_overflow)
    return (a > 0) ? fix16_max : fix16_min;
  return result;
}

variable_types: result int


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

result = fix16_sub(a1, a2);
if ( (_DWORD)result == 0x80000000 && a1 > 0 )
result = 0x7FFFFFFFLL;
return result;
}

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

result = func5(a1, a2);
if ( (_DWORD)result == 0x80000000 && a1 > 0 )
result = 0x7FFFFFFFLL;
return result;
}

original_code:
fix16_t fix16_ssub(fix16_t a, fix16_t b)
{
  fix16_t result = fix16_sub(a, b);
  if (result == fix16_overflow)
    return (a > 0) ? fix16_max : fix16_min;
  return result;
}

canonical_original_code:
int fix16_ssub(int a, int b)
{
  int result = fix16_sub(a, b);
  if (result == fix16_overflow)
    return (a > 0) ? fix16_max : fix16_min;
  return result;
}


original_code:
fix16_t fix16_mul(fix16_t inArg0, fix16_t inArg1)
{
  int64_t product = (int64_t)inArg0 * inArg1;
  uint32_t upper = (product >> 47);
  if (product < 0)
  {
    if (~upper)
        return fix16_overflow;
    product--;
  }
  else
  {
    if (upper)
        return fix16_overflow;
  }
  fix16_t result = product >> 16;
  result += (product & 0x8000) >> 15;
  return result;
}

canonical_original_code:
int fix16_mul(int inArg0, int inArg1)
{
  long product = (int64_t)inArg0 * inArg1;
  unsigned int upper = (product >> 47);
  if (product < 0)
  {
    if (~upper)
        return fix16_overflow;
    product--;
  }
  else
  {
    if (upper)
        return fix16_overflow;
  }
  int result = product >> 16;
  result += (product & 0x8000) >> 15;
  return result;
}

variable_types: product long

variable_types:
upper
unsigned int


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

result = fix16_mul(a1, a2);
if ( (_DWORD)result == 0x80000000 && a1 < 0 != a2 >= 0 )
result = 0x7FFFFFFFLL;
return result;
}

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

result = func8(a1, a2);
if ( (_DWORD)result == 0x80000000 && a1 < 0 != a2 >= 0 )
result = 0x7FFFFFFFLL;
return result;
}

original_code:
fix16_t fix16_smul(fix16_t inArg0, fix16_t inArg1) {
  fix16_t result = fix16_mul(inArg0, inArg1);
  if (result == fix16_overflow)
  {
    if ((inArg0 >= 0) == (inArg1 >= 0))
      return fix16_max;
    else
      return fix16_min;
  }
  return result;
}

canonical_original_code:
int fix16_smul(int inArg0, int inArg1) {
  int result = fix16_mul(inArg0, inArg1);
  if (result == fix16_overflow)
  {
    if ((inArg0 >= 0) == (inArg1 >= 0))
      return fix16_max;
    else
      return fix16_min;
  }
  return result;
}


original_code:
fix16_t fix16_div(fix16_t a, fix16_t b)
{
  if (b == 0)
      return fix16_min;
  uint32_t remainder = (a >= 0) ? a : (-a);
  uint32_t divider = (b >= 0) ? b : (-b);
  uint32_t quotient = 0;
  int bit_pos = 17;
  if (divider & 0xFFF00000)
  {
    uint32_t shifted_div = ((divider >> 17) + 1);
    quotient = remainder / shifted_div;
    remainder -= ((uint64_t)quotient * divider) >> 17;
  }
  while (!(divider & 0xF) && bit_pos >= 4)
  {
    divider >>= 4;
    bit_pos -= 4;
  }
  while (remainder && bit_pos >= 0)
  {
    int shift = __builtin_clzl(remainder);
    if (shift > bit_pos) shift = bit_pos;
    remainder <<= shift;
    bit_pos -= shift;
    uint32_t div = remainder / divider;
    remainder = remainder % divider;
    quotient += div << bit_pos;
    if (div & ~(0xFFFFFFFF >> bit_pos))
        return fix16_overflow;
    remainder <<= 1;
    bit_pos--;
  }
  quotient++;
  fix16_t result = quotient >> 1;
  if ((a ^ b) & 0x80000000)
  {
    if (result == fix16_min)
        return fix16_overflow;
    result = -result;
  }
  return result;
}

canonical_original_code:
int fix16_div(int a, int b)
{
  if (b == 0)
      return fix16_min;
  unsigned int remainder = (a >= 0) ? a : (-a);
  unsigned int divider = (b >= 0) ? b : (-b);
  unsigned int quotient = 0;
  int bit_pos = 17;
  if (divider & 0xFFF00000)
  {
    unsigned int shifted_div = ((divider >> 17) + 1);
    quotient = remainder / shifted_div;
    remainder -= ((unsigned long)quotient * divider) >> 17;
  }
  while (!(divider & 0xF) && bit_pos >= 4)
  {
    divider >>= 4;
    bit_pos -= 4;
  }
  while (remainder && bit_pos >= 0)
  {
    int shift = __builtin_clzl(remainder);
    if (shift > bit_pos) shift = bit_pos;
    remainder <<= shift;
    bit_pos -= shift;
    unsigned int div = remainder / divider;
    remainder = remainder % divider;
    quotient += div << bit_pos;
    if (div & ~(0xFFFFFFFF >> bit_pos))
        return fix16_overflow;
    remainder <<= 1;
    bit_pos--;
  }
  quotient++;
  int result = quotient >> 1;
  if ((a ^ b) & 0x80000000)
  {
    if (result == fix16_min)
        return fix16_overflow;
    result = -result;
  }
  return result;
}

variable_types:
remainder
unsigned int

variable_types:
divider
unsigned int

variable_types:
quotient
unsigned int

variable_types: shift int

variable_types:
div
unsigned int


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

result = fix16_div(a1, a2);
if ( (_DWORD)result == 0x80000000 && a1 < 0 != a2 >= 0 )
result = 0x7FFFFFFFLL;
return result;
}

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

result = func10(a1, a2);
if ( (_DWORD)result == 0x80000000 && a1 < 0 != a2 >= 0 )
result = 0x7FFFFFFFLL;
return result;
}

original_code:
fix16_t fix16_sdiv(fix16_t inArg0, fix16_t inArg1) {
  fix16_t result = fix16_div(inArg0, inArg1);
  if (result == fix16_overflow)
  {
    if ((inArg0 >= 0) == (inArg1 >= 0))
      return fix16_max;
    else
      return fix16_min;
  }
  return result;
}

canonical_original_code:
int fix16_sdiv(int inArg0, int inArg1) {
  int result = fix16_div(inArg0, inArg1);
  if (result == fix16_overflow)
  {
    if ((inArg0 >= 0) == (inArg1 >= 0))
      return fix16_max;
    else
      return fix16_min;
  }
  return result;
}


decompiled_code:
__int64 __fastcall fix16_lerp8(int a1, int a2, unsigned __int8 a3)
{
int v3; // ebx
__int64 v4; // rbp
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax

v3 = a3;
v4 = int64_mul_i32_i32(a1, 256 - (unsigned int)a3);
v5 = int64_mul_i32_i32(a2, v3);
v6 = int64_add(v4, v5);
v7 = int64_shift(v6, -8);
return int64_lo(v7);
}

canonical_decompiled_code:
__int64 __fastcall func12(int a1, int a2, unsigned __int8 a3)
{
int v3; // ebx
__int64 v4; // rbp
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax

v3 = a3;
v4 = func3(a1, 256 - (unsigned int)a3);
v5 = func3(a2, v3);
v6 = func1(v4, v5);
v7 = func2(v6, -8);
return func0(v7);
}

original_code:
fix16_t fix16_lerp8(fix16_t inArg0, fix16_t inArg1, uint8_t inFract) {
 int64_t tempOut = int64_mul_i32_i32(inArg0, ((1 << 8) - inFract));
 tempOut = int64_add(tempOut, int64_mul_i32_i32(inArg1, inFract));
 tempOut = int64_shift(tempOut, -8);
 return (fix16_t)int64_lo(tempOut);
}

canonical_original_code:
int fix16_lerp8(int inArg0, int inArg1, unsigned char inFract) {
 long tempOut = int64_mul_i32_i32(inArg0, ((1 << 8) - inFract));
 tempOut = int64_add(tempOut, int64_mul_i32_i32(inArg1, inFract));
 tempOut = int64_shift(tempOut, -8);
 return (int)int64_lo(tempOut);
}

variable_types:
inFract
unsigned char

variable_types: tempOut long


decompiled_code:
__int64 __fastcall fix16_lerp16(int a1, int a2, unsigned __int16 a3)
{
int v3; // ebx
__int64 v4; // rbp
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax

v3 = a3;
v4 = int64_mul_i32_i32(a1, 0x10000 - (unsigned int)a3);
v5 = int64_mul_i32_i32(a2, v3);
v6 = int64_add(v4, v5);
v7 = int64_shift(v6, -16);
return int64_lo(v7);
}

canonical_decompiled_code:
__int64 __fastcall func13(int a1, int a2, unsigned __int16 a3)
{
int v3; // ebx
__int64 v4; // rbp
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax

v3 = a3;
v4 = func3(a1, 0x10000 - (unsigned int)a3);
v5 = func3(a2, v3);
v6 = func1(v4, v5);
v7 = func2(v6, -16);
return func0(v7);
}

original_code:
fix16_t fix16_lerp16(fix16_t inArg0, fix16_t inArg1, uint16_t inFract) {
 int64_t tempOut = int64_mul_i32_i32(inArg0, ((1 << 16) - inFract));
 tempOut = int64_add(tempOut, int64_mul_i32_i32(inArg1, inFract));
 tempOut = int64_shift(tempOut, -16);
 return (fix16_t)int64_lo(tempOut);
}

canonical_original_code:
int fix16_lerp16(int inArg0, int inArg1, unsigned short inFract) {
 long tempOut = int64_mul_i32_i32(inArg0, ((1 << 16) - inFract));
 tempOut = int64_add(tempOut, int64_mul_i32_i32(inArg1, inFract));
 tempOut = int64_shift(tempOut, -16);
 return (int)int64_lo(tempOut);
}

variable_types:
inFract
unsigned short


decompiled_code:
__int64 __fastcall fix16_lerp32(int a1, int a2, unsigned int a3)
{
return (__int64)(a2 * (unsigned __int64)a3 + -a3 * (__int64)a1) >> 32;
}

canonical_decompiled_code:
__int64 __fastcall func14(int a1, int a2, unsigned int a3)
{
return (__int64)(a2 * (unsigned __int64)a3 + -a3 * (__int64)a1) >> 32;
}

original_code:
fix16_t fix16_lerp32(fix16_t inArg0, fix16_t inArg1, uint32_t inFract) {
 int64_t tempOut;
 tempOut = ((int64_t)inArg0 * (0 - inFract));
 tempOut += ((int64_t)inArg1 * inFract);
 tempOut >>= 32;
 return (fix16_t)tempOut;
}

canonical_original_code:
int fix16_lerp32(int inArg0, int inArg1, unsigned int inFract) {
 long tempOut;
 tempOut = ((long)inArg0 * (0 - inFract));
 tempOut += ((long)inArg1 * inFract);
 tempOut >>= 32;
 return (int)tempOut;
}

variable_types:
inFract
unsigned int


decompiled_code:
__int64 __fastcall handle_MonomeGridKey(unsigned int a1)
{
return monome_grid_key_handler(monomeOpFocus, a1);
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1)
{
return monome_grid_key_handler(monomeOpFocus, a1);
}

original_code:
static void handle_MonomeGridKey(s32 data) {
  (*monome_grid_key_handler)(monomeOpFocus, data);
}

canonical_original_code:
static void handle_MonomeGridKey(int data) {
  (*monome_grid_key_handler)(monomeOpFocus, data);
}

variable_types: data int


decompiled_code:
void handle_MonomeGridTilt()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code:
static void handle_MonomeGridTilt(s32 data) {
}

canonical_original_code:
static void handle_MonomeGridTilt(int data) {
}


decompiled_code:
__int64 __fastcall handle_MonomeRingEnc(unsigned int a1)
{
return monome_ring_enc_handler(monomeOpFocus, a1);
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1)
{
return monome_ring_enc_handler(monomeOpFocus, a1);
}

original_code:
static void handle_MonomeRingEnc(s32 data) {
  (*monome_ring_enc_handler)(monomeOpFocus, data);
}

canonical_original_code:
static void handle_MonomeRingEnc(int data) {
  (*monome_ring_enc_handler)(monomeOpFocus, data);
}


decompiled_code:
void handle_MonomeRingKey()
{
;
}

canonical_decompiled_code:
void func3()
{
;
}

original_code:
static void handle_MonomeRingKey(s32 data) {
}

canonical_original_code:
static void handle_MonomeRingKey(int data) {
}


decompiled_code:
void handle_HidConnect()
{
;
}

canonical_decompiled_code:
void func4()
{
;
}

original_code:
static void handle_HidConnect(s32 data) {
}

canonical_original_code:
static void handle_HidConnect(int data) {
}


decompiled_code:
void handle_HidDisconnect()
{
;
}

canonical_decompiled_code:
void func5()
{
;
}

original_code:
static void handle_HidDisconnect(s32 data) {
}

canonical_original_code:
static void handle_HidDisconnect(int data) {
}


decompiled_code:
void handle_HidByte()
{
;
}

canonical_decompiled_code:
void func6()
{
;
}

original_code:
static void handle_HidByte(s32 data) {
}

canonical_original_code:
static void handle_HidByte(int data) {
}


decompiled_code:
__int64 handle_MidiPacket()
{
return net_handle_midi_packet();
}

canonical_decompiled_code:
__int64 func7()
{
return net_handle_midi_packet();
}

original_code:
static void handle_MidiPacket(s32 data) {
  net_handle_midi_packet(data);
}

canonical_original_code:
static void handle_MidiPacket(int data) {
  net_handle_midi_packet(data);
}


decompiled_code:
__int64 handle_MidiDisconnect()
{
return timers_unset_midi();
}

canonical_decompiled_code:
__int64 func8()
{
return timers_unset_midi();
}

original_code:
static void handle_MidiDisconnect(s32 data) {
  timers_unset_midi();
}

canonical_original_code:
static void handle_MidiDisconnect(int data) {
  timers_unset_midi();
}


decompiled_code:
__int64 handle_MidiConnect()
{
return timers_set_midi();
}

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

original_code:
static void handle_MidiConnect(s32 data) {
  timers_set_midi();
}

canonical_original_code:
static void handle_MidiConnect(int data) {
  timers_set_midi();
}


decompiled_code:
__int64 handle_MonomeDisconnect()
{
return timers_unset_monome();
}

canonical_decompiled_code:
__int64 func10()
{
return timers_unset_monome();
}

original_code:
static void handle_MonomeDisconnect(s32 data) {
  timers_unset_monome();
}

canonical_original_code:
static void handle_MonomeDisconnect(int data) {
  timers_unset_monome();
}


decompiled_code:
__int64 handle_MonomeConnect()
{
return timers_set_monome();
}

canonical_decompiled_code:
__int64 func11()
{
return timers_set_monome();
}

original_code:
static void handle_MonomeConnect(s32 data) {
  timers_set_monome();
}

canonical_original_code:
static void handle_MonomeConnect(int data) {
  timers_set_monome();
}


decompiled_code:
__int64 __fastcall handle_Switch7(int a1)
{
return op_sw_sys_input(opSysSw[5], a1 > 0);
}

canonical_decompiled_code:
__int64 __fastcall func12(int a1)
{
return op_sw_sys_input(opSysSw[5], a1 > 0);
}

original_code:
static void handle_Switch7(s32 data) {
  op_sw_sys_input(opSysSw[5], data > 0);
}

canonical_original_code:
static void handle_Switch7(int data) {
  op_sw_sys_input(opSysSw[5], data > 0);
}


decompiled_code:
__int64 __fastcall handle_Switch6(int a1)
{
return op_sw_sys_input(opSysSw[4], a1 > 0);
}

canonical_decompiled_code:
__int64 __fastcall func13(int a1)
{
return op_sw_sys_input(opSysSw[4], a1 > 0);
}

original_code:
static void handle_Switch6(s32 data) {
  op_sw_sys_input(opSysSw[4], data > 0);
}

canonical_original_code:
static void handle_Switch6(int data) {
  op_sw_sys_input(opSysSw[4], data > 0);
}


decompiled_code:
__int64 handle_Switch5()
{
render_boot(&unk_360);
render_boot(&unk_360);
render_boot(&unk_360);
render_boot(&unk_360);
render_boot(&unk_360);
render_boot(&unk_360);
render_boot("powering down");
return delay_ms(100LL);
}

canonical_decompiled_code:
__int64 func14()
{
render_boot(&unk_360);
render_boot(&unk_360);
render_boot(&unk_360);
render_boot(&unk_360);
render_boot(&unk_360);
render_boot(&unk_360);
render_boot("powering down");
return delay_ms(100LL);
}

original_code:
static void handle_Switch5(s32 data) {
  render_boot("");
  render_boot("");
  render_boot("");
  render_boot("");
  render_boot("");
  render_boot("");
  render_boot("powering down");
  delay_ms(100);
}

canonical_original_code:
static void handle_Switch5(int data) {
  render_boot("");
  render_boot("");
  render_boot("");
  render_boot("");
  render_boot("");
  render_boot("");
  render_boot("powering down");
  delay_ms(100);
}


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

if ( a1 > 0 )
result = pages_toggle_play();
return result;
}

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

if ( a1 > 0 )
result = pages_toggle_play();
return result;
}

original_code:
static void handle_Switch4(s32 data) {
  if(data > 0) {
    if(pages_toggle_play()) {
    } else {
    }
  }
}

canonical_original_code:
static void handle_Switch4(int data) {
  if(data > 0) {
    if(pages_toggle_play()) {
    } else {
    }
  }
}


decompiled_code:
__int64 __fastcall handle_Adc3(unsigned __int16 a1)
{
return op_adc_sys_input(opSysAdc, 3LL, a1);
}

canonical_decompiled_code:
__int64 __fastcall func16(unsigned __int16 a1)
{
return op_adc_sys_input(opSysAdc, 3LL, a1);
}

original_code:
static void handle_Adc3(s32 data) {
  op_adc_sys_input(opSysAdc, 3, data);}

canonical_original_code:
static void handle_Adc3(int data) {
  op_adc_sys_input(opSysAdc, 3, data);}


decompiled_code:
__int64 __fastcall handle_Adc2(unsigned __int16 a1)
{
return op_adc_sys_input(opSysAdc, 2LL, a1);
}

canonical_decompiled_code:
__int64 __fastcall func17(unsigned __int16 a1)
{
return op_adc_sys_input(opSysAdc, 2LL, a1);
}

original_code:
static void handle_Adc2(s32 data) {
  op_adc_sys_input(opSysAdc, 2, data);
}

canonical_original_code:
static void handle_Adc2(int data) {
  op_adc_sys_input(opSysAdc, 2, data);
}


decompiled_code:
__int64 __fastcall handle_Adc1(unsigned __int16 a1)
{
return op_adc_sys_input(opSysAdc, 1LL, a1);
}

canonical_decompiled_code:
__int64 __fastcall func18(unsigned __int16 a1)
{
return op_adc_sys_input(opSysAdc, 1LL, a1);
}

original_code:
static void handle_Adc1(s32 data) {
  op_adc_sys_input(opSysAdc, 1, data);
}

canonical_original_code:
static void handle_Adc1(int data) {
  op_adc_sys_input(opSysAdc, 1, data);
}


decompiled_code:
__int64 __fastcall handle_Adc0(unsigned __int16 a1)
{
return op_adc_sys_input(opSysAdc, 0LL, a1);
}

canonical_decompiled_code:
__int64 __fastcall func19(unsigned __int16 a1)
{
return op_adc_sys_input(opSysAdc, 0LL, a1);
}

original_code:
static void handle_Adc0(s32 data) {
  op_adc_sys_input(opSysAdc, 0, data);
}

canonical_original_code:
static void handle_Adc0(int data) {
  op_adc_sys_input(opSysAdc, 0, data);
}


decompiled_code:
__int64 __fastcall scale_knob_value_small(unsigned int a1)
{
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func21(unsigned int a1)
{
return a1;
}

original_code:
io_t scale_knob_value_small(io_t val) {
  return val;
}

canonical_original_code:
short scale_knob_value_small(short val) {
  return val;
}

variable_types: val short


decompiled_code:
__int64 __fastcall scale_knob_value(__int16 a1)
{
unsigned int v1; // edx
unsigned int v3; // edx
int v4; // eax

if ( a1 < 0 )
{
v3 = (__int16)-a1;
if ( v3 > 0x17 )
{
v4 = 1792;
}
else
{
v4 = knobScale_1[v3 - 1];
v1 = v4;
if ( (v4 & 0x8000u) != 0 )
return v1;
}
return (unsigned int)-v4;
}
v1 = 1792;
if ( (unsigned int)a1 <= 0x17 )
v1 = LOWORD(knobScale_1[a1 - 1]);
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func22(__int16 a1)
{
unsigned int v1; // edx
unsigned int v3; // edx
int v4; // eax

if ( a1 < 0 )
{
v3 = (__int16)-a1;
if ( v3 > 0x17 )
{
v4 = 1792;
}
else
{
v4 = knobScale_1[v3 - 1];
v1 = v4;
if ( (v4 & 0x8000u) != 0 )
return v1;
}
return (unsigned int)-v4;
}
v1 = 1792;
if ( (unsigned int)a1 <= 0x17 )
v1 = LOWORD(knobScale_1[a1 - 1]);
return v1;
}

variable_types:
knobScale
unsigned int [24]

variable_types: vabs short

variable_types: ret short


decompiled_code:
__int64 __fastcall scale_knob_value_fast(__int16 a1)
{
unsigned int v1; // edx
unsigned int v3; // edx
int v4; // eax

if ( a1 < 0 )
{
v3 = (__int16)-a1;
if ( v3 > 0x17 )
{
v4 = 28672;
}
else
{
v4 = knobScale_0[v3 - 1];
v1 = v4;
if ( (v4 & 0x8000u) != 0 )
return v1;
}
return (unsigned int)-v4;
}
v1 = 28672;
if ( (unsigned int)a1 <= 0x17 )
v1 = LOWORD(knobScale_0[a1 - 1]);
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func23(__int16 a1)
{
unsigned int v1; // edx
unsigned int v3; // edx
int v4; // eax

if ( a1 < 0 )
{
v3 = (__int16)-a1;
if ( v3 > 0x17 )
{
v4 = 28672;
}
else
{
v4 = knobScale_0[v3 - 1];
v1 = v4;
if ( (v4 & 0x8000u) != 0 )
return v1;
}
return (unsigned int)-v4;
}
v1 = 28672;
if ( (unsigned int)a1 <= 0x17 )
v1 = LOWORD(knobScale_0[a1 - 1]);
return v1;
}


decompiled_code:
__int64 __fastcall int64_from_int32(int a1)
{
return a1;
}

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

original_code: static inline int64_t int64_from_int32(int32_t x) { return (int64_t)x; }

canonical_original_code: static inline long int64_from_int32(int x) { return (long)x; }

variable_types: x int


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

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

original_code: static inline uint32_t int64_lo(int64_t x) { return (x & ((1ULL << 32) - 1)); }

canonical_original_code: static inline unsigned int int64_lo(long x) { return (x & ((1ULL << 32) - 1)); }

variable_types: x long


decompiled_code:
__int64 __fastcall int64_add(__int64 a1, __int64 a2)
{
return a1 + a2;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
return a1 + a2;
}

original_code: static inline int64_t int64_add(int64_t x, int64_t y) { return (x + y); }

canonical_original_code: static inline long int64_add(long x, long y) { return (x + y); }

variable_types: y long


decompiled_code:
__int64 __fastcall int64_mul_i64_i32(__int64 a1, int a2)
{
return a1 * a2;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, int a2)
{
return a1 * a2;
}

original_code: static inline int64_t int64_mul_i64_i32(int64_t x, int32_t y) { return (x * y); }

canonical_original_code: static inline long int64_mul_i64_i32(long x, int y) { return (x * y); }

variable_types: y int


decompiled_code:
__int64 __fastcall int64_div_i64_i32(__int64 a1, int a2)
{
return a1 / a2;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, int a2)
{
return a1 / a2;
}

original_code: static inline int64_t int64_div_i64_i32(int64_t x, int32_t y) { return (x / y); }

canonical_original_code: static inline long int64_div_i64_i32(long x, int y) { return (x / y); }


decompiled_code:
__int64 __fastcall fix16_exp(int a1)
{
__int64 result; // rax
__int64 v2; // rbx
__int64 v3; // rax
__int64 v4; // rbp
__int64 v5; // r15
int v6; // er14
int i; // er12
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // rax
__int64 v11; // rax

result = 0x10000LL;
if ( a1 )
{
if ( a1 == 0x10000 )
{
result = 178145LL;
}
else
{
result = 0x7FFFFFFFLL;
if ( a1 <= 681391 )
{
result = 0LL;
if ( a1 >= -726817 )
{
if ( fix16_exp_cache_index[((unsigned __int16)a1 ^ (unsigned __int16)(a1 >> 4)) & 0xFFF] == a1 )
{
result = (unsigned int)fix16_exp_cache_value[((unsigned __int16)a1 ^ (unsigned __int16)(a1 >> 4)) & 0xFFF];
}
else
{
v2 = int64_from_int32(a1);
v3 = int64_from_int32(0x10000);
v4 = int64_add(v3, v2);
v5 = int64_from_int32(0x8000);
v6 = 2;
for ( i = 3; i != 13; ++i )
{
v8 = int64_mul_i64_i32(v2, a1);
v9 = int64_add(v8, v5);
v2 = int64_shift(v9, -16);
v10 = int64_div_i64_i32(v2, v6);
v11 = int64_add(v4, v10);
v4 = v11;
v6 *= i;
}
fix16_exp_cache_index[((unsigned __int16)a1 ^ (unsigned __int16)(a1 >> 4)) & 0xFFF] = a1;
result = int64_lo(v11);
fix16_exp_cache_value[((unsigned __int16)a1 ^ (unsigned __int16)(a1 >> 4)) & 0xFFF] = result;
}
}
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(int a1)
{
__int64 result; // rax
__int64 v2; // rbx
__int64 v3; // rax
__int64 v4; // rbp
__int64 v5; // r15
int v6; // er14
int i; // er12
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // rax
__int64 v11; // rax

result = 0x10000LL;
if ( a1 )
{
if ( a1 == 0x10000 )
{
result = 178145LL;
}
else
{
result = 0x7FFFFFFFLL;
if ( a1 <= 681391 )
{
result = 0LL;
if ( a1 >= -726817 )
{
if ( fix16_exp_cache_index[((unsigned __int16)a1 ^ (unsigned __int16)(a1 >> 4)) & 0xFFF] == a1 )
{
result = (unsigned int)fix16_exp_cache_value[((unsigned __int16)a1 ^ (unsigned __int16)(a1 >> 4)) & 0xFFF];
}
else
{
v2 = func0(a1);
v3 = func0(0x10000);
v4 = func2(v3, v2);
v5 = func0(0x8000);
v6 = 2;
for ( i = 3; i != 13; ++i )
{
v8 = func4(v2, a1);
v9 = func2(v8, v5);
v2 = func3(v9, -16);
v10 = func5(v2, v6);
v11 = func2(v4, v10);
v4 = v11;
v6 *= i;
}
fix16_exp_cache_index[((unsigned __int16)a1 ^ (unsigned __int16)(a1 >> 4)) & 0xFFF] = a1;
result = func1(v11);
fix16_exp_cache_value[((unsigned __int16)a1 ^ (unsigned __int16)(a1 >> 4)) & 0xFFF] = result;
}
}
}
}
}
return result;
}

original_code:
fix16_t fix16_exp(fix16_t inValue) {
 if(inValue == 0)
  return fix16_one;
 if(inValue == fix16_one)
  return fix16_e;
 if(inValue > 681391)
  return fix16_max;
 if(inValue < -726817)
  return 0;
 fix16_t tempIndex = (inValue ^ (inValue >> 16));
 tempIndex = (inValue ^ (inValue >> 4)) & 0x0FFF;
 if(_fix16_exp_cache_index[tempIndex] == inValue)
  return _fix16_exp_cache_value[tempIndex];
 int64_t tempOut = int64_add(int64_from_int32(fix16_one), int64_from_int32(inValue));
 int64_t tempValue = int64_from_int32(inValue);
 uint32_t i, n;
 for(i = 3, n = 2; i < 13; n *= i, i++) {
  tempValue = int64_mul_i64_i32(tempValue, inValue);
  tempValue = int64_add(tempValue, int64_from_int32(fix16_one >> 1));
  tempValue = int64_shift(tempValue, -16);
  tempOut = int64_add(tempOut, int64_div_i64_i32(tempValue, n));
 }
 _fix16_exp_cache_index[tempIndex] = inValue;
 _fix16_exp_cache_value[tempIndex] = int64_lo(tempOut);
 return int64_lo(tempOut);
}

canonical_original_code:
int fix16_exp(int inValue) {
 if(inValue == 0)
  return fix16_one;
 if(inValue == fix16_one)
  return fix16_e;
 if(inValue > 681391)
  return fix16_max;
 if(inValue < -726817)
  return 0;
 int tempIndex = (inValue ^ (inValue >> 16));
 tempIndex = (inValue ^ (inValue >> 4)) & 0x0FFF;
 if(_fix16_exp_cache_index[tempIndex] == inValue)
  return _fix16_exp_cache_value[tempIndex];
 long tempOut = int64_add(int64_from_int32(fix16_one), int64_from_int32(inValue));
 long tempValue = int64_from_int32(inValue);
 unsigned int i; unsigned int n;
 for(i = 3, n = 2; i < 13; n *= i, i++) {
  tempValue = int64_mul_i64_i32(tempValue, inValue);
  tempValue = int64_add(tempValue, int64_from_int32(fix16_one >> 1));
  tempValue = int64_shift(tempValue, -16);
  tempOut = int64_add(tempOut, int64_div_i64_i32(tempValue, n));
 }
 _fix16_exp_cache_index[tempIndex] = inValue;
 _fix16_exp_cache_value[tempIndex] = int64_lo(tempOut);
 return int64_lo(tempOut);
}

variable_types: inValue int

variable_types: tempIndex int

variable_types: tempValue long

variable_types:
i
unsigned int

variable_types:
n
unsigned int


decompiled_code:
__int64 __fastcall list_get_name(__int64 a1, __int16 a2)
{
return ((32 * a2) & 0x1FE0) + a1 + 64;
}

original_code:
const char* list_get_name(dirList_t* list, u8 idx) {
  return (const char*) ( list->nameBuf + (idx * 32) );
}

canonical_original_code:
char *list_get_name(struct _dirList *list, unsigned char idx) {
  return (char *) ( list->nameBuf + (idx * 32) );
}

variable_types: struct _dirList { char path[64]; char nameBuf[1024]; unsigned int num; } *

variable_types:
idx
unsigned char


decompiled_code:
bool __fastcall check_ext(const char *a1, const char *a2)
{
int v2; // edx
__int64 v3; // rax
const char *v4; // rdi
bool result; // al

v2 = strlen(a1);
v3 = (__int64)&a1[v2 - 1];
while ( v2 > 0 )
{
--v2;
v4 = (const char *)v3--;
if ( *(_BYTE *)(v3 + 1) == 46 )
goto LABEL_4;
}
result = 0;
if ( v2 >= 0 )
{
v4 = 0LL;
LABEL_4:
result = (unsigned __int8)strcmp(v4, a2) == 0;
}
return result;
}

canonical_decompiled_code:
bool __fastcall func1(const char *a1, const char *a2)
{
int v2; // edx
__int64 v3; // rax
const char *v4; // rdi
bool result; // al

v2 = strlen(a1);
v3 = (__int64)&a1[v2 - 1];
while ( v2 > 0 )
{
--v2;
v4 = (const char *)v3--;
if ( *(_BYTE *)(v3 + 1) == 46 )
goto LABEL_4;
}
result = 0;
if ( v2 >= 0 )
{
v4 = 0LL;
LABEL_4:
result = (unsigned __int8)strcmp(v4, a2) == 0;
}
return result;
}

original_code:
bool check_ext(char* str, const char* extB ) {
  int i;
  char* extA = ((void *)0);
  bool res;
  i = strlen(str);
  while(i > 0) {
    --i;
    if(str[i] == '.') {
      extA = str + i;
      break;
    }
  }
  if(i < 0) {
    return 0;
  } else {
    res = strcmp(extA, extB);
    if(res == 0) { return 1; } else { return 0; }
  }
}

canonical_original_code:
unsigned char check_ext(char *str, char *extB) {
  int i;
  char *extA = ((void *)0);
  unsigned char res;
  i = strlen(str);
  while(i > 0) {
    --i;
    if(str[i] == '.') {
      extA = str + i;
      break;
    }
  }
  if(i < 0) {
    return 0;
  } else {
    res = strcmp(extA, extB);
    if(res == 0) { return 1; } else { return 0; }
  }
}

variable_types:
str
char *

variable_types:
extB
char *

variable_types: i int

variable_types:
extA
char *

variable_types:
res
unsigned char

return_type: unsigned char


decompiled_code:
__int64 __fastcall strip_ext(const char *a1)
{
int v1; // eax
const char *v2; // rdx

v1 = strlen(a1);
v2 = &a1[v1 - 1];
while ( v1 > 0 )
{
--v1;
if ( *v2-- == 46 )
{
a1[v1] = 0;
return 1LL;
}
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(const char *a1)
{
int v1; // eax
const char *v2; // rdx

v1 = strlen(a1);
v2 = &a1[v1 - 1];
while ( v1 > 0 )
{
--v1;
if ( *v2-- == 46 )
{
a1[v1] = 0;
return 1LL;
}
}
return 0LL;
}

original_code:
bool strip_ext(char* str) {
  int i;
  int dotpos = -1;
  i = strlen(str);
  while(i > 0) {
    --i;
    if(str[i] == '.') {
      dotpos = i;
      break;
    }
  }
  if(dotpos >= 0) {
    str[dotpos] = '\0';
    return 1;
  } else {
    return 0;
  }
}

canonical_original_code:
unsigned char strip_ext(char *str) {
  int i;
  int dotpos = -1;
  i = strlen(str);
  while(i > 0) {
    --i;
    if(str[i] == '.') {
      dotpos = i;
      break;
    }
  }
  if(dotpos >= 0) {
    str[dotpos] = '\0';
    return 1;
  } else {
    return 0;
  }
}

variable_types: dotpos int


decompiled_code:
__int64 files_init()
{
return print_dbg("\r\n BEES file_init, scanning directories..");
}

canonical_decompiled_code:
__int64 func3()
{
return print_dbg("\r\n BEES file_init, scanning directories..");
}

original_code:
void files_init(void) {
  print_dbg("\r\n BEES file_init, scanning directories..");
  list_scan(&dspList, "/mod/");
  list_scan(&sceneList, "/data/bees/scenes/");
  list_scan(&scalerList, "/data/bees/scalers/");
}

canonical_original_code:
void files_init() {
  print_dbg("\r\n BEES file_init, scanning directories..");
  list_scan(&dspList, "/mod/");
  list_scan(&sceneList, "/data/bees/scenes/");
  list_scan(&scalerList, "/data/bees/scalers/");
}