decompiled_code:
void sios_core_exit()
{
sios_unload_modules_all();
sios_del_source_ctx(&main_src_ctx);
pthread_mutex_lock(&halt_lock);
halt = 1;
pthread_mutex_unlock(&halt_lock);
if ( use_syslog )
syslog(7, "Debug %s:%d in %s(): joining main reader thread", "core.c", 148LL, "sios_core_exit");
else
fprintf(stdout, "Debug %s:%d in %s(): joining main reader thread\n", "core.c", 148LL, "sios_core_exit");
pthread_join(main_reader_loop_thread, 0LL);
if ( use_syslog )
syslog(7, "Debug %s:%d in %s(): joining main reader thread done", "core.c", 150LL, "sios_core_exit");
else
fprintf(stdout, "Debug %s:%d in %s(): joining main reader thread done\n", "core.c", 150LL, "sios_core_exit");
if ( use_syslog )
syslog(7, "Debug %s:%d in %s(): joining main writer thread", "core.c", 152LL, "sios_core_exit");
else
fprintf(stdout, "Debug %s:%d in %s(): joining main writer thread\n", "core.c", 152LL, "sios_core_exit");
pthread_join(main_writer_loop_thread, 0LL);
if ( use_syslog )
syslog(7, "Debug %s:%d in %s(): joining main writer thread done", "core.c", 154LL, "sios_core_exit");
else
fprintf(stdout, "Debug %s:%d in %s(): joining main writer thread done\n", "core.c", 154LL, "sios_core_exit");
}

canonical_decompiled_code:
void func3()
{
sios_unload_modules_all();
sios_del_source_ctx(&main_src_ctx);
pthread_mutex_lock(&halt_lock);
halt = 1;
pthread_mutex_unlock(&halt_lock);
if ( use_syslog )
syslog(7, "Debug %s:%d in %s(): joining main reader thread", "core.c", 148LL, "sios_core_exit");
else
fprintf(stdout, "Debug %s:%d in %s(): joining main reader thread\n", "core.c", 148LL, "sios_core_exit");
pthread_join(main_reader_loop_thread, 0LL);
if ( use_syslog )
syslog(7, "Debug %s:%d in %s(): joining main reader thread done", "core.c", 150LL, "sios_core_exit");
else
fprintf(stdout, "Debug %s:%d in %s(): joining main reader thread done\n", "core.c", 150LL, "sios_core_exit");
if ( use_syslog )
syslog(7, "Debug %s:%d in %s(): joining main writer thread", "core.c", 152LL, "sios_core_exit");
else
fprintf(stdout, "Debug %s:%d in %s(): joining main writer thread\n", "core.c", 152LL, "sios_core_exit");
pthread_join(main_writer_loop_thread, 0LL);
if ( use_syslog )
syslog(7, "Debug %s:%d in %s(): joining main writer thread done", "core.c", 154LL, "sios_core_exit");
else
fprintf(stdout, "Debug %s:%d in %s(): joining main writer thread done\n", "core.c", 154LL, "sios_core_exit");
}

original_code:
void sios_core_exit()
{
 sios_unload_modules_all();
 sios_del_source_ctx(&main_src_ctx);
 pthread_mutex_lock(&halt_lock);
 halt = 1;
 pthread_mutex_unlock(&halt_lock);
 do { if (use_syslog) { syslog(7, "Debug %s:%d in %s(): " "joining main reader thread", "core.c", 148, __FUNCTION__); } else { fprintf(stdout, "Debug %s:%d in %s(): " "joining main reader thread" "\n", "core.c", 148, __FUNCTION__); } } while (0);
 pthread_join(main_reader_loop_thread, ((void *)0));
 do { if (use_syslog) { syslog(7, "Debug %s:%d in %s(): " "joining main reader thread done", "core.c", 150, __FUNCTION__); } else { fprintf(stdout, "Debug %s:%d in %s(): " "joining main reader thread done" "\n", "core.c", 150, __FUNCTION__); } } while (0);
 do { if (use_syslog) { syslog(7, "Debug %s:%d in %s(): " "joining main writer thread", "core.c", 152, __FUNCTION__); } else { fprintf(stdout, "Debug %s:%d in %s(): " "joining main writer thread" "\n", "core.c", 152, __FUNCTION__); } } while (0);
 pthread_join(main_writer_loop_thread, ((void *)0));
 do { if (use_syslog) { syslog(7, "Debug %s:%d in %s(): " "joining main writer thread done", "core.c", 154, __FUNCTION__); } else { fprintf(stdout, "Debug %s:%d in %s(): " "joining main writer thread done" "\n", "core.c", 154, __FUNCTION__); } } while (0);
}


repo: sdbakker/sio-platform

decompiled_code:
void __fastcall list_del(__int64 a1)
{
_list_del(*(_QWORD **)(a1 + 8), *(_QWORD *)a1);
*(_QWORD *)a1 = 0LL;
*(_QWORD *)(a1 + 8) = 0LL;
}

original_code:
static inline void list_del(struct list_head *entry)
{
 __list_del(entry->prev, entry->next);
 entry->next = ((void *)0);
 entry->prev = ((void *)0);
}

variable_types: struct list_head { struct list_head *next; } *

return_type: void


decompiled_code:
_QWORD *sios_alloc_module()
{
_QWORD *v0; // rax
_QWORD *v1; // rbx

v0 = malloc(0x90uLL);
v1 = v0;
if ( v0 )
{
INIT_LIST_HEAD(v0 + 5);
INIT_LIST_HEAD(v1 + 7);
}
return v1;
}

canonical_decompiled_code:
_QWORD *func6()
{
_QWORD *v0; // rax
_QWORD *v1; // rbx

v0 = malloc(0x90uLL);
v1 = v0;
if ( v0 )
{
func0(v0 + 5);
func0(v1 + 7);
}
return v1;
}

original_code:
struct sios_module * sios_alloc_module()
{
 struct sios_module * module;
 module = (struct sios_module*)malloc(sizeof(struct sios_module));
 if (!module)
  return ((void *)0);
 INIT_LIST_HEAD(&module->params);
 INIT_LIST_HEAD(&module->list);
 return module;
}

canonical_original_code:
struct sios_module *sios_alloc_module()
{
 struct sios_module *module;
 module = (struct sios_module *)malloc(sizeof(struct sios_module));
 if (!module)
  return ((void *)0);
 INIT_LIST_HEAD(&module->params);
 INIT_LIST_HEAD(&module->list);
 return module;
}

variable_types: struct sios_module { char *__xpg_basename; char *path; int lazy; char *lazy_id; void *dl_handle; struct list_head { struct list_head *next; } params; struct list_head list; char *module_name; char *module_descr; struct sios_class { char name[64]; char classpath[128]; struct list_head object_list; struct list_head class_head; } *class; struct sios_object { char name[64]; char path[128]; char *desc; char *id; int type; struct sios_class *class; struct list_head class_head; struct list_head object_head; struct list_head osc_methods; struct list_head osc_params; struct list_head listeners; } *obj; int (*init)(); void (*destroy)(); void (*set_name)(char *name); void (*set_descr)(char *descr); void (*set_class)(struct sios_class *class); } *

user_defined_types: struct sios_module { char *__xpg_basename; char *path; int lazy; char *lazy_id; void *dl_handle; struct list_head params; struct list_head list; char *module_name; char *module_descr; struct sios_class *class; struct sios_object *obj; int (*init)(); void (*destroy)(); void (*set_name)(char *name); void (*set_descr)(char *descr); void (*set_class)(struct sios_class *class); }


decompiled_code:
__int64 __fastcall sios_module_add_param(__int64 a1, __int64 a2)
{
if ( !a2 )
return 0xFFFFFFFFLL;
list_add((_QWORD *)(a2 + 16), (__int64 *)(a1 + 40));
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, __int64 a2)
{
if ( !a2 )
return 0xFFFFFFFFLL;
func2((_QWORD *)(a2 + 16), (__int64 *)(a1 + 40));
return 0LL;
}

original_code:
int sios_module_add_param(struct sios_module * module, struct sios_param_type * ptype)
{
 if (!ptype)
  return -1;
 list_add(&ptype->params, &module->params);
 return 0;
}

canonical_original_code:
int sios_module_add_param(struct sios_module *module, struct sios_param_type *ptype)
{
 if (!ptype)
  return -1;
 list_add(&ptype->params, &module->params);
 return 0;
}

variable_types: struct sios_param_type { char *name; char *val; struct list_head params; } *

return_type: int

user_defined_types: struct list_head { struct list_head *next; }

user_defined_types: struct sios_class { char name[64]; char classpath[128]; struct list_head object_list; struct list_head class_head; }

user_defined_types: struct sios_object { char name[64]; char path[128]; char *desc; char *id; int type; struct sios_class *class; struct list_head class_head; struct list_head object_head; struct list_head osc_methods; struct list_head osc_params; struct list_head listeners; }


decompiled_code:
__int64 __fastcall sios_load_module(const char **a1)
{
char *v1; // rax
__int64 (*v2)(void); // rax
unsigned int v3; // eax
const char **v4; // rax
const char *v5; // rax
char *v7; // rax
char *v8; // rax

v1 = (char *)dlopen(a1[1], 2);
a1[4] = v1;
if ( v1 )
{
v2 = (__int64 (*)(void))dlsym(v1, "__compiled_against_version");
if ( v2 )
{
v3 = v2();
if ( v3 == 131328 )
{
LABEL_7:
v4 = (const char **)dlsym((void *)a1[4], "__module_version_str");
if ( v4 )
{
if ( use_syslog )
syslog(6, "[%s] loading module '%s' version %s", "Module", *a1, *v4);
else
fprintf(stdout, "[%s] loading module '%s' version %s\n", "Module", *a1, *v4);
}
else if ( use_syslog )
{
syslog(6, "[%s] loading module '%s'", "Module", *a1);
}
else
{
fprintf(stdout, "[%s] loading module '%s'\n", "Module", *a1);
}
a1[13] = (const char *)dlsym((void *)a1[4], "__init_module");
a1[14] = (const char *)dlsym((void *)a1[4], "__exit_module");
a1[15] = (const char *)dlsym((void *)a1[4], "__set_module_name");
a1[16] = (const char *)dlsym((void *)a1[4], "__set_module_descr");
v5 = (const char *)dlsym((void *)a1[4], "__set_module_class");
a1[17] = v5;
if ( a1[13] && a1[14] && a1[15] && a1[16] && v5 )
return 0LL;
goto LABEL_22;
}
if ( !*(_BYTE *)(config + 16LL) )
{
if ( use_syslog )
syslog(
4,
"Warning: [%s] module version mismatch, %s has SIOS version %d, should be %d",
"Module",
a1[9],
v3,
131328LL);
else
fprintf(
stdout,
"Warning: [%s] module version mismatch, %s has SIOS version %d, should be %d\n",
"Module",
a1[9],
v3,
131328LL);
goto LABEL_7;
}
if ( use_syslog )
syslog(
3,
"Error: [%s] module version mismatch, %s has SIOS version %d, should be %d",
"Module",
a1[9],
v3,
131328LL);
else
fprintf(
stderr,
"Error: [%s] module version mismatch, %s has SIOS version %d, should be %d\n",
"Module",
a1[9],
v3,
131328LL);
}
LABEL_22:
dlclose((void *)a1[4]);
list_del((__int64)(a1 + 7));
return 0xFFFFFFFFLL;
}
if ( use_syslog )
{
v7 = dlerror();
syslog(3, "Error: [%s] dlopen() failed: %s", "Module", v7);
}
else
{
v8 = dlerror();
fprintf(stderr, "Error: [%s] dlopen() failed: %s\n", "Module", v8);
}
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func10(const char **a1)
{
char *v1; // rax
__int64 (*v2)(void); // rax
unsigned int v3; // eax
const char **v4; // rax
const char *v5; // rax
char *v7; // rax
char *v8; // rax

v1 = (char *)dlopen(a1[1], 2);
a1[4] = v1;
if ( v1 )
{
v2 = (__int64 (*)(void))dlsym(v1, "__compiled_against_version");
if ( v2 )
{
v3 = v2();
if ( v3 == 131328 )
{
LABEL_7:
v4 = (const char **)dlsym((void *)a1[4], "__module_version_str");
if ( v4 )
{
if ( use_syslog )
syslog(6, "[%s] loading module '%s' version %s", "Module", *a1, *v4);
else
fprintf(stdout, "[%s] loading module '%s' version %s\n", "Module", *a1, *v4);
}
else if ( use_syslog )
{
syslog(6, "[%s] loading module '%s'", "Module", *a1);
}
else
{
fprintf(stdout, "[%s] loading module '%s'\n", "Module", *a1);
}
a1[13] = (const char *)dlsym((void *)a1[4], "__init_module");
a1[14] = (const char *)dlsym((void *)a1[4], "__exit_module");
a1[15] = (const char *)dlsym((void *)a1[4], "__set_module_name");
a1[16] = (const char *)dlsym((void *)a1[4], "__set_module_descr");
v5 = (const char *)dlsym((void *)a1[4], "__set_module_class");
a1[17] = v5;
if ( a1[13] && a1[14] && a1[15] && a1[16] && v5 )
return 0LL;
goto LABEL_22;
}
if ( !*(_BYTE *)(config + 16LL) )
{
if ( use_syslog )
syslog(
4,
"Warning: [%s] module version mismatch, %s has SIOS version %d, should be %d",
"Module",
a1[9],
v3,
131328LL);
else
fprintf(
stdout,
"Warning: [%s] module version mismatch, %s has SIOS version %d, should be %d\n",
"Module",
a1[9],
v3,
131328LL);
goto LABEL_7;
}
if ( use_syslog )
syslog(
3,
"Error: [%s] module version mismatch, %s has SIOS version %d, should be %d",
"Module",
a1[9],
v3,
131328LL);
else
fprintf(
stderr,
"Error: [%s] module version mismatch, %s has SIOS version %d, should be %d\n",
"Module",
a1[9],
v3,
131328LL);
}
LABEL_22:
dlclose((void *)a1[4]);
func4((__int64)(a1 + 7));
return 0xFFFFFFFFLL;
}
if ( use_syslog )
{
v7 = dlerror();
syslog(3, "Error: [%s] dlopen() failed: %s", "Module", v7);
}
else
{
v8 = dlerror();
fprintf(stderr, "Error: [%s] dlopen() failed: %s\n", "Module", v8);
}
return 0xFFFFFFFFLL;
}

original_code:
int sios_load_module(struct sios_module * module)
{
 int retval = -1;
 unsigned int compiled_version;
 unsigned int (*get_version)(void);
 char ** version_str;
 module->dl_handle = dlopen(module->path, 0x00002);
 if (!module->dl_handle) {
  do { if (use_syslog) { syslog(3, "Error: [%s] " "dlopen() failed: %s","Module", dlerror()); } else { fprintf(stderr, "Error: [%s] " "dlopen() failed: %s" "\n","Module", dlerror()); } } while (0);
  goto out;
 }
 get_version = dlsym(module->dl_handle, "__compiled_against_version");
 if (!get_version)
  goto out_close_handle;
 compiled_version = get_version();
 if (compiled_version != (((2) << 16) + ((1) << 8) + (0))) {
  if (config->strict_versioning) {
   do { if (use_syslog) { syslog(3, "Error: [%s] " "module version mismatch, %s has SIOS version %d, should be %d","Module", module->module_name, compiled_version, (((2) << 16) + ((1) << 8) + (0))); } else { fprintf(stderr, "Error: [%s] " "module version mismatch, %s has SIOS version %d, should be %d" "\n","Module", module->module_name, compiled_version, (((2) << 16) + ((1) << 8) + (0))); } } while (0);
   goto out_close_handle;
  } else {
   do { if (use_syslog) { syslog(4, "Warning: [%s] " "module version mismatch, %s has SIOS version %d, should be %d","Module", module->module_name, compiled_version, (((2) << 16) + ((1) << 8) + (0))); } else { fprintf(stdout, "Warning: [%s] " "module version mismatch, %s has SIOS version %d, should be %d" "\n","Module", module->module_name, compiled_version, (((2) << 16) + ((1) << 8) + (0))); } } while (0);
  }
 }
 version_str = dlsym(module->dl_handle, "__module_version_str");
 if (version_str)
  do { if (use_syslog) { syslog(6, "[%s] " "loading module '%s' version %s","Module", module->__xpg_basename, *version_str); } else { fprintf(stdout, "[%s] " "loading module '%s' version %s" "\n","Module", module->__xpg_basename, *version_str); } } while (0);
 else
  do { if (use_syslog) { syslog(6, "[%s] " "loading module '%s'","Module", module->__xpg_basename); } else { fprintf(stdout, "[%s] " "loading module '%s'" "\n","Module", module->__xpg_basename); } } while (0);
 module->init = dlsym(module->dl_handle, "__init_module");
 module->destroy = dlsym(module->dl_handle, "__exit_module");
 module->set_name = dlsym(module->dl_handle, "__set_module_name");
 module->set_descr = dlsym(module->dl_handle, "__set_module_descr");
 module->set_class = dlsym(module->dl_handle, "__set_module_class");
 if (!module->init || !module->destroy || !module->set_name
   || !module->set_descr || !module->set_class)
  goto out_close_handle;
 return 0;
out_close_handle:
 dlclose(module->dl_handle);
 list_del(&module->list);
out:
 return retval;
}

canonical_original_code:
int sios_load_module(struct sios_module *module)
{
 int retval = -1;
 unsigned int compiled_version;
 unsigned int (*get_version)();
 char **version_str;
 module->dl_handle = dlopen(module->path, 0x00002);
 if (!module->dl_handle) {
  do { if (use_syslog) { syslog(3, "Error: [%s] " "dlopen() failed: %s","Module", dlerror()); } else { fprintf(stderr, "Error: [%s] " "dlopen() failed: %s" "\n","Module", dlerror()); } } while (0);
  goto out;
 }
 get_version = dlsym(module->dl_handle, "__compiled_against_version");
 if (!get_version)
  goto out_close_handle;
 compiled_version = get_version();
 if (compiled_version != (((2) << 16) + ((1) << 8) + (0))) {
  if (config->strict_versioning) {
   do { if (use_syslog) { syslog(3, "Error: [%s] " "module version mismatch, %s has SIOS version %d, should be %d","Module", module->module_name, compiled_version, (((2) << 16) + ((1) << 8) + (0))); } else { fprintf(stderr, "Error: [%s] " "module version mismatch, %s has SIOS version %d, should be %d" "\n","Module", module->module_name, compiled_version, (((2) << 16) + ((1) << 8) + (0))); } } while (0);
   goto out_close_handle;
  } else {
   do { if (use_syslog) { syslog(4, "Warning: [%s] " "module version mismatch, %s has SIOS version %d, should be %d","Module", module->module_name, compiled_version, (((2) << 16) + ((1) << 8) + (0))); } else { fprintf(stdout, "Warning: [%s] " "module version mismatch, %s has SIOS version %d, should be %d" "\n","Module", module->module_name, compiled_version, (((2) << 16) + ((1) << 8) + (0))); } } while (0);
  }
 }
 version_str = dlsym(module->dl_handle, "__module_version_str");
 if (version_str)
  do { if (use_syslog) { syslog(6, "[%s] " "loading module '%s' version %s","Module", module->__xpg_basename, *version_str); } else { fprintf(stdout, "[%s] " "loading module '%s' version %s" "\n","Module", module->__xpg_basename, *version_str); } } while (0);
 else
  do { if (use_syslog) { syslog(6, "[%s] " "loading module '%s'","Module", module->__xpg_basename); } else { fprintf(stdout, "[%s] " "loading module '%s'" "\n","Module", module->__xpg_basename); } } while (0);
 module->init = dlsym(module->dl_handle, "__init_module");
 module->destroy = dlsym(module->dl_handle, "__exit_module");
 module->set_name = dlsym(module->dl_handle, "__set_module_name");
 module->set_descr = dlsym(module->dl_handle, "__set_module_descr");
 module->set_class = dlsym(module->dl_handle, "__set_module_class");
 if (!module->init || !module->destroy || !module->set_name
   || !module->set_descr || !module->set_class)
  goto out_close_handle;
 return 0;
out_close_handle:
 dlclose(module->dl_handle);
 list_del(&module->list);
out:
 return retval;
}

variable_types: retval int


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

if ( !a1 )
return (unsigned int)-1;
(*(void (__fastcall **)(_QWORD))(a1 + 120))(*(_QWORD *)(a1 + 72));
(*(void (__fastcall **)(_QWORD))(a1 + 128))(*(_QWORD *)(a1 + 80));
(*(void (__fastcall **)(_QWORD))(a1 + 136))(*(_QWORD *)(a1 + 88));
if ( (unsigned int)module_set_params(a1) )
{
if ( use_syslog )
syslog(3, "Error: [%s] Error setting parameters '%s'", "Module", *(const char **)(a1 + 72));
else
fprintf(stderr, "Error: [%s] Error setting parameters '%s'\n", "Module", *(const char **)(a1 + 72));
v2 = -1;
}
else
{
v2 = (*(__int64 (**)(void))(a1 + 104))();
if ( v2 )
{
if ( use_syslog )
syslog(3, "Error: [%s] Error initializing '%s'", "Module", *(const char **)(a1 + 72));
else
fprintf(stderr, "Error: [%s] Error initializing '%s'\n", "Module", *(const char **)(a1 + 72));
}
else
{
v3 = dlsym(*(void **)(a1 + 32), "__this_object");
if ( v3 )
{
*(_QWORD *)(a1 + 96) = v3;
}
else
{
if ( use_syslog )
syslog(3, "Error: [%s] Error getting object '%s'", "Module", *(const char **)(a1 + 72));
else
fprintf(stderr, "Error: [%s] Error getting object '%s'\n", "Module", *(const char **)(a1 + 72));
v2 = -1;
}
}
}
return v2;
}

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

if ( !a1 )
return (unsigned int)-1;
(*(void (__fastcall **)(_QWORD))(a1 + 120))(*(_QWORD *)(a1 + 72));
(*(void (__fastcall **)(_QWORD))(a1 + 128))(*(_QWORD *)(a1 + 80));
(*(void (__fastcall **)(_QWORD))(a1 + 136))(*(_QWORD *)(a1 + 88));
if ( (unsigned int)func5(a1) )
{
if ( use_syslog )
syslog(3, "Error: [%s] Error setting parameters '%s'", "Module", *(const char **)(a1 + 72));
else
fprintf(stderr, "Error: [%s] Error setting parameters '%s'\n", "Module", *(const char **)(a1 + 72));
v2 = -1;
}
else
{
v2 = (*(__int64 (**)(void))(a1 + 104))();
if ( v2 )
{
if ( use_syslog )
syslog(3, "Error: [%s] Error initializing '%s'", "Module", *(const char **)(a1 + 72));
else
fprintf(stderr, "Error: [%s] Error initializing '%s'\n", "Module", *(const char **)(a1 + 72));
}
else
{
v3 = dlsym(*(void **)(a1 + 32), "__this_object");
if ( v3 )
{
*(_QWORD *)(a1 + 96) = v3;
}
else
{
if ( use_syslog )
syslog(3, "Error: [%s] Error getting object '%s'", "Module", *(const char **)(a1 + 72));
else
fprintf(stderr, "Error: [%s] Error getting object '%s'\n", "Module", *(const char **)(a1 + 72));
v2 = -1;
}
}
}
return v2;
}

original_code:
int sios_init_module(struct sios_module * module)
{
 int retval;
 struct sios_object * obj;
 if (!module)
  return -1;
 module->set_name(module->module_name);
 module->set_descr(module->module_descr);
 module->set_class(module->class);
 if (module_set_params(module)) {
  do { if (use_syslog) { syslog(3, "Error: [%s] " "Error setting parameters '%s'","Module", module->module_name); } else { fprintf(stderr, "Error: [%s] " "Error setting parameters '%s'" "\n","Module", module->module_name); } } while (0);
  return -1;
 }
 retval = module->init();
 if (retval) {
  do { if (use_syslog) { syslog(3, "Error: [%s] " "Error initializing '%s'","Module", module->module_name); } else { fprintf(stderr, "Error: [%s] " "Error initializing '%s'" "\n","Module", module->module_name); } } while (0);
  return retval;
 }
 obj = dlsym(module->dl_handle, "__this_object");
 if (!obj) {
  do { if (use_syslog) { syslog(3, "Error: [%s] " "Error getting object '%s'","Module", module->module_name); } else { fprintf(stderr, "Error: [%s] " "Error getting object '%s'" "\n","Module", module->module_name); } } while (0);
  return -1;
 }
 module->obj = obj;
 return 0;
}

canonical_original_code:
int sios_init_module(struct sios_module *module)
{
 int retval;
 struct sios_object *obj;
 if (!module)
  return -1;
 module->set_name(module->module_name);
 module->set_descr(module->module_descr);
 module->set_class(module->class);
 if (module_set_params(module)) {
  do { if (use_syslog) { syslog(3, "Error: [%s] " "Error setting parameters '%s'","Module", module->module_name); } else { fprintf(stderr, "Error: [%s] " "Error setting parameters '%s'" "\n","Module", module->module_name); } } while (0);
  return -1;
 }
 retval = module->init();
 if (retval) {
  do { if (use_syslog) { syslog(3, "Error: [%s] " "Error initializing '%s'","Module", module->module_name); } else { fprintf(stderr, "Error: [%s] " "Error initializing '%s'" "\n","Module", module->module_name); } } while (0);
  return retval;
 }
 obj = dlsym(module->dl_handle, "__this_object");
 if (!obj) {
  do { if (use_syslog) { syslog(3, "Error: [%s] " "Error getting object '%s'","Module", module->module_name); } else { fprintf(stderr, "Error: [%s] " "Error getting object '%s'" "\n","Module", module->module_name); } } while (0);
  return -1;
 }
 module->obj = obj;
 return 0;
}

variable_types: struct sios_object { char name[64]; char path[128]; char *desc; char *id; int type; struct sios_class { char name[64]; char classpath[128]; struct list_head { struct list_head *next; } object_list; struct list_head class_head; } *class; struct list_head class_head; struct list_head object_head; struct list_head osc_methods; struct list_head osc_params; struct list_head listeners; } *


decompiled_code:
void __fastcall sios_unload_module(__int64 a1, int a2)
{
if ( a2 )
(*(void (**)(void))(a1 + 112))();
dlclose(*(void **)(a1 + 32));
list_del(a1 + 56);
}

original_code:
void sios_unload_module(struct sios_module * module, int call_module_destroy)
{
 if (call_module_destroy)
  module->destroy();
 dlclose(module->dl_handle);
 list_del(&module->list);
}

canonical_original_code:
void sios_unload_module(struct sios_module *module, int call_module_destroy)
{
 if (call_module_destroy)
  module->destroy();
 dlclose(module->dl_handle);
 list_del(&module->list);
}


decompiled_code:
__int64 sios_dump_modules()
{
return sios_modules_dump_xml(&module_list);
}

canonical_decompiled_code:
__int64 func15()
{
return sios_modules_dump_xml(&module_list);
}

original_code:
void sios_dump_modules(void)
{
 sios_modules_dump_xml(&module_list);
}

canonical_original_code:
void sios_dump_modules()
{
 sios_modules_dump_xml(&module_list);
}


decompiled_code:
void __fastcall free_ifi_info(void *ptr)
{
_QWORD *v1; // rbx
_QWORD *v2; // rbp
void *v3; // rdi
void *v4; // rdi
void *v5; // rdi

v1 = ptr;
if ( ptr )
{
while ( 1 )
{
v3 = (void *)v1[5];
if ( v3 )
free(v3);
v4 = (void *)v1[6];
if ( v4 )
free(v4);
v5 = (void *)v1[7];
if ( v5 )
free(v5);
v2 = (_QWORD *)v1[8];
free(v1);
if ( !v2 )
break;
v1 = v2;
}
}
}

canonical_decompiled_code:
void __fastcall func0(void *ptr)
{
_QWORD *v1; // rbx
_QWORD *v2; // rbp
void *v3; // rdi
void *v4; // rdi
void *v5; // rdi

v1 = ptr;
if ( ptr )
{
while ( 1 )
{
v3 = (void *)v1[5];
if ( v3 )
free(v3);
v4 = (void *)v1[6];
if ( v4 )
free(v4);
v5 = (void *)v1[7];
if ( v5 )
free(v5);
v2 = (_QWORD *)v1[8];
free(v1);
if ( !v2 )
break;
v1 = v2;
}
}
}

original_code:
void
free_ifi_info(struct ifi_info *ifihead)
{
    struct ifi_info *ifi, *ifinext;
    for (ifi = ifihead; ifi != ((void *)0); ifi = ifinext) {
        if (ifi->ifi_addr != ((void *)0))
            free(ifi->ifi_addr);
        if (ifi->ifi_brdaddr != ((void *)0))
            free(ifi->ifi_brdaddr);
        if (ifi->ifi_dstaddr != ((void *)0))
            free(ifi->ifi_dstaddr);
        ifinext = ifi->ifi_next;
        free(ifi);
    }
}

canonical_original_code:
void free_ifi_info(struct ifi_info *ifihead)
{
    struct ifi_info *ifi; struct ifi_info *ifinext;
    for (ifi = ifihead; ifi != ((void *)0); ifi = ifinext) {
        if (ifi->ifi_addr != ((void *)0))
            free(ifi->ifi_addr);
        if (ifi->ifi_brdaddr != ((void *)0))
            free(ifi->ifi_brdaddr);
        if (ifi->ifi_dstaddr != ((void *)0))
            free(ifi->ifi_dstaddr);
        ifinext = ifi->ifi_next;
        free(ifi);
    }
}

variable_types: struct ifi_info { char ifi_name[16]; unsigned char ifi_haddr[8]; unsigned short ifi_hlen; short ifi_flags; short ifi_myflags; int ifi_index; struct sockaddr { unsigned short sa_family; char sa_data[14]; } *ifi_addr; struct sockaddr *ifi_brdaddr; struct sockaddr *ifi_dstaddr; struct ifi_info *ifi_next; } *

user_defined_types: struct ifi_info { char ifi_name[16]; unsigned char ifi_haddr[8]; unsigned short ifi_hlen; short ifi_flags; short ifi_myflags; int ifi_index; struct sockaddr *ifi_addr; struct sockaddr *ifi_brdaddr; struct sockaddr *ifi_dstaddr; struct ifi_info *ifi_next; }


original_code:
struct ifi_info *get_ifi_info(int family, int doaliases)
{
    int junk;
    struct ifi_info *ifi, *ifihead, **ifipnext;
    int sockfd, len, lastlen, flags, myflags;
    char *ptr, *buf, lastname[16], *cptr;
    struct ifconf ifc;
    struct ifreq *ifr, ifrcopy;
    struct sockaddr_in *sinptr;
    sockfd = -1;
    buf = ((void *)0);
    ifihead = ((void *)0);
    sockfd = socket(2, SOCK_DGRAM, 0);
    if (sockfd < 0) {
        goto gotError;
    }
    lastlen = 0;
    len = 100 * sizeof(struct ifreq);
    for ( ; ; ) {
        buf = malloc(len);
        if (buf == ((void *)0)) {
            goto gotError;
        }
        ifc.ifc_len = len;
        ifc.ifc_ifcu.ifcu_buf = buf;
        if (ioctl(sockfd, 0x8912, &ifc) < 0) {
            if ((*__errno_location ()) != 22 || lastlen != 0) {
                goto gotError;
            }
        } else {
            if (ifc.ifc_len == lastlen)
                break;
            lastlen = ifc.ifc_len;
        }
        len += 10 * sizeof(struct ifreq);
        free(buf);
    }
    ifihead = ((void *)0);
    ifipnext = &ifihead;
    lastname[0] = 0;
    for (ptr = buf; ptr < buf + ifc.ifc_len; ) {
        ifr = (struct ifreq *) ptr;
  len = ((ifr->ifr_ifru.ifru_addr).sa_family == 2 ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr));
        ptr += sizeof(ifr->ifr_ifrn.ifrn_name) + len;
        if (ifr->ifr_ifru.ifru_addr.sa_family != family)
            continue;
        myflags = 0;
        if ( (cptr = strchr(ifr->ifr_ifrn.ifrn_name, ':')) != ((void *)0))
            *cptr = 0;
        if (strncmp(lastname, ifr->ifr_ifrn.ifrn_name, 16) == 0) {
            if (doaliases == 0)
                continue;
            myflags = 1;
        }
        memcpy(lastname, ifr->ifr_ifrn.ifrn_name, 16);
        ifrcopy = *ifr;
        if (ioctl(sockfd, 0x8913, &ifrcopy) < 0) {
            goto gotError;
        }
        flags = ifrcopy.ifr_ifru.ifru_flags;
        if ((flags & IFF_UP) == 0)
            continue;
        ifi = calloc(1, sizeof(struct ifi_info));
        if (ifi == ((void *)0)) {
            goto gotError;
        }
        *ifipnext = ifi;
        ifipnext = &ifi->ifi_next;
        ifi->ifi_flags = flags;
        ifi->ifi_myflags = myflags;
        ifi->ifi_index = if_nametoindex(ifr->ifr_ifrn.ifrn_name);
        memcpy(ifi->ifi_name, ifr->ifr_ifrn.ifrn_name, 16);
        ifi->ifi_name[16 -1] = '\0';
        switch (ifr->ifr_ifru.ifru_addr.sa_family) {
        case 2:
            sinptr = (struct sockaddr_in *) &ifr->ifr_ifru.ifru_addr;
            if (ifi->ifi_addr == ((void *)0)) {
                ifi->ifi_addr = calloc(1, sizeof(struct sockaddr_in));
                if (ifi->ifi_addr == ((void *)0)) {
                    goto gotError;
                }
                memcpy(ifi->ifi_addr, sinptr, sizeof(struct sockaddr_in));
                if (flags & IFF_BROADCAST) {
                    if (ioctl(sockfd, 0x8919, &ifrcopy) < 0) {
                        goto gotError;
                    }
                    sinptr = (struct sockaddr_in *) &ifrcopy.ifr_ifru.ifru_broadaddr;
                    ifi->ifi_brdaddr = calloc(1, sizeof(struct sockaddr_in));
                    if (ifi->ifi_brdaddr == ((void *)0)) {
                        goto gotError;
                    }
                    memcpy(ifi->ifi_brdaddr, sinptr, sizeof(struct sockaddr_in));
                }
                if (flags & IFF_POINTOPOINT) {
                    if (ioctl(sockfd, 0x8917, &ifrcopy) < 0) {
                        goto gotError;
                    }
                    sinptr = (struct sockaddr_in *) &ifrcopy.ifr_ifru.ifru_dstaddr;
                    ifi->ifi_dstaddr = calloc(1, sizeof(struct sockaddr_in));
                    if (ifi->ifi_dstaddr == ((void *)0)) {
                        goto gotError;
                    }
                    memcpy(ifi->ifi_dstaddr, sinptr, sizeof(struct sockaddr_in));
                }
            }
            break;
        default:
            break;
        }
    }
    goto done;
gotError:
    if (ifihead != ((void *)0)) {
        free_ifi_info(ifihead);
        ifihead = ((void *)0);
    }
done:
    if (buf != ((void *)0)) {
        free(buf);
    }
    if (sockfd != -1) {
        junk = close(sockfd);
        ((void) sizeof ((junk == 0) ? 1 : 0), __extension__ ({ if (junk == 0) ; else __assert_fail ("junk == 0", "mDNS/mDNSUNP.c", 274, __extension__ __PRETTY_FUNCTION__); }));
    }
    return(ifihead);
}

canonical_original_code:
struct ifi_info *get_ifi_info(int family, int doaliases)
{
    int junk;
    struct ifi_info *ifi; struct ifi_info *ifihead; struct ifi_info **ifipnext;
    int sockfd; int len; int lastlen; int flags; int myflags;
    char *ptr; char *buf; char lastname[16]; char *cptr;
    struct ifconf ifc;
    struct ifreq *ifr; struct ifreq ifrcopy;
    struct sockaddr_in *sinptr;
    sockfd = -1;
    buf = ((void *)0);
    ifihead = ((void *)0);
    sockfd = socket(2, SOCK_DGRAM, 0);
    if (sockfd < 0) {
        goto gotError;
    }
    lastlen = 0;
    len = 100 * sizeof(struct ifreq);
    for ( ; ; ) {
        buf = malloc(len);
        if (buf == ((void *)0)) {
            goto gotError;
        }
        ifc.ifc_len = len;
        ifc.ifc_ifcu.ifcu_buf = buf;
        if (ioctl(sockfd, 0x8912, &ifc) < 0) {
            if ((*__errno_location ()) != 22 || lastlen != 0) {
                goto gotError;
            }
        } else {
            if (ifc.ifc_len == lastlen)
                break;
            lastlen = ifc.ifc_len;
        }
        len += 10 * sizeof(struct ifreq);
        free(buf);
    }
    ifihead = ((void *)0);
    ifipnext = &ifihead;
    lastname[0] = 0;
    for (ptr = buf; ptr < buf + ifc.ifc_len; ) {
        ifr = (struct ifreq *) ptr;
  len = ((ifr->ifr_ifru.ifru_addr).sa_family == 2 ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr));
        ptr += sizeof(ifr->ifr_ifrn.ifrn_name) + len;
        if (ifr->ifr_ifru.ifru_addr.sa_family != family)
            continue;
        myflags = 0;
        if ( (cptr = strchr(ifr->ifr_ifrn.ifrn_name, ':')) != ((void *)0))
            *cptr = 0;
        if (strncmp(lastname, ifr->ifr_ifrn.ifrn_name, 16) == 0) {
            if (doaliases == 0)
                continue;
            myflags = 1;
        }
        memcpy(lastname, ifr->ifr_ifrn.ifrn_name, 16);
        ifrcopy = *ifr;
        if (ioctl(sockfd, 0x8913, &ifrcopy) < 0) {
            goto gotError;
        }
        flags = ifrcopy.ifr_ifru.ifru_flags;
        if ((flags & IFF_UP) == 0)
            continue;
        ifi = calloc(1, sizeof(struct ifi_info));
        if (ifi == ((void *)0)) {
            goto gotError;
        }
        *ifipnext = ifi;
        ifipnext = &ifi->ifi_next;
        ifi->ifi_flags = flags;
        ifi->ifi_myflags = myflags;
        ifi->ifi_index = if_nametoindex(ifr->ifr_ifrn.ifrn_name);
        memcpy(ifi->ifi_name, ifr->ifr_ifrn.ifrn_name, 16);
        ifi->ifi_name[16 -1] = '\0';
        switch (ifr->ifr_ifru.ifru_addr.sa_family) {
        case 2:
            sinptr = (struct sockaddr_in *) &ifr->ifr_ifru.ifru_addr;
            if (ifi->ifi_addr == ((void *)0)) {
                ifi->ifi_addr = calloc(1, sizeof(struct sockaddr_in));
                if (ifi->ifi_addr == ((void *)0)) {
                    goto gotError;
                }
                memcpy(ifi->ifi_addr, sinptr, sizeof(struct sockaddr_in));
                if (flags & IFF_BROADCAST) {
                    if (ioctl(sockfd, 0x8919, &ifrcopy) < 0) {
                        goto gotError;
                    }
                    sinptr = (struct sockaddr_in *) &ifrcopy.ifr_ifru.ifru_broadaddr;
                    ifi->ifi_brdaddr = calloc(1, sizeof(struct sockaddr_in));
                    if (ifi->ifi_brdaddr == ((void *)0)) {
                        goto gotError;
                    }
                    memcpy(ifi->ifi_brdaddr, sinptr, sizeof(struct sockaddr_in));
                }
                if (flags & IFF_POINTOPOINT) {
                    if (ioctl(sockfd, 0x8917, &ifrcopy) < 0) {
                        goto gotError;
                    }
                    sinptr = (struct sockaddr_in *) &ifrcopy.ifr_ifru.ifru_dstaddr;
                    ifi->ifi_dstaddr = calloc(1, sizeof(struct sockaddr_in));
                    if (ifi->ifi_dstaddr == ((void *)0)) {
                        goto gotError;
                    }
                    memcpy(ifi->ifi_dstaddr, sinptr, sizeof(struct sockaddr_in));
                }
            }
            break;
        default:
            break;
        }
    }
    goto done;
gotError:
    if (ifihead != ((void *)0)) {
        free_ifi_info(ifihead);
        ifihead = ((void *)0);
    }
done:
    if (buf != ((void *)0)) {
        free(buf);
    }
    if (sockfd != -1) {
        junk = close(sockfd);
        ((void) sizeof ((junk == 0) ? 1 : 0), __extension__ ({ if (junk == 0) ; else __assert_fail ("junk == 0", "mDNS/mDNSUNP.c", 274, __extension__ __PRETTY_FUNCTION__); }));
    }
    return(ifihead);
}

variable_types: family int

variable_types: doaliases int

variable_types: junk int

variable_types: struct ifi_info { char ifi_name[16]; unsigned char ifi_haddr[8]; unsigned short ifi_hlen; short ifi_flags; short ifi_myflags; int ifi_index; struct sockaddr { unsigned short sa_family; char sa_data[14]; } *ifi_addr; struct sockaddr *ifi_brdaddr; struct sockaddr *ifi_dstaddr; struct ifi_info *ifi_next; } **

variable_types: sockfd int

variable_types: len int

variable_types: lastlen int

variable_types: flags int

variable_types: myflags int

variable_types:
ptr
char *

variable_types:
buf
char *

variable_types:
lastname
char [16]

variable_types:
cptr
char *

variable_types: struct ifconf { int ifc_len; union { char *ifcu_buf; struct ifreq { union { char ifrn_name[16]; } ifr_ifrn; union { struct sockaddr { unsigned short sa_family; char sa_data[14]; } ifru_addr; struct sockaddr ifru_dstaddr; struct sockaddr ifru_broadaddr; struct sockaddr ifru_netmask; struct sockaddr ifru_hwaddr; short ifru_flags; int ifru_ivalue; int ifru_mtu; struct ifmap { unsigned long mem_start; unsigned long mem_end; unsigned short base_addr; unsigned char irq; unsigned char dma; unsigned char port; } ifru_map; char ifru_slave[16]; char ifru_newname[16]; char *ifru_data; } ifr_ifru; } *ifcu_req; } ifc_ifcu; }

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

user_defined_types: struct ifconf { int ifc_len; union { char *ifcu_buf; struct ifreq *ifcu_req; } ifc_ifcu; }

user_defined_types: struct ifreq { union { char ifrn_name[16]; } ifr_ifrn; union { struct sockaddr ifru_addr; struct sockaddr ifru_dstaddr; struct sockaddr ifru_broadaddr; struct sockaddr ifru_netmask; struct sockaddr ifru_hwaddr; short ifru_flags; int ifru_ivalue; int ifru_mtu; struct ifmap ifru_map; char ifru_slave[16]; char ifru_newname[16]; char *ifru_data; } ifr_ifru; }

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


canonical_original_code:
static inline void list_del(struct list_head *entry)
{
 __list_del(entry->prev, entry->next);
 entry->next = ((void *)0);
 entry->prev = ((void *)0);
}

variable_types: struct list_head { struct list_head *next; } *


decompiled_code:
_QWORD *config_add_module()
{
__int64 v0; // rax
_QWORD *v1; // rbx
__int64 v2; // rbp
_QWORD *v3; // rax
_QWORD *v4; // r12

v0 = sios_alloc_module();
v1 = (_QWORD *)v0;
if ( v0 )
{
v2 = v0;
v3 = malloc(0x20uLL);
v1 = v3;
if ( v3 )
{
v4 = v3 + 2;
INIT_LIST_HEAD(v3 + 2);
*v1 = v2;
list_add(v4, (__int64 *)(config + 56));
}
else
{
sios_destroy_module(v2);
}
}
return v1;
}

canonical_decompiled_code:
_QWORD *func6()
{
__int64 v0; // rax
_QWORD *v1; // rbx
__int64 v2; // rbp
_QWORD *v3; // rax
_QWORD *v4; // r12

v0 = sios_alloc_module();
v1 = (_QWORD *)v0;
if ( v0 )
{
v2 = v0;
v3 = malloc(0x20uLL);
v1 = v3;
if ( v3 )
{
v4 = v3 + 2;
func0(v3 + 2);
*v1 = v2;
func2(v4, (__int64 *)(config + 56));
}
else
{
sios_destroy_module(v2);
}
}
return v1;
}

original_code:
static struct module_entry * config_add_module()
{
 struct sios_module * module = sios_alloc_module();
 if (module) {
  struct module_entry * entry =
   (struct module_entry*)malloc(sizeof(struct module_entry));
  if (!entry) {
   sios_destroy_module(module);
   return ((void *)0);
  }
  INIT_LIST_HEAD(&entry->entry);
  entry->module = module;
  list_add(&entry->entry, &config->module_entries);
  return entry;
 }
 return ((void *)0);
}

canonical_original_code:
static struct module_entry *config_add_module()
{
 struct sios_module *module = sios_alloc_module();
 if (module) {
  struct module_entry *entry = (struct module_entry*)malloc(sizeof(struct module_entry));
  if (!entry) {
   sios_destroy_module(module);
   return ((void *)0);
  }
  INIT_LIST_HEAD(&entry->entry);
  entry->module = module;
  list_add(&entry->entry, &config->module_entries);
  return entry;
 }
 return ((void *)0);
}

variable_types: struct module_entry { struct sios_module { char *basename; char *path; int lazy; char *lazy_id; void *dl_handle; struct list_head { struct list_head *next; } params; struct list_head list; char *module_name; char *module_descr; struct sios_class { char name[64]; char classpath[128]; struct list_head object_list; struct list_head class_head; } *class; struct sios_object { char name[64]; char path[128]; char *desc; char *id; int type; struct sios_class *class; struct list_head class_head; struct list_head object_head; struct list_head osc_methods; struct list_head osc_params; struct list_head listeners; } *obj; int (*init)(); void (*destroy)(); void (*set_name)(char *name); void (*set_descr)(char *descr); void (*set_class)(struct sios_class *class); } *module; char *class; struct list_head entry; } *

user_defined_types: struct sios_module { char *basename; char *path; int lazy; char *lazy_id; void *dl_handle; struct list_head params; struct list_head list; char *module_name; char *module_descr; struct sios_class *class; struct sios_object *obj; int (*init)(); void (*destroy)(); void (*set_name)(char *name); void (*set_descr)(char *descr); void (*set_class)(struct sios_class *class); }

user_defined_types: struct module_entry { struct sios_module *module; char *class; struct list_head entry; }


yyparse

decompiled_code:
__int64 yyparse()
{
int v0; // ebp
unsigned __int64 v1; // r14
char *v2; // r12
__int16 *v3; // rbx
__int16 *v4; // r13
int v5; // edx
unsigned int v6; // er15
int v7; // er15
__int16 *v8; // rdx
__int16 *v9; // rax
unsigned int v10; // ebp
unsigned __int8 v11; // bp
int v12; // eax
unsigned int v13; // ecx
unsigned __int64 v14; // rax
signed __int64 v15; // r12
__int16 *v16; // rax
__int16 *v17; // r15
int v18; // er15
__int64 v19; // rdi
__int64 v20; // rdi
char **v21; // rdi
__int64 v22; // rdi
__int64 v23; // rdi
__int64 v24; // rdi
__int64 v25; // rdi
int v26; // eax
unsigned int v27; // eax
char *v29; // [rsp+8h] [rbp-830h]
int v30; // [rsp+14h] [rbp-824h]
const char *v31; // [rsp+18h] [rbp-820h]
__int64 v32; // [rsp+18h] [rbp-820h]
char *v33; // [rsp+28h] [rbp-810h]
char v34[1600]; // [rsp+30h] [rbp-808h] BYREF
__int16 src[228]; // [rsp+670h] [rbp-1C8h] BYREF

yynerrs = 0;
yychar = -2;
src[0] = 0;
v30 = 0;
v0 = 0;
v1 = 200LL;
v2 = v34;
v29 = v34;
v3 = src;
v4 = src;
while ( 1 )
{
v18 = yypact[v0];
if ( v18 == -27 )
break;
if ( yychar == -2 )
yychar = yylex();
if ( yychar <= 0 )
{
yychar = 0;
v5 = 0;
}
else
{
v5 = 2;
if ( (unsigned int)yychar <= 0x11B )
v5 = (unsigned __int8)yytranslate[yychar];
}
v6 = v5 + v18;
if ( v6 > 0x3B || yycheck[v6] != v5 )
break;
v0 = yytable[v6];
v7 = -v0;
if ( v0 > 0 )
{
v30 = (v30 == 0) + v30 - 1;
yychar = -2;
*((_QWORD *)v2 + 1) = yylval;
v2 += 8;
v8 = v3;
goto LABEL_18;
}
LABEL_13:
v11 = yyr2[v7];
v31 = *(const char **)&v2[8 * (1 - v11)];
switch ( v7 )
{
case 5:
config_add_class();
break;
case 6:
*(_BYTE *)(config + 16) = *v2;
break;
case 7:
use_syslog = 1;
break;
case 8:
*(_BYTE *)(config + 17) = *v2;
break;
case 9:
v19 = config;
*(_QWORD *)(v19 + 24) = strdup(*(const char **)v2);
break;
case 10:
v20 = config;
*(_QWORD *)(v20 + 32) = strdup(*(const char **)v2);
break;
case 13:
case 21:
v31 = 0LL;
break;
case 14:
v31 = (const char *)config;
break;
case 17:
*(_DWORD *)(config + 8) = *(_QWORD *)v2;
break;
case 18:
v21 = (char **)config;
*v21 = strdup(*(const char **)v2);
break;
case 19:
*(_BYTE *)(config + 12) = *v2;
break;
case 20:
*(_BYTE *)(config + 13) = *v2;
break;
case 22:
v31 = (const char *)config_add_module();
module_entry = (__int64)v31;
break;
case 23:
v31 = *(const char **)v2;
v22 = *(_QWORD *)module_entry;
*(_QWORD *)(v22 + 72) = strdup(*(const char **)v2);
break;
case 25:
case 27:
sios_module_add_param(*(_QWORD *)module_entry, *(_QWORD *)v2);
break;
case 28:
v23 = *(_QWORD *)module_entry;
*(_QWORD *)(v23 + 8) = strdup(*(const char **)v2);
break;
case 29:
v24 = module_entry;
*(_QWORD *)(v24 + 8) = strdup(*(const char **)v2);
break;
case 30:
v25 = *(_QWORD *)module_entry;
*(_QWORD *)(v25 + 80) = strdup(*(const char **)v2);
break;
case 31:
*(_DWORD *)(*(_QWORD *)module_entry + 16LL) = 1;
break;
case 32:
v31 = (const char *)*((_QWORD *)v2 - 1);
sios_param_set_val(v31, *(_QWORD *)v2);
break;
case 33:
v31 = (const char *)sios_param_alloc(*(_QWORD *)v2);
break;
default:
break;
}
v8 = &v3[-v11];
v2 = &v2[-8 * v11 + 8];
*(_QWORD *)v2 = v31;
v12 = (unsigned __int8)yyr1[v7] - 31;
v13 = *v8 + yypgoto[v12];
if ( v13 <= 0x3B && *v8 == yycheck[v13] )
v0 = yytable[v13];
else
v0 = yydefgoto[v12];
LABEL_18:
v3 = v8 + 1;
v8[1] = v0;
v14 = 2 * v1;
if ( v8 + 1 >= &v4[v1 - 1] )
{
v15 = (char *)v3 - (char *)v4;
v32 = v3 - v4 + 1;
if ( v1 > 0x270F )
goto LABEL_64;
v1 = 10000LL;
if ( v14 <= 0x2710 )
v1 = v14;
v16 = (__int16 *)malloc(10 * v1 + 7);
v17 = v16;
if ( !v16 )
{
LABEL_64:
yyerror("memory exhausted");
v9 = v3;
v3 = v4;
v10 = 2;
goto LABEL_66;
}
memcpy(v16, v4, v15 + 2);
v33 = (char *)&v17[v1];
memcpy(v33, v29, 8 * v32);
if ( v4 != src )
free(v4);
v3 = (__int16 *)((char *)v17 + v15);
v2 = &v33[8 * v32 - 8];
if ( v3 >= &v17[v1 - 1] )
{
if ( v17 == v3 )
{
v3 = v17;
v10 = 1;
goto LABEL_69;
}
v9 = v3;
v3 = v17;
v10 = 1;
goto LABEL_67;
}
v29 = v33;
v4 = v17;
}
if ( v0 == 18 )
{
v9 = v3;
v3 = v4;
v10 = 0;
goto LABEL_66;
}
}
v7 = (unsigned __int8)yydefact[v0];
if ( yydefact[v0] )
goto LABEL_13;
if ( !v30 )
{
++yynerrs;
yyerror("syntax error");
goto LABEL_59;
}
if ( v30 == 3 )
{
if ( yychar > 0 )
{
yychar = -2;
goto LABEL_59;
}
if ( !yychar )
{
v9 = v3;
v3 = v4;
v10 = 1;
LABEL_66:
if ( v9 == v3 )
goto LABEL_68;
do
LABEL_67:
--v9;
while ( v9 != v3 );
goto LABEL_68;
}
}
while ( 1 )
{
LABEL_59:
v26 = yypact[v0];
if ( v26 != -27 )
{
v27 = v26 + 1;
if ( v27 <= 0x3B && yycheck[v27] == 1 )
{
v0 = yytable[v27];
if ( v0 > 0 )
{
*((_QWORD *)v2 + 1) = yylval;
v2 += 8;
v8 = v3;
v30 = 3;
goto LABEL_18;
}
}
}
if ( v4 == v3 )
break;
v2 -= 8;
v0 = *--v3;
}
v10 = 1;
LABEL_68:
if ( v3 == src )
return v10;
LABEL_69:
free(v3);
return v10;
}

canonical_decompiled_code:
__int64 func8()
{
int v0; // ebp
unsigned __int64 v1; // r14
char *v2; // r12
__int16 *v3; // rbx
__int16 *v4; // r13
int v5; // edx
unsigned int v6; // er15
int v7; // er15
__int16 *v8; // rdx
__int16 *v9; // rax
unsigned int v10; // ebp
unsigned __int8 v11; // bp
int v12; // eax
unsigned int v13; // ecx
unsigned __int64 v14; // rax
signed __int64 v15; // r12
__int16 *v16; // rax
__int16 *v17; // r15
int v18; // er15
__int64 v19; // rdi
__int64 v20; // rdi
char **v21; // rdi
__int64 v22; // rdi
__int64 v23; // rdi
__int64 v24; // rdi
__int64 v25; // rdi
int v26; // eax
unsigned int v27; // eax
char *v29; // [rsp+8h] [rbp-830h]
int v30; // [rsp+14h] [rbp-824h]
const char *v31; // [rsp+18h] [rbp-820h]
__int64 v32; // [rsp+18h] [rbp-820h]
char *v33; // [rsp+28h] [rbp-810h]
char v34[1600]; // [rsp+30h] [rbp-808h] BYREF
__int16 src[228]; // [rsp+670h] [rbp-1C8h] BYREF

yynerrs = 0;
yychar = -2;
src[0] = 0;
v30 = 0;
v0 = 0;
v1 = 200LL;
v2 = v34;
v29 = v34;
v3 = src;
v4 = src;
while ( 1 )
{
v18 = yypact[v0];
if ( v18 == -27 )
break;
if ( yychar == -2 )
yychar = yylex();
if ( yychar <= 0 )
{
yychar = 0;
v5 = 0;
}
else
{
v5 = 2;
if ( (unsigned int)yychar <= 0x11B )
v5 = (unsigned __int8)yytranslate[yychar];
}
v6 = v5 + v18;
if ( v6 > 0x3B || yycheck[v6] != v5 )
break;
v0 = yytable[v6];
v7 = -v0;
if ( v0 > 0 )
{
v30 = (v30 == 0) + v30 - 1;
yychar = -2;
*((_QWORD *)v2 + 1) = yylval;
v2 += 8;
v8 = v3;
goto LABEL_18;
}
LABEL_13:
v11 = yyr2[v7];
v31 = *(const char **)&v2[8 * (1 - v11)];
switch ( v7 )
{
case 5:
func5();
break;
case 6:
*(_BYTE *)(config + 16) = *v2;
break;
case 7:
use_syslog = 1;
break;
case 8:
*(_BYTE *)(config + 17) = *v2;
break;
case 9:
v19 = config;
*(_QWORD *)(v19 + 24) = strdup(*(const char **)v2);
break;
case 10:
v20 = config;
*(_QWORD *)(v20 + 32) = strdup(*(const char **)v2);
break;
case 13:
case 21:
v31 = 0LL;
break;
case 14:
v31 = (const char *)config;
break;
case 17:
*(_DWORD *)(config + 8) = *(_QWORD *)v2;
break;
case 18:
v21 = (char **)config;
*v21 = strdup(*(const char **)v2);
break;
case 19:
*(_BYTE *)(config + 12) = *v2;
break;
case 20:
*(_BYTE *)(config + 13) = *v2;
break;
case 22:
v31 = (const char *)func6();
module_entry = (__int64)v31;
break;
case 23:
v31 = *(const char **)v2;
v22 = *(_QWORD *)module_entry;
*(_QWORD *)(v22 + 72) = strdup(*(const char **)v2);
break;
case 25:
case 27:
sios_module_add_param(*(_QWORD *)module_entry, *(_QWORD *)v2);
break;
case 28:
v23 = *(_QWORD *)module_entry;
*(_QWORD *)(v23 + 8) = strdup(*(const char **)v2);
break;
case 29:
v24 = module_entry;
*(_QWORD *)(v24 + 8) = strdup(*(const char **)v2);
break;
case 30:
v25 = *(_QWORD *)module_entry;
*(_QWORD *)(v25 + 80) = strdup(*(const char **)v2);
break;
case 31:
*(_DWORD *)(*(_QWORD *)module_entry + 16LL) = 1;
break;
case 32:
v31 = (const char *)*((_QWORD *)v2 - 1);
sios_param_set_val(v31, *(_QWORD *)v2);
break;
case 33:
v31 = (const char *)sios_param_alloc(*(_QWORD *)v2);
break;
default:
break;
}
v8 = &v3[-v11];
v2 = &v2[-8 * v11 + 8];
*(_QWORD *)v2 = v31;
v12 = (unsigned __int8)yyr1[v7] - 31;
v13 = *v8 + yypgoto[v12];
if ( v13 <= 0x3B && *v8 == yycheck[v13] )
v0 = yytable[v13];
else
v0 = yydefgoto[v12];
LABEL_18:
v3 = v8 + 1;
v8[1] = v0;
v14 = 2 * v1;
if ( v8 + 1 >= &v4[v1 - 1] )
{
v15 = (char *)v3 - (char *)v4;
v32 = v3 - v4 + 1;
if ( v1 > 0x270F )
goto LABEL_64;
v1 = 10000LL;
if ( v14 <= 0x2710 )
v1 = v14;
v16 = (__int16 *)malloc(10 * v1 + 7);
v17 = v16;
if ( !v16 )
{
LABEL_64:
func7("memory exhausted");
v9 = v3;
v3 = v4;
v10 = 2;
goto LABEL_66;
}
memcpy(v16, v4, v15 + 2);
v33 = (char *)&v17[v1];
memcpy(v33, v29, 8 * v32);
if ( v4 != src )
free(v4);
v3 = (__int16 *)((char *)v17 + v15);
v2 = &v33[8 * v32 - 8];
if ( v3 >= &v17[v1 - 1] )
{
if ( v17 == v3 )
{
v3 = v17;
v10 = 1;
goto LABEL_69;
}
v9 = v3;
v3 = v17;
v10 = 1;
goto LABEL_67;
}
v29 = v33;
v4 = v17;
}
if ( v0 == 18 )
{
v9 = v3;
v3 = v4;
v10 = 0;
goto LABEL_66;
}
}
v7 = (unsigned __int8)yydefact[v0];
if ( yydefact[v0] )
goto LABEL_13;
if ( !v30 )
{
++yynerrs;
func7("syntax error");
goto LABEL_59;
}
if ( v30 == 3 )
{
if ( yychar > 0 )
{
yychar = -2;
goto LABEL_59;
}
if ( !yychar )
{
v9 = v3;
v3 = v4;
v10 = 1;
LABEL_66:
if ( v9 == v3 )
goto LABEL_68;
do
LABEL_67:
--v9;
while ( v9 != v3 );
goto LABEL_68;
}
}
while ( 1 )
{
LABEL_59:
v26 = yypact[v0];
if ( v26 != -27 )
{
v27 = v26 + 1;
if ( v27 <= 0x3B && yycheck[v27] == 1 )
{
v0 = yytable[v27];
if ( v0 > 0 )
{
*((_QWORD *)v2 + 1) = yylval;
v2 += 8;
v8 = v3;
v30 = 3;
goto LABEL_18;
}
}
}
if ( v4 == v3 )
break;
v2 -= 8;
v0 = *--v3;
}
v10 = 1;
LABEL_68:
if ( v3 == src )
return v10;
LABEL_69:
free(v3);
return v10;
}

original_code:
int
yyparse (void)
{
    int yystate;
    int yyerrstatus;
    yytype_int16 yyssa[200];
    yytype_int16 *yyss;
    yytype_int16 *yyssp;
    YYSTYPE yyvsa[200];
    YYSTYPE *yyvs;
    YYSTYPE *yyvsp;
    long unsigned int yystacksize;
  int yyn;
  int yyresult;
  int yytoken = 0;
  YYSTYPE yyval;
  int yylen = 0;
  yyssp = yyss = yyssa;
  yyvsp = yyvs = yyvsa;
  yystacksize = 200;
  ;
  yystate = 0;
  yyerrstatus = 0;
  yynerrs = 0;
  yychar = (-2);
  goto yysetstate;
yynewstate:
  yyssp++;
yysetstate:
  *yyssp = (yytype_int16) yystate;
  if (yyss + yystacksize - 1 <= yyssp)
    {
      long unsigned int yysize = (long unsigned int) (yyssp - yyss + 1);
      if (10000 <= yystacksize)
        goto yyexhaustedlab;
      yystacksize *= 2;
      if (10000 < yystacksize)
        yystacksize = 10000;
      {
        yytype_int16 *yyss1 = yyss;
        union yyalloc *yyptr =
          (union yyalloc *) malloc (((yystacksize) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) + (sizeof (union yyalloc) - 1)));
        if (! yyptr)
          goto yyexhaustedlab;
        do { long unsigned int yynewbytes; __builtin_memcpy (&yyptr->yyss_alloc, yyss, (yysize) * sizeof (*(yyss))); yyss = &yyptr->yyss_alloc; yynewbytes = yystacksize * sizeof (*yyss) + (sizeof (union yyalloc) - 1); yyptr += yynewbytes / sizeof (*yyptr); } while (0);
        do { long unsigned int yynewbytes; __builtin_memcpy (&yyptr->yyvs_alloc, yyvs, (yysize) * sizeof (*(yyvs))); yyvs = &yyptr->yyvs_alloc; yynewbytes = yystacksize * sizeof (*yyvs) + (sizeof (union yyalloc) - 1); yyptr += yynewbytes / sizeof (*yyptr); } while (0);
        if (yyss1 != yyssa)
          free (yyss1);
      }
      yyssp = yyss + yysize - 1;
      yyvsp = yyvs + yysize - 1;
      ;
      if (yyss + yystacksize - 1 <= yyssp)
        goto yyabortlab;
    }
  ;
  if (yystate == 18)
    goto yyacceptlab;
  goto yybackup;
yybackup:
  yyn = yypact[yystate];
  if ((!!((yyn) == (-27))))
    goto yydefault;
  if (yychar == (-2))
    {
      ;
      yychar = yylex ();
    }
  if (yychar <= 0)
    {
      yychar = yytoken = 0;
      ;
    }
  else
    {
      yytoken = ((unsigned) (yychar) <= 283 ? yytranslate[yychar] : 2);
      ;
    }
  yyn += yytoken;
  if (yyn < 0 || 59 < yyn || yycheck[yyn] != yytoken)
    goto yydefault;
  yyn = yytable[yyn];
  if (yyn <= 0)
    {
      if (0)
        goto yyerrlab;
      yyn = -yyn;
      goto yyreduce;
    }
  if (yyerrstatus)
    yyerrstatus--;
  ;
  yychar = (-2);
  yystate = yyn;

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yyvsp = yylval;

#pragma GCC diagnostic pop

  goto yynewstate;
yydefault:
  yyn = yydefact[yystate];
  if (yyn == 0)
    goto yyerrlab;
  goto yyreduce;
yyreduce:
  yylen = yyr2[yyn];
  yyval = yyvsp[1-yylen];
  ;
  switch (yyn)
    {
        case 5:
    {
   config_add_class((yyvsp[0].str));
  }
    break;
  case 6:
    {
   config->strict_versioning = (yyvsp[0].bool);
  }
    break;
  case 7:
    {
   use_syslog = 1;
  }
    break;
  case 8:
    {
   config->dump_module_xml = (yyvsp[0].bool);
  }
    break;
  case 9:
    {
   config->xml_dump_path = strdup((yyvsp[0].str));
  }
    break;
  case 10:
    {
   config->xml_module_prefix = strdup((yyvsp[0].str));
  }
    break;
  case 13:
    { (yyval.osc) = ((void *)0); }
    break;
  case 14:
    { (yyval.osc) = &config->osc; }
    break;
  case 17:
    { config->osc.port = (yyvsp[0].num); }
    break;
  case 18:
    { config->osc.root = strdup((yyvsp[0].str)); }
    break;
  case 19:
    { config->osc.do_udp = (yyvsp[0].bool); }
    break;
  case 20:
    { config->osc.do_tcp = (yyvsp[0].bool); }
    break;
  case 21:
    { (yyval.entry) = ((void *)0); }
    break;
  case 22:
    {
   (yyval.entry) = config_add_module();
   module_entry = (yyval.entry);
  }
    break;
  case 23:
    {
   module_entry->module->module_name = strdup((yyvsp[0].str));
   (yyval.str) = (yyvsp[0].str);
  }
    break;
  case 25:
    {
   sios_module_add_param(module_entry->module, (yyvsp[0].param));
  }
    break;
  case 27:
    {
   sios_module_add_param(module_entry->module, (yyvsp[0].param));
  }
    break;
  case 28:
    {
   module_entry->module->path = strdup((yyvsp[0].str));
  }
    break;
  case 29:
    {
   module_entry->class = strdup((yyvsp[0].str));
  }
    break;
  case 30:
    {
   module_entry->module->module_descr = strdup((yyvsp[0].str));
  }
    break;
  case 31:
    {
   module_entry->module->lazy = 1;
  }
    break;
  case 32:
    {
   sios_param_set_val((yyvsp[-1].param), (yyvsp[0].str));
   (yyval.param) = (yyvsp[-1].param);
  }
    break;
  case 33:
    {
  (yyval.param) = sios_param_alloc((yyvsp[0].str));
 }
    break;
      default: break;
    }
  ;
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  ;
  *++yyvsp = yyval;
  {
    const int yylhs = yyr1[yyn] - 31;
    const int yyi = yypgoto[yylhs] + *yyssp;
    yystate = (0 <= yyi && yyi <= 59 && yycheck[yyi] == *yyssp
               ? yytable[yyi]
               : yydefgoto[yylhs]);
  }
  goto yynewstate;
yyerrlab:
  yytoken = yychar == (-2) ? (-2) : ((unsigned) (yychar) <= 283 ? yytranslate[yychar] : 2);
  if (!yyerrstatus)
    {
      ++yynerrs;
      yyerror ("syntax error");
    }
  if (yyerrstatus == 3)
    {
      if (yychar <= 0)
        {
          if (yychar == 0)
            goto yyabortlab;
        }
      else
        {
          yydestruct ("Error: discarding",
                      yytoken, &yylval);
          yychar = (-2);
        }
    }
  goto yyerrlab1;
yyerrorlab:
  if (0)
    goto yyerrorlab;
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  ;
  yystate = *yyssp;
  goto yyerrlab1;
yyerrlab1:
  yyerrstatus = 3;
  for (;;)
    {
      yyn = yypact[yystate];
      if (!(!!((yyn) == (-27))))
        {
          yyn += 1;
          if (0 <= yyn && yyn <= 59 && yycheck[yyn] == 1)
            {
              yyn = yytable[yyn];
              if (0 < yyn)
                break;
            }
        }
      if (yyssp == yyss)
        goto yyabortlab;
      yydestruct ("Error: popping",
                  yystos[yystate], yyvsp);
      (yyvsp -= (1), yyssp -= (1));
      yystate = *yyssp;
      ;
    }

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yyvsp = yylval;

#pragma GCC diagnostic pop

  ;
  yystate = yyn;
  goto yynewstate;
yyacceptlab:
  yyresult = 0;
  goto yyreturn;
yyabortlab:
  yyresult = 1;
  goto yyreturn;
yyexhaustedlab:
  yyerror ("memory exhausted");
  yyresult = 2;
yyreturn:
  if (yychar != (-2))
    {
      yytoken = ((unsigned) (yychar) <= 283 ? yytranslate[yychar] : 2);
      yydestruct ("Cleanup: discarding lookahead",
                  yytoken, &yylval);
    }
  (yyvsp -= (yylen), yyssp -= (yylen));
  ;
  while (yyssp != yyss)
    {
      yydestruct ("Cleanup: popping",
                  yystos[*yyssp], yyvsp);
      (yyvsp -= (1), yyssp -= (1));
    }
  if (yyss != yyssa)
    free (yyss);
  return yyresult;
}

canonical_original_code:
int yyparse()
{
    int yystate;
    int yyerrstatus;
    short yyssa[200];
    short *yyss;
    short *yyssp;
    union YYSTYPE yyvsa[200];
    union YYSTYPE *yyvs;
    union YYSTYPE *yyvsp;
    unsigned long yystacksize;
  int yyn;
  int yyresult;
  int yytoken = 0;
  union YYSTYPE yyval;
  int yylen = 0;
  yyssp = yyss = yyssa;
  yyvsp = yyvs = yyvsa;
  yystacksize = 200;
  ;
  yystate = 0;
  yyerrstatus = 0;
  yynerrs = 0;
  yychar = (-2);
  goto yysetstate;
yynewstate:
  yyssp++;
yysetstate:
  *yyssp = (short) yystate;
  if (yyss + yystacksize - 1 <= yyssp)
    {
      unsigned long yysize = (long unsigned int) (yyssp - yyss + 1);
      if (10000 <= yystacksize)
        goto yyexhaustedlab;
      yystacksize *= 2;
      if (10000 < yystacksize)
        yystacksize = 10000;
      {
        short *yyss1 = yyss;
        union yyalloc *yyptr = (union yyalloc *) malloc (((yystacksize) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) + (sizeof (union yyalloc) - 1)));
        if (! yyptr)
          goto yyexhaustedlab;
        do { unsigned long yynewbytes; __builtin_memcpy (&yyptr->yyss_alloc, yyss, (yysize) * sizeof (*(yyss))); yyss = &yyptr->yyss_alloc; yynewbytes = yystacksize * sizeof (*yyss) + (sizeof (union yyalloc) - 1); yyptr += yynewbytes / sizeof (*yyptr); } while (0);
        do { unsigned long yynewbytes; __builtin_memcpy (&yyptr->yyvs_alloc, yyvs, (yysize) * sizeof (*(yyvs))); yyvs = &yyptr->yyvs_alloc; yynewbytes = yystacksize * sizeof (*yyvs) + (sizeof (union yyalloc) - 1); yyptr += yynewbytes / sizeof (*yyptr); } while (0);
        if (yyss1 != yyssa)
          free (yyss1);
      }
      yyssp = yyss + yysize - 1;
      yyvsp = yyvs + yysize - 1;
      ;
      if (yyss + yystacksize - 1 <= yyssp)
        goto yyabortlab;
    }
  ;
  if (yystate == 18)
    goto yyacceptlab;
  goto yybackup;
yybackup:
  yyn = yypact[yystate];
  if ((!!((yyn) == (-27))))
    goto yydefault;
  if (yychar == (-2))
    {
      ;
      yychar = yylex ();
    }
  if (yychar <= 0)
    {
      yychar = yytoken = 0;
      ;
    }
  else
    {
      yytoken = ((unsigned int) (yychar) <= 283 ? yytranslate[yychar] : 2);
      ;
    }
  yyn += yytoken;
  if (yyn < 0 || 59 < yyn || yycheck[yyn] != yytoken)
    goto yydefault;
  yyn = yytable[yyn];
  if (yyn <= 0)
    {
      if (0)
        goto yyerrlab;
      yyn = -yyn;
      goto yyreduce;
    }
  if (yyerrstatus)
    yyerrstatus--;
  ;
  yychar = (-2);
  yystate = yyn;

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yyvsp = yylval;

#pragma GCC diagnostic pop

  goto yynewstate;
yydefault:
  yyn = yydefact[yystate];
  if (yyn == 0)
    goto yyerrlab;
  goto yyreduce;
yyreduce:
  yylen = yyr2[yyn];
  yyval = yyvsp[1-yylen];
  ;
  switch (yyn)
    {
        case 5:
    {
   config_add_class((yyvsp[0].str));
  }
    break;
  case 6:
    {
   config->strict_versioning = (yyvsp[0].bool);
  }
    break;
  case 7:
    {
   use_syslog = 1;
  }
    break;
  case 8:
    {
   config->dump_module_xml = (yyvsp[0].bool);
  }
    break;
  case 9:
    {
   config->xml_dump_path = strdup((yyvsp[0].str));
  }
    break;
  case 10:
    {
   config->xml_module_prefix = strdup((yyvsp[0].str));
  }
    break;
  case 13:
    { (yyval.osc) = ((void *)0); }
    break;
  case 14:
    { (yyval.osc) = &config->osc; }
    break;
  case 17:
    { config->osc.port = (yyvsp[0].num); }
    break;
  case 18:
    { config->osc.root = strdup((yyvsp[0].str)); }
    break;
  case 19:
    { config->osc.do_udp = (yyvsp[0].bool); }
    break;
  case 20:
    { config->osc.do_tcp = (yyvsp[0].bool); }
    break;
  case 21:
    { (yyval.entry) = ((void *)0); }
    break;
  case 22:
    {
   (yyval.entry) = config_add_module();
   module_entry = (yyval.entry);
  }
    break;
  case 23:
    {
   module_entry->module->module_name = strdup((yyvsp[0].str));
   (yyval.str) = (yyvsp[0].str);
  }
    break;
  case 25:
    {
   sios_module_add_param(module_entry->module, (yyvsp[0].param));
  }
    break;
  case 27:
    {
   sios_module_add_param(module_entry->module, (yyvsp[0].param));
  }
    break;
  case 28:
    {
   module_entry->module->path = strdup((yyvsp[0].str));
  }
    break;
  case 29:
    {
   module_entry->class = strdup((yyvsp[0].str));
  }
    break;
  case 30:
    {
   module_entry->module->module_descr = strdup((yyvsp[0].str));
  }
    break;
  case 31:
    {
   module_entry->module->lazy = 1;
  }
    break;
  case 32:
    {
   sios_param_set_val((yyvsp[-1].param), (yyvsp[0].str));
   (yyval.param) = (yyvsp[-1].param);
  }
    break;
  case 33:
    {
  (yyval.param) = sios_param_alloc((yyvsp[0].str));
 }
    break;
      default: break;
    }
  ;
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  ;
  *++yyvsp = yyval;
  {
    int yylhs = yyr1[yyn] - 31;
    int yyi = yypgoto[yylhs] + *yyssp;
    yystate = (0 <= yyi && yyi <= 59 && yycheck[yyi] == *yyssp
               ? yytable[yyi]
               : yydefgoto[yylhs]);
  }
  goto yynewstate;
yyerrlab:
  yytoken = yychar == (-2) ? (-2) : ((unsigned int) (yychar) <= 283 ? yytranslate[yychar] : 2);
  if (!yyerrstatus)
    {
      ++yynerrs;
      yyerror ("syntax error");
    }
  if (yyerrstatus == 3)
    {
      if (yychar <= 0)
        {
          if (yychar == 0)
            goto yyabortlab;
        }
      else
        {
          yydestruct ("Error: discarding",
                      yytoken, &yylval);
          yychar = (-2);
        }
    }
  goto yyerrlab1;
yyerrorlab:
  if (0)
    goto yyerrorlab;
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  ;
  yystate = *yyssp;
  goto yyerrlab1;
yyerrlab1:
  yyerrstatus = 3;
  for (;;)
    {
      yyn = yypact[yystate];
      if (!(!!((yyn) == (-27))))
        {
          yyn += 1;
          if (0 <= yyn && yyn <= 59 && yycheck[yyn] == 1)
            {
              yyn = yytable[yyn];
              if (0 < yyn)
                break;
            }
        }
      if (yyssp == yyss)
        goto yyabortlab;
      yydestruct ("Error: popping",
                  yystos[yystate], yyvsp);
      (yyvsp -= (1), yyssp -= (1));
      yystate = *yyssp;
      ;
    }

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yyvsp = yylval;

#pragma GCC diagnostic pop

  ;
  yystate = yyn;
  goto yynewstate;
yyacceptlab:
  yyresult = 0;
  goto yyreturn;
yyabortlab:
  yyresult = 1;
  goto yyreturn;
yyexhaustedlab:
  yyerror ("memory exhausted");
  yyresult = 2;
yyreturn:
  if (yychar != (-2))
    {
      yytoken = ((unsigned int) (yychar) <= 283 ? yytranslate[yychar] : 2);
      yydestruct ("Cleanup: discarding lookahead",
                  yytoken, &yylval);
    }
  (yyvsp -= (yylen), yyssp -= (yylen));
  ;
  while (yyssp != yyss)
    {
      yydestruct ("Cleanup: popping",
                  yystos[*yyssp], yyvsp);
      (yyvsp -= (1), yyssp -= (1));
    }
  if (yyss != yyssa)
    free (yyss);
  return yyresult;
}

variable_types: yystate int

variable_types: yyerrstatus int

variable_types:
yyssa
short [200]

variable_types:
yyss
short *

variable_types:
yyssp
short *

variable_types: union YYSTYPE { char *str; long num; float fnum; char bool; struct osc_entry { char *root; int port; char do_udp; char do_tcp; } *osc; struct module_entry { struct sios_module { char *basename; char *path; int lazy; char *lazy_id; void *dl_handle; struct list_head { struct list_head *next; } params; struct list_head list; char *module_name; char *module_descr; struct sios_class { char name[64]; char classpath[128]; struct list_head object_list; struct list_head class_head; } *class; struct sios_object { char name[64]; char path[128]; char *desc; char *id; int type; struct sios_class *class; struct list_head class_head; struct list_head object_head; struct list_head osc_methods; struct list_head osc_params; struct list_head listeners; } *obj; int (*init)(); void (*destroy)(); void (*set_name)(char *name); void (*set_descr)(char *descr); void (*set_class)(struct sios_class *class); } *module; char *class; struct list_head entry; } *entry; struct sios_param_type { char *name; char *val; struct list_head params; } *param; } [200]

variable_types: union YYSTYPE { char *str; long num; float fnum; char bool; struct osc_entry { char *root; int port; char do_udp; char do_tcp; } *osc; struct module_entry { struct sios_module { char *basename; char *path; int lazy; char *lazy_id; void *dl_handle; struct list_head { struct list_head *next; } params; struct list_head list; char *module_name; char *module_descr; struct sios_class { char name[64]; char classpath[128]; struct list_head object_list; struct list_head class_head; } *class; struct sios_object { char name[64]; char path[128]; char *desc; char *id; int type; struct sios_class *class; struct list_head class_head; struct list_head object_head; struct list_head osc_methods; struct list_head osc_params; struct list_head listeners; } *obj; int (*init)(); void (*destroy)(); void (*set_name)(char *name); void (*set_descr)(char *descr); void (*set_class)(struct sios_class *class); } *module; char *class; struct list_head entry; } *entry; struct sios_param_type { char *name; char *val; struct list_head params; } *param; } *

variable_types:
yystacksize
unsigned long

variable_types: yyn int

variable_types: yyresult int

variable_types: yytoken int

variable_types: yylen int

variable_types:
yysize
unsigned long

variable_types: union yyalloc { short yyss_alloc; union YYSTYPE { char *str; long num; float fnum; char bool; struct osc_entry { char *root; int port; char do_udp; char do_tcp; } *osc; struct module_entry { struct sios_module { char *basename; char *path; int lazy; char *lazy_id; void *dl_handle; struct list_head { struct list_head *next; } params; struct list_head list; char *module_name; char *module_descr; struct sios_class { char name[64]; char classpath[128]; struct list_head object_list; struct list_head class_head; } *class; struct sios_object { char name[64]; char path[128]; char *desc; char *id; int type; struct sios_class *class; struct list_head class_head; struct list_head object_head; struct list_head osc_methods; struct list_head osc_params; struct list_head listeners; } *obj; int (*init)(); void (*destroy)(); void (*set_name)(char *name); void (*set_descr)(char *descr); void (*set_class)(struct sios_class *class); } *module; char *class; struct list_head entry; } *entry; struct sios_param_type { char *name; char *val; struct list_head params; } *param; } yyvs_alloc; } *

variable_types:
yynewbytes
unsigned long

variable_types: yylhs int

variable_types: yyi int

user_defined_types: union YYSTYPE { char *str; long num; float fnum; char bool; struct osc_entry *osc; struct module_entry *entry; struct sios_param_type *param; }

user_defined_types: union yyalloc { short yyss_alloc; union YYSTYPE yyvs_alloc; }


decompiled_code:
_BOOL8 __fastcall list_empty(_QWORD *a1)
{
return *a1 == (_QWORD)a1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(_QWORD *a1)
{
return *a1 == (_QWORD)a1;
}

original_code:
static inline int list_empty(const struct list_head *head)
{
 return head->next == head;
}

canonical_original_code:
static inline int list_empty(struct list_head *head)
{
 return head->next == head;
}

variable_types: struct list_head { struct list_head *next; } *


decompiled_code:
void sios_osc_dump_xml()
{
const char *v0; // r12
size_t v1; // rbx
char *v2; // rbp
int v3; // eax
int v4; // ebx
int *v5; // rax
char *v6; // rax
int *v7; // rax
char *v8; // rax
size_t v9; // r12
size_t v10; // r12
char s[1048]; // [rsp+0h] [rbp-418h] BYREF

v0 = *(const char **)(config + 24LL);
v1 = (int)(strlen(v0) + 9);
v2 = (char *)malloc(v1);
snprintf(v2, v1, "%s/osc.xml", v0);
v3 = open(v2, 65, 493LL);
if ( v3 < 0 )
{
if ( use_syslog )
{
v5 = _errno_location();
v6 = strerror(*v5);
syslog(4, "Warning: [%s] Could not open xml dump path '%s': %s", "XMLDUMP", v2, v6);
}
else
{
v7 = _errno_location();
v8 = strerror(*v7);
fprintf(stdout, "Warning: [%s] Could not open xml dump path '%s': %s\n", "XMLDUMP", v2, v8);
}
free(v2);
}
else
{
v4 = v3;
if ( *(_BYTE *)(config + 12LL) )
{
v9 = sprintf(
s,
"<%s %s=\"%d\" %s=\"%s\" %s=\"%s\"/>\n",
"osc",
"port",
*(unsigned int *)(config + 8LL),
"proto",
"udp",
"root",
(const char *)*config);
write(v4, s, v9);
memset(s, 0, v9);
}
if ( *(_BYTE *)(config + 13LL) )
{
v10 = sprintf(
s,
"<%s %s=\"%d\" %s=\"%s\" %s=\"%s\"/>\n",
"osc",
"port",
*(unsigned int *)(config + 8LL),
"proto",
"tcp",
"root",
(const char *)*config);
write(v4, s, v10);
memset(s, 0, v10);
}
free(v2);
close(v4);
}
}

canonical_decompiled_code:
void func1()
{
const char *v0; // r12
size_t v1; // rbx
char *v2; // rbp
int v3; // eax
int v4; // ebx
int *v5; // rax
char *v6; // rax
int *v7; // rax
char *v8; // rax
size_t v9; // r12
size_t v10; // r12
char s[1048]; // [rsp+0h] [rbp-418h] BYREF

v0 = *(const char **)(config + 24LL);
v1 = (int)(strlen(v0) + 9);
v2 = (char *)malloc(v1);
snprintf(v2, v1, "%s/osc.xml", v0);
v3 = open(v2, 65, 493LL);
if ( v3 < 0 )
{
if ( use_syslog )
{
v5 = _errno_location();
v6 = strerror(*v5);
syslog(4, "Warning: [%s] Could not open xml dump path '%s': %s", "XMLDUMP", v2, v6);
}
else
{
v7 = _errno_location();
v8 = strerror(*v7);
fprintf(stdout, "Warning: [%s] Could not open xml dump path '%s': %s\n", "XMLDUMP", v2, v8);
}
free(v2);
}
else
{
v4 = v3;
if ( *(_BYTE *)(config + 12LL) )
{
v9 = sprintf(
s,
"<%s %s=\"%d\" %s=\"%s\" %s=\"%s\"/>\n",
"osc",
"port",
*(unsigned int *)(config + 8LL),
"proto",
"udp",
"root",
(const char *)*config);
write(v4, s, v9);
memset(s, 0, v9);
}
if ( *(_BYTE *)(config + 13LL) )
{
v10 = sprintf(
s,
"<%s %s=\"%d\" %s=\"%s\" %s=\"%s\"/>\n",
"osc",
"port",
*(unsigned int *)(config + 8LL),
"proto",
"tcp",
"root",
(const char *)*config);
write(v4, s, v10);
memset(s, 0, v10);
}
free(v2);
close(v4);
}
}

original_code:
void sios_osc_dump_xml(void)
{
 char * dumppath;
 char linebuf[1024];
 int buflen;
 int pathlen;
 int fd;
 pathlen = strlen(config->xml_dump_path) + 9;
 dumppath = (char*)malloc(pathlen);
 snprintf(dumppath, pathlen, "%s/osc.xml", config->xml_dump_path);
 fd = open(dumppath, 01|0100, 0755);
 if (fd < 0) {
  do { if (use_syslog) { syslog(4, "Warning: [%s] " "Could not open xml dump path '%s': %s","XMLDUMP", dumppath, strerror((*__errno_location ()))); } else { fprintf(stdout, "Warning: [%s] " "Could not open xml dump path '%s': %s" "\n","XMLDUMP", dumppath, strerror((*__errno_location ()))); } } while (0);
  free(dumppath);
  return;
 }
 if (config->osc.do_udp) {
  buflen = sprintf(linebuf, "<%s %s=\"%d\" %s=\"%s\" %s=\"%s\"/>\n",
       "osc",
       "port", config->osc.port,
       "proto", "udp",
       "root", config->osc.root);
  write(fd, linebuf, buflen);
  bzero(linebuf, buflen);
 }
 if (config->osc.do_tcp) {
  buflen = sprintf(linebuf, "<%s %s=\"%d\" %s=\"%s\" %s=\"%s\"/>\n",
       "osc",
       "port", config->osc.port,
       "proto", "tcp",
       "root", config->osc.root);
  write(fd, linebuf, buflen);
  bzero(linebuf, buflen);
 }
 free(dumppath);
 close(fd);
}

canonical_original_code:
void sios_osc_dump_xml()
{
 char *dumppath;
 char linebuf[1024];
 int buflen;
 int pathlen;
 int fd;
 pathlen = strlen(config->xml_dump_path) + 9;
 dumppath = (char *)malloc(pathlen);
 snprintf(dumppath, pathlen, "%s/osc.xml", config->xml_dump_path);
 fd = open(dumppath, 01|0100, 0755);
 if (fd < 0) {
  do { if (use_syslog) { syslog(4, "Warning: [%s] " "Could not open xml dump path '%s': %s","XMLDUMP", dumppath, strerror((*__errno_location ()))); } else { fprintf(stdout, "Warning: [%s] " "Could not open xml dump path '%s': %s" "\n","XMLDUMP", dumppath, strerror((*__errno_location ()))); } } while (0);
  free(dumppath);
  return;
 }
 if (config->osc.do_udp) {
  buflen = sprintf(linebuf, "<%s %s=\"%d\" %s=\"%s\" %s=\"%s\"/>\n",
       "osc",
       "port", config->osc.port,
       "proto", "udp",
       "root", config->osc.root);
  write(fd, linebuf, buflen);
  bzero(linebuf, buflen);
 }
 if (config->osc.do_tcp) {
  buflen = sprintf(linebuf, "<%s %s=\"%d\" %s=\"%s\" %s=\"%s\"/>\n",
       "osc",
       "port", config->osc.port,
       "proto", "tcp",
       "root", config->osc.root);
  write(fd, linebuf, buflen);
  bzero(linebuf, buflen);
 }
 free(dumppath);
 close(fd);
}

variable_types:
dumppath
char *

variable_types:
linebuf
char [1024]

variable_types: buflen int

variable_types: pathlen int

variable_types: fd int


decompiled_code:
void sios_dump_xml()
{
if ( *(_QWORD *)(config + 24LL) )
{
sios_dump_classes();
sios_dump_modules();
sios_osc_dump_xml();
}
}

canonical_decompiled_code:
void func2()
{
if ( *(_QWORD *)(config + 24LL) )
{
sios_dump_classes();
sios_dump_modules();
func1();
}
}

original_code:
void sios_dump_xml(void)
{
 if (config->xml_dump_path) {
  sios_dump_classes();
  sios_dump_modules();
  sios_osc_dump_xml();
 }
}

canonical_original_code:
void sios_dump_xml()
{
 if (config->xml_dump_path) {
  sios_dump_classes();
  sios_dump_modules();
  sios_osc_dump_xml();
 }
}


original_code:
int timeval_subtract (struct timeval * result,
        struct timeval * x,
        struct timeval * y)
{
 if (x->tv_usec < y->tv_usec) {
  int nsec = (y->tv_usec - x->tv_usec) / 1000000 + 1;
  y->tv_usec -= 1000000 * nsec;
  y->tv_sec += nsec;
 }
 if (x->tv_usec - y->tv_usec > 1000000) {
  int nsec = (x->tv_usec - y->tv_usec) / 1000000;
  y->tv_usec += 1000000 * nsec;
  y->tv_sec -= nsec;
 }
 result->tv_sec = x->tv_sec - y->tv_sec;
 result->tv_usec = x->tv_usec - y->tv_usec;
 return x->tv_sec < y->tv_sec;
}

canonical_original_code:
int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y)
{
 if (x->tv_usec < y->tv_usec) {
  int nsec = (y->tv_usec - x->tv_usec) / 1000000 + 1;
  y->tv_usec -= 1000000 * nsec;
  y->tv_sec += nsec;
 }
 if (x->tv_usec - y->tv_usec > 1000000) {
  int nsec = (x->tv_usec - y->tv_usec) / 1000000;
  y->tv_usec += 1000000 * nsec;
  y->tv_sec -= nsec;
 }
 result->tv_sec = x->tv_sec - y->tv_sec;
 result->tv_usec = x->tv_usec - y->tv_usec;
 return x->tv_sec < y->tv_sec;
}

variable_types: struct timeval { long tv_sec; long tv_usec; } *

variable_types:
x
struct timeval *

variable_types:
y
struct timeval *

variable_types: nsec int


repo: sddelong/ddc-svd

decompiled_code:
int __fastcall print_matrix(__int64 a1, __int64 a2, __int64 a3, const char *a4)
{
int result; // eax
__int64 i; // r14
__int64 v7; // rbx
double *v8; // rbp

result = printf("%s \n", a4);
if ( a2 > 0 )
{
for ( i = 0LL; i != a2; ++i )
{
v8 = (double *)(a1 + 8 * i);
v7 = 0LL;
if ( a3 > 0 )
{
do
{
printf("%11.3E", *v8);
++v7;
v8 += a2;
}
while ( v7 != a3 );
}
result = putchar(10);
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func0(__int64 a1, __int64 a2, __int64 a3, const char *a4)
{
int result; // eax
__int64 i; // r14
__int64 v7; // rbx
double *v8; // rbp

result = printf("%s \n", a4);
if ( a2 > 0 )
{
for ( i = 0LL; i != a2; ++i )
{
v8 = (double *)(a1 + 8 * i);
v7 = 0LL;
if ( a3 > 0 )
{
do
{
printf("%11.3E", *v8);
++v7;
v8 += a2;
}
while ( v7 != a3 );
}
result = putchar(10);
}
}
return result;
}

original_code:
void print_matrix(const double * A, long m, long n, char * message){
    printf("%s \n",message);
    for (int i=0; i<m; i++){
  for (int j=0; j<n; j++){
   printf("%11.3E",A[i+m*j]);
  }
  printf("\n");
 }
 return;
}

canonical_original_code:
void print_matrix(double *A, long m, long n, char *message){
    printf("%s \n",message);
    for (int i = 0; i<m; i++){
  for (int j = 0; j<n; j++){
   printf("%11.3E",A[i+m*j]);
  }
  printf("\n");
 }
 return;
}

variable_types:
A
double *

variable_types: m long

variable_types: n long

variable_types:
message
char *

variable_types: i int

variable_types: j int


decompiled_code:
double __fastcall l2_normv(int a1, double *a2)
{
double *v2; // rax
double v3; // xmm1_8

if ( a1 <= 0 )
{
v3 = 0.0;
return sqrt(v3);
}
v2 = a2;
v3 = 0.0;
do
{
v3 = v3 + *v2 * *v2;
++v2;
}
while ( v2 != &a2[(unsigned int)(a1 - 1) + 1] );
if ( v3 >= 0.0 )
return sqrt(v3);
return sqrt(v3);
}

canonical_decompiled_code:
double __fastcall func1(int a1, double *a2)
{
double *v2; // rax
double v3; // xmm1_8

if ( a1 <= 0 )
{
v3 = 0.0;
return sqrt(v3);
}
v2 = a2;
v3 = 0.0;
do
{
v3 = v3 + *v2 * *v2;
++v2;
}
while ( v2 != &a2[(unsigned int)(a1 - 1) + 1] );
if ( v3 >= 0.0 )
return sqrt(v3);
return sqrt(v3);
}

original_code:
double l2_normv(int l, const double*restrict v){
  double temp = 0;
  for (int i=0; i<l; i++){
   temp+= v[i]*v[i];
  }
  return sqrt(temp);
 }

canonical_original_code:
double l2_normv(int l, double *v){
  double temp = 0;
  for (int i = 0; i<l; i++){
   temp+= v[i]*v[i];
  }
  return sqrt(temp);
 }

variable_types: l int

variable_types:
v
double *

variable_types: temp double

return_type: double


decompiled_code:
void __fastcall scale_vector(int a1, double *a2, double a3)
{
double *v3; // rax

if ( a1 > 0 )
{
v3 = a2;
do
{
*v3 = a3 * *v3;
++v3;
}
while ( v3 != &a2[(unsigned int)(a1 - 1) + 1] );
}
}

canonical_decompiled_code:
void __fastcall func2(int a1, double *a2, double a3)
{
double *v3; // rax

if ( a1 > 0 )
{
v3 = a2;
do
{
*v3 = a3 * *v3;
++v3;
}
while ( v3 != &a2[(unsigned int)(a1 - 1) + 1] );
}
}

original_code:
void scale_vector(int l, double*restrict v, double scale){
 for (int i=0; i<l; i++){
  v[i] *= scale;
 }
 return;
}

canonical_original_code:
void scale_vector(int l, double *v, double scale){
 for (int i = 0; i<l; i++){
  v[i] *= scale;
 }
 return;
}

variable_types: scale double


decompiled_code:
double __fastcall l2_norm_mat_row(int a1, __int64 a2, int a3, double *a4)
{
int v4; // eax
double v5; // xmm1_8

if ( a3 <= 0 )
{
v5 = 0.0;
return sqrt(v5);
}
v4 = 0;
v5 = 0.0;
do
{
v5 = v5 + *a4 * *a4;
++v4;
a4 += a1;
}
while ( a3 != v4 );
if ( v5 >= 0.0 )
return sqrt(v5);
return sqrt(v5);
}

canonical_decompiled_code:
double __fastcall func3(int a1, __int64 a2, int a3, double *a4)
{
int v4; // eax
double v5; // xmm1_8

if ( a3 <= 0 )
{
v5 = 0.0;
return sqrt(v5);
}
v4 = 0;
v5 = 0.0;
do
{
v5 = v5 + *a4 * *a4;
++v4;
a4 += a1;
}
while ( a3 != v4 );
if ( v5 >= 0.0 )
return sqrt(v5);
return sqrt(v5);
}

original_code:
double l2_norm_mat_row(int m, int n, int l, const double*restrict row){
  double temp = 0;
  for (int i=0; i<l; i++){
   temp+= row[i*m]*row[i*m];
  }
  return sqrt(temp);
 }

canonical_original_code:
double l2_norm_mat_row(int m, int n, int l, double *row){
  double temp = 0;
  for (int i = 0; i<l; i++){
   temp+= row[i*m]*row[i*m];
  }
  return sqrt(temp);
 }

variable_types: m int

variable_types: n int

variable_types:
row
double *


decompiled_code:
void __fastcall scale_mat_row(int a1, double a2, __int64 a3, int a4, double *a5)
{
int i; // eax

if ( a4 > 0 )
{
for ( i = 0; i != a4; ++i )
{
*a5 = a2 * *a5;
a5 += a1;
}
}
}

canonical_decompiled_code:
void __fastcall func4(int a1, double a2, __int64 a3, int a4, double *a5)
{
int i; // eax

if ( a4 > 0 )
{
for ( i = 0; i != a4; ++i )
{
*a5 = a2 * *a5;
a5 += a1;
}
}
}

original_code:
void scale_mat_row(int m, int n, int l, double*restrict row, double scale){
 for (int i=0; i<l; i++){
  row[i*m] *= scale;
 }
 return;
}

canonical_original_code:
void scale_mat_row(int m, int n, int l, double *row, double scale){
 for (int i = 0; i<l; i++){
  row[i*m] *= scale;
 }
 return;
}


decompiled_code:
void __fastcall set_vec_to_zero(int a1, _QWORD *a2)
{
_QWORD *v2; // rax

if ( a1 > 0 )
{
v2 = a2;
do
*v2++ = 0LL;
while ( v2 != &a2[(unsigned int)(a1 - 1) + 1] );
}
}

canonical_decompiled_code:
void __fastcall func5(int a1, _QWORD *a2)
{
_QWORD *v2; // rax

if ( a1 > 0 )
{
v2 = a2;
do
*v2++ = 0LL;
while ( v2 != &a2[(unsigned int)(a1 - 1) + 1] );
}
}

original_code:
void set_vec_to_zero(int l, double*restrict v){
 for (int i=0; i<l; i++){
  v[i] = 0;
 }
 return;
}

canonical_original_code:
void set_vec_to_zero(int l, double *v){
 for (int i = 0; i<l; i++){
  v[i] = 0;
 }
 return;
}


original_code:
void dgemm_simple( const int M, const int N, const int L, const double *A, const double *B, double *C){
 for (int i=0; i<M; i++){
  for (int j=0; j<N; j++){
   for (int k=0; k<L; k++){
     C[i+j*M] = C[i+j*M] + A[i+k*M]*B[k+j*L];
   }
  }
 }
 return;
}

canonical_original_code:
void dgemm_simple(int M, int N, int L, double *A, double *B, double *C){
 for (int i = 0; i<M; i++){
  for (int j = 0; j<N; j++){
   for (int k = 0; k<L; k++){
     C[i+j*M] = C[i+j*M] + A[i+k*M]*B[k+j*L];
   }
  }
 }
 return;
}

variable_types: M int

variable_types: N int

variable_types: L int

variable_types:
B
double *

variable_types:
C
double *

variable_types: k int


original_code:
void form_bidiag( const int M, const int N, const double *alpha, const double *beta, double * mat){
 for (int j=0; j < N; j++){
  for (int i=0; i < M; i++){
   mat[i+j*M] = 0;
  }
 }
 if (N>M){
  for (int i=0; i < M; i++){
   mat[i+i*M] = alpha[i];
   mat[i+(i+1)*M] = beta[i];
  }
 }
 else{
  for (int i=0; i < N-1; i++){
   mat[i+i*M] = alpha[i];
   mat[i+(i+1)*M] = beta[i];
  }
  mat[N-1 + (N-1)*M] = alpha[N-1];
 }
 return;
}

canonical_original_code:
void form_bidiag(int M, int N, double *alpha, double *beta, double *mat){
 for (int j = 0; j < N; j++){
  for (int i = 0; i < M; i++){
   mat[i+j*M] = 0;
  }
 }
 if (N>M){
  for (int i = 0; i < M; i++){
   mat[i+i*M] = alpha[i];
   mat[i+(i+1)*M] = beta[i];
  }
 }
 else{
  for (int i = 0; i < N-1; i++){
   mat[i+i*M] = alpha[i];
   mat[i+(i+1)*M] = beta[i];
  }
  mat[N-1 + (N-1)*M] = alpha[N-1];
 }
 return;
}

variable_types:
alpha
double *

variable_types:
beta
double *

variable_types:
mat
double *


transpose

original_code:
void transpose( const int M, const int N, const double * A, double * AT){
 for (int i=0; i < N; i++){
  for (int j=0; j < M; j++){
   AT[i+j*N] = A[j + i*M];
  }
 }
 return;
}

canonical_original_code:
void transpose(int M, int N, double *A, double *AT){
 for (int i = 0; i < N; i++){
  for (int j = 0; j < M; j++){
   AT[i+j*N] = A[j + i*M];
  }
 }
 return;
}

variable_types:
A
double *

variable_types:
AT
double *

variable_types: i int

variable_types: j int


decompiled_code:
void __fastcall svd_gpu(int a1, int a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6)
{
int v6; // er13
int v7; // er14
void *v8; // r15
void *v9; // r14
void *v10; // r12
void *v11; // [rsp+0h] [rbp-B8h]
void *ptr; // [rsp+8h] [rbp-B0h]
unsigned int v15; // [rsp+24h] [rbp-94h]
__int64 v18[6]; // [rsp+40h] [rbp-78h] BYREF
int v19; // [rsp+70h] [rbp-48h]
int v20; // [rsp+74h] [rbp-44h]
int v21; // [rsp+78h] [rbp-40h]

v6 = a1;
if ( a2 <= a1 )
v6 = a2;
v7 = a2 - 1;
if ( a2 > a1 )
v7 = a1;
ptr = malloc(8 * a2 * (__int64)a1);
if ( !ptr )
{
fwrite("in main: failed to allocate AT\n", 1uLL, 0x1FuLL, stderr);
abort();
}
v11 = malloc(8LL * v6);
if ( !v11 )
{
fwrite("in main: failed to allocate alpha\n", 1uLL, 0x22uLL, stderr);
abort();
}
v8 = malloc(8LL * v7);
if ( !v8 )
{
fwrite("in main: failed to allocate beta\n", 1uLL, 0x21uLL, stderr);
abort();
}
v15 = v7 + 1;
v9 = malloc(8LL * v6 * (v7 + 1));
if ( !v9 )
{
fwrite("in main: failed to allocate X\n", 1uLL, 0x1EuLL, stderr);
abort();
}
v10 = malloc(8 * v6 * (__int64)v6);
if ( !v10 )
{
fwrite("in main: failed to allocate Y\n", 1uLL, 0x1EuLL, stderr);
abort();
}
bidiag_par((unsigned int)a1, (unsigned int)a2, a3, v11, v8);
transpose((unsigned int)a1, (unsigned int)a2, a3, ptr);
GetSingularValues_Parallel((unsigned int)v6, v11, v8, a4);
CalcRightSingularVectors((unsigned int)v6, v15, v11, v8, a4, v9);
RighttoLeftSingularVectors((unsigned int)v6, v15, v11, v8, a4, v9, v10);
v18[5] = a3;
v18[4] = (__int64)v10;
v18[3] = (__int64)v9;
v18[2] = (__int64)ptr;
v21 = v6;
v18[1] = a6;
v18[0] = a5;
v20 = a2;
v19 = a1;
GOMP_parallel(svd_gpu__omp_fn_0, v18, 0LL, 0LL);
free(ptr);
free(v11);
free(v8);
free(v9);
free(v10);
}

canonical_decompiled_code:
void __fastcall func1(int a1, int a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6)
{
int v6; // er13
int v7; // er14
void *v8; // r15
void *v9; // r14
void *v10; // r12
void *v11; // [rsp+0h] [rbp-B8h]
void *ptr; // [rsp+8h] [rbp-B0h]
unsigned int v15; // [rsp+24h] [rbp-94h]
__int64 v18[6]; // [rsp+40h] [rbp-78h] BYREF
int v19; // [rsp+70h] [rbp-48h]
int v20; // [rsp+74h] [rbp-44h]
int v21; // [rsp+78h] [rbp-40h]

v6 = a1;
if ( a2 <= a1 )
v6 = a2;
v7 = a2 - 1;
if ( a2 > a1 )
v7 = a1;
ptr = malloc(8 * a2 * (__int64)a1);
if ( !ptr )
{
fwrite("in main: failed to allocate AT\n", 1uLL, 0x1FuLL, stderr);
abort();
}
v11 = malloc(8LL * v6);
if ( !v11 )
{
fwrite("in main: failed to allocate alpha\n", 1uLL, 0x22uLL, stderr);
abort();
}
v8 = malloc(8LL * v7);
if ( !v8 )
{
fwrite("in main: failed to allocate beta\n", 1uLL, 0x21uLL, stderr);
abort();
}
v15 = v7 + 1;
v9 = malloc(8LL * v6 * (v7 + 1));
if ( !v9 )
{
fwrite("in main: failed to allocate X\n", 1uLL, 0x1EuLL, stderr);
abort();
}
v10 = malloc(8 * v6 * (__int64)v6);
if ( !v10 )
{
fwrite("in main: failed to allocate Y\n", 1uLL, 0x1EuLL, stderr);
abort();
}
bidiag_par((unsigned int)a1, (unsigned int)a2, a3, v11, v8);
transpose((unsigned int)a1, (unsigned int)a2, a3, ptr);
GetSingularValues_Parallel((unsigned int)v6, v11, v8, a4);
CalcRightSingularVectors((unsigned int)v6, v15, v11, v8, a4, v9);
RighttoLeftSingularVectors((unsigned int)v6, v15, v11, v8, a4, v9, v10);
v18[5] = a3;
v18[4] = (__int64)v10;
v18[3] = (__int64)v9;
v18[2] = (__int64)ptr;
v21 = v6;
v18[1] = a6;
v18[0] = a5;
v20 = a2;
v19 = a1;
GOMP_parallel(svd_gpu__omp_fn_0, v18, 0LL, 0LL);
free(ptr);
free(v11);
free(v8);
free(v9);
free(v10);
}

original_code:
void svd_gpu(int m, int n, double* A,double * sigma, double * U, double* V){
  timestamp_type time1, time2;
  double elapsed, flops;
  int mn = (m >= n) ? n : m;
  int len_beta = (m >= n) ? n-1 : m;
  double dmn = (double) mn;
  double dm = (double) m;
  double dn = (double) n;
  double * AT = (double *) malloc(sizeof(double) * m *n);
  if(!AT) { fprintf(stderr,"in main: failed to allocate AT\n"); abort();}
  double * alpha = (double *) malloc(sizeof(double) *mn);
  if(!alpha) { fprintf(stderr,"in main: failed to allocate alpha\n"); abort();}
  double *beta = (double *) malloc(sizeof(double) *len_beta);
  if(!beta) { fprintf(stderr,"in main: failed to allocate beta\n"); abort();}
  double *X = (double *) malloc(sizeof(double) *mn*(len_beta + 1));
  if(!X) { fprintf(stderr,"in main: failed to allocate X\n"); abort();}
  double *Y = (double *) malloc(sizeof(double) *mn*mn);
  if(!Y) { fprintf(stderr,"in main: failed to allocate Y\n"); abort();}
  bidiag_par(m,n,A,alpha,beta);
  transpose(m,n,A,AT);
  GetSingularValues_Parallel( mn , alpha, beta, sigma);
  CalcRightSingularVectors(mn,len_beta + 1,alpha,beta,sigma,X);
  RighttoLeftSingularVectors(mn,len_beta + 1,alpha,beta,sigma,X,Y);

#pragma omp parallel for default(shared) firstprivate(A)
  for(int i = 0; i < mn; i++){
      multU(m,n,i,A,Y,U + i*m);
      multV(m,n,i,AT,X,V + i*n);
  }
  free(AT);
  free(alpha);
  free(beta);
  free(X);
  free(Y);
}

canonical_original_code:
void svd_gpu(int m, int n, double *A, double *sigma, double *U, double *V){
  struct timespec time1; struct timespec time2;
  double elapsed; double flops;
  int mn = (m >= n) ? n : m;
  int len_beta = (m >= n) ? n-1 : m;
  double dmn = (double) mn;
  double dm = (double) m;
  double dn = (double) n;
  double *AT = (double *) malloc(sizeof(double) * m *n);
  if(!AT) { fprintf(stderr,"in main: failed to allocate AT\n"); abort();}
  double *alpha = (double *) malloc(sizeof(double) *mn);
  if(!alpha) { fprintf(stderr,"in main: failed to allocate alpha\n"); abort();}
  double *beta = (double *) malloc(sizeof(double) *len_beta);
  if(!beta) { fprintf(stderr,"in main: failed to allocate beta\n"); abort();}
  double *X = (double *) malloc(sizeof(double) *mn*(len_beta + 1));
  if(!X) { fprintf(stderr,"in main: failed to allocate X\n"); abort();}
  double *Y = (double *) malloc(sizeof(double) *mn*mn);
  if(!Y) { fprintf(stderr,"in main: failed to allocate Y\n"); abort();}
  bidiag_par(m,n,A,alpha,beta);
  transpose(m,n,A,AT);
  GetSingularValues_Parallel( mn , alpha, beta, sigma);
  CalcRightSingularVectors(mn,len_beta + 1,alpha,beta,sigma,X);
  RighttoLeftSingularVectors(mn,len_beta + 1,alpha,beta,sigma,X,Y);

#pragma omp parallel for default(shared) firstprivate(A)
  for(int i = 0; i < mn; i++){
      multU(m,n,i,A,Y,U + i*m);
      multV(m,n,i,AT,X,V + i*n);
  }
  free(AT);
  free(alpha);
  free(beta);
  free(X);
  free(Y);
}

variable_types:
sigma
double *

variable_types:
U
double *

variable_types:
V
double *

variable_types: struct timespec { long tv_sec; long tv_nsec; }

variable_types: elapsed double

variable_types: flops double

variable_types: mn int

variable_types: dmn double

variable_types: dm double

variable_types: dn double

variable_types:
X
double *

variable_types:
Y
double *


main

canonical_name: main

repo: sduverger/ld-shatner

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // eax
int v4; // er13
int v5; // ebx
_DWORD *v6; // r12
unsigned __int64 v7; // rbx
int v8; // ebp
__int64 v9; // rax
__int64 v10; // rsi
size_t len; // [rsp+8h] [rbp-40h]

if ( argc == 2 )
{
v3 = open(argv[1], 2, envp);
v4 = v3;
if ( v3 != -1 )
{
v5 = lseek(v3, 0LL, 2);
lseek(v4, 0LL, 0);
len = v5;
v6 = mmap(0LL, v5, 3, 1, v4, 0LL);
v7 = (unsigned int)(v6[7] + (_DWORD)v6);
if ( !*((_WORD *)v6 + 22) )
{
LABEL_12:
munmap(v6, len);
close(v4);
return 0;
}
v8 = 0;
while ( 1 )
{
if ( *(_DWORD *)v7 == 3 )
{
v10 = *(unsigned int *)(v7 + 16);
if ( (unsigned int)v10 <= 0xF )
{
printf("not enough space to fix interp name (%d)\n", v10);
return -1;
}
*(_DWORD *)(v7 + 20) = 16;
*(_DWORD *)(v7 + 16) = 16;
v9 = (unsigned int)(*(_DWORD *)(v7 + 4) + (_DWORD)v6);
*(_QWORD *)(unsigned int)v9 = 0x2D646C2F62696C2FLL;
*(_DWORD *)(v9 + 8) = 1802465128;
*(_WORD *)(v9 + 12) = 29486;
*(_BYTE *)(v9 + 14) = 111;
memset((void *)(unsigned int)((_DWORD)v6 + *(_DWORD *)(v7 + 4) + 15), 0, (unsigned int)(v10 - 16));
}
++v8;
v7 += 32LL;
if ( *((unsigned __int16 *)v6 + 22) <= v8 )
goto LABEL_12;
}
}
printf("can't open file %s\n", argv[1]);
}
else
{
printf("usage: %s <elf>\n", *argv);
v4 = -1;
}
return v4;
}

original_code:
int main(int argc, char **argv)
{
   Elf32_Ehdr *e_hdr;
   Elf32_Phdr *p_hdr;
   int fd, i;
   off_t fd_sz;
   uint32_t len, old;
   if (argc != 2)
   {
      printf("usage: %s <elf>\n", argv[0]);
      return -1;
   }
   if ((fd = open(argv[1], 02)) == -1)
   {
      printf("can't open file %s\n", argv[1]);
      return -1;
   }
   fd_sz = lseek(fd, 0, 2);
   lseek(fd, 0, 0);
   e_hdr = (Elf32_Ehdr*)mmap(((void *)0), fd_sz, 0x1|0x2, 0x01, fd, 0);
   p_hdr = (Elf32_Phdr*)((uint32_t)e_hdr + e_hdr->e_phoff);
   len = strlen("/lib/ld-hook.so")+1;
   for (i=0 ; i<e_hdr->e_phnum ; i++, p_hdr++)
      if (p_hdr->p_type == 3)
      {
  if (p_hdr->p_filesz < len)
  {
     printf("not enough space to fix interp name (%d)\n", p_hdr->p_filesz);
     return -1;
  }
  old = p_hdr->p_filesz;
  p_hdr->p_filesz = p_hdr->p_memsz = len;
  memcpy((void*)((uint32_t)e_hdr+p_hdr->p_offset), "/lib/ld-hook.so", len-1);
  memset((void*)((uint32_t)e_hdr+p_hdr->p_offset+len-1), 0, old-len);
      }
   munmap((void*)e_hdr, fd_sz);
   close(fd);
   return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
   struct Elf32_Ehdr *e_hdr;
   struct Elf32_Phdr *p_hdr;
   int fd; int i;
   long fd_sz;
   unsigned int len; unsigned int old;
   if (argc != 2)
   {
      printf("usage: %s <elf>\n", argv[0]);
      return -1;
   }
   if ((fd = open(argv[1], 02)) == -1)
   {
      printf("can't open file %s\n", argv[1]);
      return -1;
   }
   fd_sz = lseek(fd, 0, 2);
   lseek(fd, 0, 0);
   e_hdr = (struct Elf32_Ehdr *)mmap(((void *)0), fd_sz, 0x1|0x2, 0x01, fd, 0);
   p_hdr = (struct Elf32_Phdr *)((unsigned int)e_hdr + e_hdr->e_phoff);
   len = strlen("/lib/ld-hook.so")+1;
   for (i=0 ; i<e_hdr->e_phnum ; i++, p_hdr++)
      if (p_hdr->p_type == 3)
      {
  if (p_hdr->p_filesz < len)
  {
     printf("not enough space to fix interp name (%d)\n", p_hdr->p_filesz);
     return -1;
  }
  old = p_hdr->p_filesz;
  p_hdr->p_filesz = p_hdr->p_memsz = len;
  memcpy((void *)((unsigned int)e_hdr+p_hdr->p_offset), "/lib/ld-hook.so", len-1);
  memset((void *)((unsigned int)e_hdr+p_hdr->p_offset+len-1), 0, old-len);
      }
   munmap((void *)e_hdr, fd_sz);
   close(fd);
   return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: struct Elf32_Ehdr { unsigned char e_ident[-1]; unsigned short e_type; unsigned short e_machine; unsigned int e_version; unsigned int e_entry; unsigned int e_phoff; unsigned int e_shoff; unsigned int e_flags; unsigned short e_ehsize; unsigned short e_phentsize; unsigned short e_phnum; unsigned short e_shentsize; unsigned short e_shnum; unsigned short e_shstrndx; } *

variable_types: struct Elf32_Phdr { unsigned int p_type; unsigned int p_offset; unsigned int p_vaddr; unsigned int p_paddr; unsigned int p_filesz; unsigned int p_memsz; unsigned int p_flags; unsigned int p_align; } *

variable_types: fd int

variable_types:
len
unsigned int

variable_types:
old
unsigned int


repo: seabat/TohriSDK

decompiled_code:
void *sbt_malloc_init()
{
return memset(&g_allocate_adrs, 0, 0x3E80uLL);
}

canonical_decompiled_code:
void *func0()
{
return memset(&g_allocate_adrs, 0, 0x3E80uLL);
}

original_code:
static void sbt_malloc_init(){
 memset( g_allocate_adrs, 0x00, sizeof(g_allocate_adrs));
}


decompiled_code:
void *__fastcall sbt_malloc(size_t a1)
{
void *v1; // rbp
int v2; // er13
__int64 v3; // rax
__int64 v4; // rbx
__int64 v5; // r13
unsigned int v6; // eax
__int64 v7; // rbx

v1 = malloc(a1);
if ( v1 )
{
v2 = g_sbt_all_alloc_size;
if ( !g_sbt_all_alloc_size )
sbt_malloc_init();
v3 = 0LL;
while ( 1 )
{
v4 = (unsigned int)v3;
if ( !g_allocate_adrs[2 * v3] )
break;
if ( ++v3 == 1000 )
return v1;
}
v5 = (unsigned int)(a1 + v2);
g_sbt_all_alloc_size = v5;
v6 = getpid();
sbt_logln_tofd(
stderr,
"D",
"src/sbt_alloc.c",
"sbt_malloc",
48LL,
v6,
"Add index=%d and address=0x%p => all size=%d ",
v4,
v1,
v5);
v7 = 2LL * (int)v4;
g_allocate_adrs[v7] = (__int64)v1;
LODWORD(qword_4C8[v7]) = a1;
}
return v1;
}

canonical_decompiled_code:
void *__fastcall func1(size_t a1)
{
void *v1; // rbp
int v2; // er13
__int64 v3; // rax
__int64 v4; // rbx
__int64 v5; // r13
unsigned int v6; // eax
__int64 v7; // rbx

v1 = malloc(a1);
if ( v1 )
{
v2 = g_sbt_all_alloc_size;
if ( !g_sbt_all_alloc_size )
func0();
v3 = 0LL;
while ( 1 )
{
v4 = (unsigned int)v3;
if ( !g_allocate_adrs[2 * v3] )
break;
if ( ++v3 == 1000 )
return v1;
}
v5 = (unsigned int)(a1 + v2);
g_sbt_all_alloc_size = v5;
v6 = getpid();
sbt_logln_tofd(
stderr,
"D",
"src/sbt_alloc.c",
"sbt_malloc",
48LL,
v6,
"Add index=%d and address=0x%p => all size=%d ",
v4,
v1,
v5);
v7 = 2LL * (int)v4;
g_allocate_adrs[v7] = (__int64)v1;
LODWORD(qword_4C8[v7]) = a1;
}
return v1;
}

original_code:
void* sbt_malloc(size_t size){
 int i;
 void* adr =((void *)0);
 adr = (void*)malloc(size);
 if( ((void *)0)!=adr ){
  if(0==g_sbt_all_alloc_size){
   sbt_malloc_init();
  }
  for( i=0; i<1000; i++ ){
   if( ((void *)0) == g_allocate_adrs[i].addr ){
    g_sbt_all_alloc_size = g_sbt_all_alloc_size + size;
    if(1) sbt_logln_tofd(stderr, "D", "src/sbt_alloc.c", __func__, 48, getpid(), "Add index=%d and address=0x%p => all size=%d ", i, adr, g_sbt_all_alloc_size);
    g_allocate_adrs[i].addr=(void*)adr;
    g_allocate_adrs[i].size= size;
    break;
   }
  }
 }
 return adr;
}

canonical_original_code:
void *sbt_malloc(unsigned long size){
 int i;
 void *adr = ((void *)0);
 adr = (void *)malloc(size);
 if( ((void *)0)!=adr ){
  if(0==g_sbt_all_alloc_size){
   sbt_malloc_init();
  }
  for( i=0; i<1000; i++ ){
   if( ((void *)0) == g_allocate_adrs[i].addr ){
    g_sbt_all_alloc_size = g_sbt_all_alloc_size + size;
    if(1) sbt_logln_tofd(stderr, "D", "src/sbt_alloc.c", __func__, 48, getpid(), "Add index=%d and address=0x%p => all size=%d ", i, adr, g_sbt_all_alloc_size);
    g_allocate_adrs[i].addr=(void *)adr;
    g_allocate_adrs[i].size= size;
    break;
   }
  }
 }
 return adr;
}

variable_types:
size
unsigned long

variable_types: i int

variable_types:
adr
void *

return_type: void *


decompiled_code:
void __fastcall sbt_free(void *ptr)
{
__int64 v1; // rax
__int64 v2; // rbp
__int64 v3; // r12
__int64 v4; // r13
unsigned int v5; // eax

if ( ptr )
{
v1 = 0LL;
while ( 1 )
{
v2 = (unsigned int)v1;
if ( (void *)g_allocate_adrs[2 * v1] == ptr )
break;
if ( ++v1 == 1000 )
goto LABEL_7;
}
v3 = 2LL * (int)v1;
g_sbt_all_alloc_size -= LODWORD(qword_4C8[v3]);
v4 = (unsigned int)g_sbt_all_alloc_size;
v5 = getpid();
sbt_logln_tofd(
stderr,
"D",
"src/sbt_alloc.c",
"sbt_free",
66LL,
v5,
"Delete index=%d and address=0x%p => all size=%d",
v2,
ptr,
v4);
g_allocate_adrs[v3] = 0LL;
qword_4C8[v3] = 0LL;
LABEL_7:
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func2(void *ptr)
{
__int64 v1; // rax
__int64 v2; // rbp
__int64 v3; // r12
__int64 v4; // r13
unsigned int v5; // eax

if ( ptr )
{
v1 = 0LL;
while ( 1 )
{
v2 = (unsigned int)v1;
if ( (void *)g_allocate_adrs[2 * v1] == ptr )
break;
if ( ++v1 == 1000 )
goto LABEL_7;
}
v3 = 2LL * (int)v1;
g_sbt_all_alloc_size -= LODWORD(qword_4C8[v3]);
v4 = (unsigned int)g_sbt_all_alloc_size;
v5 = getpid();
sbt_logln_tofd(
stderr,
"D",
"src/sbt_alloc.c",
"sbt_free",
66LL,
v5,
"Delete index=%d and address=0x%p => all size=%d",
v2,
ptr,
v4);
g_allocate_adrs[v3] = 0LL;
qword_4C8[v3] = 0LL;
LABEL_7:
free(ptr);
}
}

original_code:
void sbt_free(void *ptr){
 int i;
 if( ((void *)0)!=ptr ){
  for(i=0; i<1000; i++){
   if(g_allocate_adrs[i].addr==(void*)ptr){
    g_sbt_all_alloc_size = g_sbt_all_alloc_size - g_allocate_adrs[i].size;
    if(1) sbt_logln_tofd(stderr, "D", "src/sbt_alloc.c", __func__, 66, getpid(), "Delete index=%d and address=0x%p => all size=%d", i, ptr ,g_sbt_all_alloc_size);
    memset( &g_allocate_adrs[i], 0x00, sizeof(sbt_alloc_st));
    break;
   }
  }
  free(ptr);
 }
}

canonical_original_code:
void sbt_free(void *ptr){
 int i;
 if( ((void *)0)!=ptr ){
  for(i=0; i<1000; i++){
   if(g_allocate_adrs[i].addr==(void *)ptr){
    g_sbt_all_alloc_size = g_sbt_all_alloc_size - g_allocate_adrs[i].size;
    if(1) sbt_logln_tofd(stderr, "D", "src/sbt_alloc.c", __func__, 66, getpid(), "Delete index=%d and address=0x%p => all size=%d", i, ptr ,g_sbt_all_alloc_size);
    memset( &g_allocate_adrs[i], 0x00, sizeof(sbt_alloc_st));
    break;
   }
  }
  free(ptr);
 }
}

variable_types:
ptr
void *