NewNode

original_code:
NodeObj
NewNode(){
 NodeObj temp = malloc (sizeof(node));
 if (temp) {
  temp->name = NewData(0);
  temp->value = NewData(1);
  temp->props = ((void *)0);
  temp->parent = ((void *)0);
  temp->child = ((void *)0);
  temp->nextSib = ((void *)0);
  temp->prevSib = ((void *)0);
 }
 return temp;
}

canonical_original_code:
struct node *NewNode(){
 struct node *temp = malloc (sizeof(node));
 if (temp) {
  temp->name = NewData(0);
  temp->value = NewData(1);
  temp->props = ((void *)0);
  temp->parent = ((void *)0);
  temp->child = ((void *)0);
  temp->nextSib = ((void *)0);
  temp->prevSib = ((void *)0);
 }
 return temp;
}

return_type: struct node { int type; void *name; void *value; struct node *props; struct node *parent; struct node *class; struct node *child; struct node *nextSib; struct node *prevSib; } *


SetName

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

if ( a1 )
{
if ( a2 )
result = SetStr(*(_QWORD *)(a1 + 8));
}
return result;
}

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

if ( a1 )
{
if ( a2 )
result = SetStr(*(_QWORD *)(a1 + 8));
}
return result;
}

original_code:
void
SetName(NodeObj node, char * name){
 if(!node || !name)
  return;
 SetStr(node->name, name);
}

canonical_original_code:
void SetName(struct node *node, char *name){
 if(!node || !name)
  return;
 SetStr(node->name, name);
}

variable_types: struct node { int type; void *name; void *value; struct node *props; struct node *parent; struct node *class; struct node *child; struct node *nextSib; struct node *prevSib; } *

variable_types:
name
char *

return_type: void


CmpName

decompiled_code:
_BOOL8 __fastcall CmpName(__int64 a1, const char *a2)
{
_BOOL8 result; // rax
int v3; // er12
const char *v4; // rax

if ( !a1 )
return 0LL;
result = 0LL;
if ( a2 )
{
v3 = strlen(a2);
v4 = (const char *)GetStr(*(_QWORD *)(a1 + 8));
result = strncmp(v4, a2, v3 + 1) == 0;
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func5(__int64 a1, const char *a2)
{
_BOOL8 result; // rax
int v3; // er12
const char *v4; // rax

if ( !a1 )
return 0LL;
result = 0LL;
if ( a2 )
{
v3 = strlen(a2);
v4 = (const char *)GetStr(*(_QWORD *)(a1 + 8));
result = strncmp(v4, a2, v3 + 1) == 0;
}
return result;
}

original_code:
int
CmpName(NodeObj node, char * name){
 int length;
 if(!node || !name)
  return 0;
 length = strlen(name)+1;
 return (strncmp( GetStr(node->name), name, length ) == 0);
}

canonical_original_code:
int CmpName(struct node *node, char *name){
 int length;
 if(!node || !name)
  return 0;
 length = strlen(name)+1;
 return (strncmp( GetStr(node->name), name, length ) == 0);
}

variable_types: length int

return_type: int

user_defined_types: struct node { int type; void *name; void *value; struct node *props; struct node *parent; struct node *class; struct node *child; struct node *nextSib; struct node *prevSib; }


SetValueStr

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

if ( a1 )
{
if ( a2 )
result = SetStr(*(_QWORD *)(a1 + 16));
}
return result;
}

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

if ( a1 )
{
if ( a2 )
result = SetStr(*(_QWORD *)(a1 + 16));
}
return result;
}

original_code:
void
SetValueStr(NodeObj node, char * value){
 if (!node || !value)
  return;
 SetStr(node->value, value);
}

canonical_original_code:
void SetValueStr(struct node *node, char *value){
 if (!node || !value)
  return;
 SetStr(node->value, value);
}

variable_types:
value
char *


GetValueStr

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

if ( a1 )
result = GetStr(*(_QWORD *)(a1 + 16));
else
result = 0LL;
return result;
}

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

if ( a1 )
result = GetStr(*(_QWORD *)(a1 + 16));
else
result = 0LL;
return result;
}

original_code:
char *
GetValueStr(NodeObj node){
 if (!node)
  return ((void *)0);
 return GetStr(node->value);
}

canonical_original_code:
char *GetValueStr(struct node *node){
 if (!node)
  return ((void *)0);
 return GetStr(node->value);
}

return_type: char *


GetNameStr

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

if ( a1 )
result = GetStr(*(_QWORD *)(a1 + 8));
else
result = 0LL;
return result;
}

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

if ( a1 )
result = GetStr(*(_QWORD *)(a1 + 8));
else
result = 0LL;
return result;
}

original_code:
char *
GetNameStr(NodeObj node){
 if (!node)
  return ((void *)0);
 return GetStr(node->name);
}

canonical_original_code:
char *GetNameStr(struct node *node){
 if (!node)
  return ((void *)0);
 return GetStr(node->name);
}


GetValueInt

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

if ( a1 )
result = GetInt(*(_QWORD *)(a1 + 16));
else
result = 0LL;
return result;
}

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

if ( a1 )
result = GetInt(*(_QWORD *)(a1 + 16));
else
result = 0LL;
return result;
}

original_code:
int
GetValueInt(NodeObj node){
 if (!node)
  return 0;
 return GetInt(node->value);
}

canonical_original_code:
int GetValueInt(struct node *node){
 if (!node)
  return 0;
 return GetInt(node->value);
}


GetValueNode

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

if ( a1 )
result = *(_QWORD *)(a1 + 16);
else
result = 0LL;
return result;
}

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

if ( a1 )
result = *(_QWORD *)(a1 + 16);
else
result = 0LL;
return result;
}

original_code:
DataObj
GetValueNode(NodeObj node){
 if (!node)
  return 0;
 return node->value;
}

canonical_original_code:
void *GetValueNode(struct node *node){
 if (!node)
  return 0;
 return node->value;
}

return_type: void *


SetParent

decompiled_code:
void __fastcall SetParent(__int64 a1, __int64 a2)
{
if ( a1 )
{
if ( a2 )
*(_QWORD *)(a2 + 32) = a1;
}
}

original_code:
void
SetParent (NodeObj parent, NodeObj child){
 if(!parent || !child)
  return;
 child->parent=parent;
}

canonical_original_code:
void SetParent(struct node *parent, struct node *child){
 if(!parent || !child)
  return;
 child->parent=parent;
}

variable_types:
child
struct node *


SetChild

decompiled_code:
void __fastcall SetChild(__int64 a1, __int64 a2)
{
if ( a1 )
{
if ( a2 )
{
DelNode_localalias(*(void **)(a1 + 48));
*(_QWORD *)(a1 + 48) = a2;
*(_QWORD *)(a2 + 32) = a1;
}
}
}

original_code:
void
SetChild (NodeObj node, NodeObj child){
 if(!node || !child)
  return;
 DelNode(node->child);
 node->child=child;
 child->parent=node;
}

canonical_original_code:
void SetChild(struct node *node, struct node *child){
 if(!node || !child)
  return;
 DelNode(node->child);
 node->child=child;
 child->parent=node;
}


DelSibling

decompiled_code:
void DelSibling()
{
;
}

canonical_decompiled_code:
void func13()
{
;
}

original_code:
void
DelSibling (NodeObj sib){
 if(!sib)
  return;
 if (sib->nextSib){
 }
}

canonical_original_code:
void DelSibling(struct node *sib){
 if(!sib)
  return;
 if (sib->nextSib){
 }
}


GetPropNode

decompiled_code:
__int64 __fastcall GetPropNode(__int64 a1, const char *a2)
{
__int64 v2; // r12

if ( !a1 )
return 0LL;
if ( !a2 )
return 0LL;
v2 = *(_QWORD *)(a1 + 24);
if ( !v2 )
return 0LL;
while ( !CmpName(v2, a2) )
{
v2 = *(_QWORD *)(v2 + 56);
if ( !v2 )
return 0LL;
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func16(__int64 a1, const char *a2)
{
__int64 v2; // r12

if ( !a1 )
return 0LL;
if ( !a2 )
return 0LL;
v2 = *(_QWORD *)(a1 + 24);
if ( !v2 )
return 0LL;
while ( !func5(v2, a2) )
{
v2 = *(_QWORD *)(v2 + 56);
if ( !v2 )
return 0LL;
}
return v2;
}

original_code:
NodeObj
GetPropNode(NodeObj node, char * name){
 if (!node || !name)
  return ((void *)0);
 NodeObj current = node->props;
 while (current){
  if (CmpName(current, name))
   return current;
  current=current->nextSib;
 }
 return ((void *)0);
}

canonical_original_code:
struct node *GetPropNode(struct node *node, char *name){
 if (!node || !name)
  return ((void *)0);
 struct node *current = node->props;
 while (current){
  if (CmpName(current, name))
   return current;
  current=current->nextSib;
 }
 return ((void *)0);
}

variable_types:
node
struct node *


SetPropInt

decompiled_code:
void __fastcall SetPropInt(__int64 a1, const char *a2, unsigned int a3)
{
__int64 v5; // rax
__int64 v6; // r13
__int64 v7; // r14
_QWORD *v8; // r15
__int64 v9; // rax
void (__fastcall *v10)(__int64, _QWORD *, _QWORD); // rbx
__int64 v11; // rax
_QWORD *v12; // r13
__int64 v13; // rdi

if ( a1 && a2 )
{
v5 = GetPropNode(a1, a2);
v6 = v5;
if ( v5 )
{
v7 = GetPropNode(v5, "Intercept");
if ( v7
&& (v8 = NewNode(),
SetStr(v8[1]),
SetInt(v8[2], a3),
v9 = GetPropNode(v7, "Callback"),
v10 = (void (__fastcall *)(__int64, _QWORD *, _QWORD))(int)GetValueInt(v9),
v11 = GetPropNode(v7, "Current"),
v10)
&& v11 )
{
v10(v11, v8, 0LL);
}
else
{
SetInt(*(_QWORD *)(v6 + 16), a3);
}
}
else
{
v12 = NewNode();
SetStr(v12[1]);
SetInt(v12[2], a3);
v13 = *(_QWORD *)(a1 + 24);
if ( v13 )
{
AddSibling(v13, v12);
}
else
{
*(_QWORD *)(a1 + 24) = v12;
v12[4] = a1;
}
}
}
}

original_code:
void
SetPropInt(NodeObj node, char * name, int value){
 NodeObj propnode;
 if (!node || !name)
  return;
 if ((propnode=GetPropNode(node, name))){
  NodeObj intercept = GetPropNode(propnode, "Intercept");
  if(intercept){
   NodeObj newpropnode;
   newpropnode = NewNode();
   SetStr(newpropnode->name, name);
   SetInt(newpropnode->value, value);
   FuncPtr callback = (FuncPtr)GetValueInt(GetPropNode(intercept, "Callback"));
   NodeObj current = GetPropNode(intercept, "Current");
   if (!callback || ! current){
    SetInt(propnode->value, value);
   } else {
    (*callback)(current, newpropnode, msg_change);
   }
  } else {
   SetInt(propnode->value, value);
  }
 } else {
  propnode = NewNode();
  SetStr(propnode->name, name);
  SetInt(propnode->value, value);
  if (node->props){
   AddSibling(node->props, propnode);
  } else {
   node->props = propnode;
   propnode->parent = node;
  }
 }
}

canonical_original_code:
void SetPropInt(struct node *node, char *name, int value){
 struct node *propnode;
 if (!node || !name)
  return;
 if ((propnode=GetPropNode(node, name))){
  struct node *intercept = GetPropNode(propnode, "Intercept");
  if(intercept){
   struct node *newpropnode;
   newpropnode = NewNode();
   SetStr(newpropnode->name, name);
   SetInt(newpropnode->value, value);
   int (*callback)(struct node *, struct node *, int) = (FuncPtr)GetValueInt(GetPropNode(intercept, "Callback"));
   struct node *current = GetPropNode(intercept, "Current");
   if (!callback || ! current){
    SetInt(propnode->value, value);
   } else {
    (*callback)(current, newpropnode, msg_change);
   }
  } else {
   SetInt(propnode->value, value);
  }
 } else {
  propnode = NewNode();
  SetStr(propnode->name, name);
  SetInt(propnode->value, value);
  if (node->props){
   AddSibling(node->props, propnode);
  } else {
   node->props = propnode;
   propnode->parent = node;
  }
 }
}

variable_types: value int

variable_types: int (*)(struct node { int type; void *name; void *value; struct node *props; struct node *parent; struct node *class; struct node *child; struct node *nextSib; struct node *prevSib; } *, struct node *, int)


SetPropStr

decompiled_code:
void __fastcall SetPropStr(__int64 a1, const char *a2)
{
__int64 v3; // rax
__int64 v4; // r12
_QWORD *v5; // r12
__int64 v6; // rdi

if ( a1 && a2 )
{
v3 = GetPropNode(a1, a2);
v4 = v3;
if ( v3 )
{
if ( !GetPropNode(v3, "Intercept") )
SetStr(*(_QWORD *)(v4 + 16));
}
else
{
v5 = NewNode();
SetStr(v5[1]);
SetStr(v5[2]);
v6 = *(_QWORD *)(a1 + 24);
if ( v6 )
{
AddSibling(v6, v5);
}
else
{
*(_QWORD *)(a1 + 24) = v5;
v5[4] = a1;
}
}
}
}

original_code:
void
SetPropStr(NodeObj node, char * name, char * value){
 NodeObj propnode;
 if (!node || !name)
  return;
 if ((propnode=GetPropNode(node, name))){
  NodeObj intercept = GetPropNode(propnode, "Intercept");
  if(intercept){
  } else
  SetStr(propnode->value, value);
 } else {
  propnode = NewNode();
  SetStr(propnode->name, name);
  SetStr(propnode->value, value);
  if (node->props){
   AddSibling(node->props, propnode);
  } else {
   node->props = propnode;
   propnode->parent = node;
  }
 }
}

canonical_original_code:
void SetPropStr(struct node *node, char *name, char *value){
 struct node *propnode;
 if (!node || !name)
  return;
 if ((propnode=GetPropNode(node, name))){
  struct node *intercept = GetPropNode(propnode, "Intercept");
  if(intercept){
  } else
  SetStr(propnode->value, value);
 } else {
  propnode = NewNode();
  SetStr(propnode->name, name);
  SetStr(propnode->value, value);
  if (node->props){
   AddSibling(node->props, propnode);
  } else {
   node->props = propnode;
   propnode->parent = node;
  }
 }
}


TestFunc

decompiled_code:
int __fastcall TestFunc(_QWORD *a1)
{
_BOOL4 v1; // eax
_BOOL4 v2; // eax
__int64 v3; // rax
unsigned int v4; // eax

puts("\n\nRunning tests\n");
puts("Set name of root to Test.");
SetName((__int64)a1, (__int64)"Test");
v1 = CmpName((__int64)a1, "Test");
printf("Is name of root Test? %d\n", v1);
v2 = CmpName((__int64)a1, "Banana");
printf("Is name of root Banana? %d\n", v2);
puts("Set property on root named Banana, set value to 5.");
SetPropInt((__int64)a1, "Banana", 5u);
v3 = GetPropNode((__int64)a1, "Banana");
v4 = GetValueInt(v3);
printf("The value of Banana is %d\n", v4);
puts("Check root for non exisitant property Fred.");
if ( GetPropNode((__int64)a1, "Fred") )
puts("Fred Exists.");
else
puts("Fred property does not exist.");
puts("Set another property on root to be Fred with value of 6.");
SetPropInt((__int64)a1, "Fred", 6u);
if ( GetPropNode((__int64)a1, "Fred") )
puts("Fred Exists.");
else
puts("Fred property does not exist.");
return PrintNode(a1);
}

canonical_decompiled_code:
int __fastcall func19(_QWORD *a1)
{
_BOOL4 v1; // eax
_BOOL4 v2; // eax
__int64 v3; // rax
unsigned int v4; // eax

puts("\n\nRunning tests\n");
puts("Set name of root to Test.");
func4((__int64)a1, (__int64)"Test");
v1 = func5((__int64)a1, "Test");
printf("Is name of root Test? %d\n", v1);
v2 = func5((__int64)a1, "Banana");
printf("Is name of root Banana? %d\n", v2);
puts("Set property on root named Banana, set value to 5.");
func17((__int64)a1, "Banana", 5u);
v3 = func16((__int64)a1, "Banana");
v4 = func9(v3);
printf("The value of Banana is %d\n", v4);
puts("Check root for non exisitant property Fred.");
if ( func16((__int64)a1, "Fred") )
puts("Fred Exists.");
else
puts("Fred property does not exist.");
puts("Set another property on root to be Fred with value of 6.");
func17((__int64)a1, "Fred", 6u);
if ( func16((__int64)a1, "Fred") )
puts("Fred Exists.");
else
puts("Fred property does not exist.");
return func1(a1);
}

original_code:
void
TestFunc(NodeObj node){
 printf("\n\nRunning tests\n\n");
 printf("Set name of root to Test.\n");
 SetName(node, "Test");
 printf("Is name of root Test?  %d\n", CmpName(node, "Test"));
 printf("Is name of root Banana?  %d\n", CmpName(node, "Banana"));
 printf("Set property on root named Banana, set value to 5.\n");
 SetPropInt(node, "Banana", 5);
 printf("The value of Banana is %d\n", GetValueInt(GetPropNode(node, "Banana")));
 printf("Check root for non exisitant property Fred.\n");
 if (GetPropNode(node, "Fred"))
  printf("Fred Exists.\n");
 else
  printf("Fred property does not exist.\n");
 printf("Set another property on root to be Fred with value of 6.\n");
 SetPropInt(node, "Fred", 6);
 if (GetPropNode(node, "Fred"))
  printf("Fred Exists.\n");
 else
  printf("Fred property does not exist.\n");
 PrintNode(node);
}

canonical_original_code:
void TestFunc(struct node *node){
 printf("\n\nRunning tests\n\n");
 printf("Set name of root to Test.\n");
 SetName(node, "Test");
 printf("Is name of root Test?  %d\n", CmpName(node, "Test"));
 printf("Is name of root Banana?  %d\n", CmpName(node, "Banana"));
 printf("Set property on root named Banana, set value to 5.\n");
 SetPropInt(node, "Banana", 5);
 printf("The value of Banana is %d\n", GetValueInt(GetPropNode(node, "Banana")));
 printf("Check root for non exisitant property Fred.\n");
 if (GetPropNode(node, "Fred"))
  printf("Fred Exists.\n");
 else
  printf("Fred property does not exist.\n");
 printf("Set another property on root to be Fred with value of 6.\n");
 SetPropInt(node, "Fred", 6);
 if (GetPropNode(node, "Fred"))
  printf("Fred Exists.\n");
 else
  printf("Fred property does not exist.\n");
 PrintNode(node);
}


NodeTest

decompiled_code:
int NodeTest()
{
_QWORD *v0; // rbp

v0 = NewNode();
TestFunc(v0);
DelNode_localalias(v0);
return TestFunc(0LL);
}

canonical_decompiled_code:
int func20()
{
_QWORD *v0; // rbp

v0 = func3();
func19(v0);
func2(v0);
return func19(0LL);
}

original_code:
void
NodeTest (){
 NodeObj root = ((void *)0);
 int i;
 for (i=0; i < 1; i++){
  root = NewNode();
  TestFunc(root);
  DelNode(root);
  root=((void *)0);
  TestFunc(root);
 }
}

canonical_original_code:
void NodeTest(){
 struct node *root = ((void *)0);
 int i;
 for (i=0; i < 1; i++){
  root = NewNode();
  TestFunc(root);
  DelNode(root);
  root=((void *)0);
  TestFunc(root);
 }
}

variable_types: i int


decompiled_code:
char *__fastcall Real2Str(double a1)
{
char *v1; // rax
char *v2; // r12

v1 = (char *)malloc(0xDuLL);
v2 = v1;
if ( v1 )
sprintf(v1, "%f", a1);
return v2;
}

canonical_decompiled_code:
char *__fastcall func0(double a1)
{
char *v1; // rax
char *v2; // r12

v1 = (char *)malloc(0xDuLL);
v2 = v1;
if ( v1 )
sprintf(v1, "%f", a1);
return v2;
}

original_code:
char *
Real2Str(double val){
 char * ret_val = malloc(13);
 if (!ret_val)
  return ((void *)0);
 sprintf(ret_val, "%f", val);
 return ret_val;
}

canonical_original_code:
char *Real2Str(double val){
 char *ret_val = malloc(13);
 if (!ret_val)
  return ((void *)0);
 sprintf(ret_val, "%f", val);
 return ret_val;
}

variable_types: val double


decompiled_code:
char *__fastcall Int2Hex(unsigned int a1)
{
char *v1; // rax
char *v2; // r12

v1 = (char *)malloc(0xAuLL);
v2 = v1;
if ( v1 )
sprintf(v1, "%x", a1);
return v2;
}

canonical_decompiled_code:
char *__fastcall func1(unsigned int a1)
{
char *v1; // rax
char *v2; // r12

v1 = (char *)malloc(0xAuLL);
v2 = v1;
if ( v1 )
sprintf(v1, "%x", a1);
return v2;
}

original_code:
char *
Int2Hex(int val){
 char * ret_val = malloc(10);
 if (!ret_val)
  return ((void *)0);
 sprintf(ret_val, "%x", val);
 return ret_val;
}

canonical_original_code:
char *Int2Hex(int val){
 char *ret_val = malloc(10);
 if (!ret_val)
  return ((void *)0);
 sprintf(ret_val, "%x", val);
 return ret_val;
}

variable_types: val int


decompiled_code:
__int64 __fastcall Hex2Int(_BYTE *a1)
{
_BYTE *v1; // rbp
int v2; // ebx
const unsigned __int16 *v3; // rsi
__int64 result; // rax
int v5; // eax
unsigned int v6; // ecx
unsigned __int16 v7; // dx

if ( !a1 )
return 0LL;
v1 = a1;
v2 = (char)*a1;
if ( !*a1 )
return 0LL;
v3 = *_ctype_b_loc();
result = 0LL;
do
{
v7 = v3[(char)v2];
if ( (v7 & 0x1000) == 0 )
break;
v5 = v2 + 16 * result;
v6 = v5 - 48;
result = (unsigned int)(v5 - 55);
if ( (v7 & 0x800) != 0 )
result = v6;
v2 = (char)*++v1;
}
while ( (_BYTE)v2 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(_BYTE *a1)
{
_BYTE *v1; // rbp
int v2; // ebx
const unsigned __int16 *v3; // rsi
__int64 result; // rax
int v5; // eax
unsigned int v6; // ecx
unsigned __int16 v7; // dx

if ( !a1 )
return 0LL;
v1 = a1;
v2 = (char)*a1;
if ( !*a1 )
return 0LL;
v3 = *_ctype_b_loc();
result = 0LL;
do
{
v7 = v3[(char)v2];
if ( (v7 & 0x1000) == 0 )
break;
v5 = v2 + 16 * result;
v6 = v5 - 48;
result = (unsigned int)(v5 - 55);
if ( (v7 & 0x800) != 0 )
result = v6;
v2 = (char)*++v1;
}
while ( (_BYTE)v2 );
return result;
}

original_code:
int
Hex2Int(char * val){
 int ret_val = 0;
 if (!val)
  return 0;
 while(val[0] && ((*__ctype_b_loc ())[(int) ((val[0]))] & (unsigned short int) _ISxdigit)){
  if (((*__ctype_b_loc ())[(int) ((val[0]))] & (unsigned short int) _ISdigit))
   ret_val = ret_val * 16 + val[0] - '0';
  else
   ret_val = ret_val * 16 + val[0] -'A' + 10;
  val++;
 }
 return ret_val;
}

canonical_original_code:
int Hex2Int(char *val){
 int ret_val = 0;
 if (!val)
  return 0;
 while(val[0] && ((*__ctype_b_loc ())[(int) ((val[0]))] & (unsigned short) _ISxdigit)){
  if (((*__ctype_b_loc ())[(int) ((val[0]))] & (unsigned short) _ISdigit))
   ret_val = ret_val * 16 + val[0] - '0';
  else
   ret_val = ret_val * 16 + val[0] -'A' + 10;
  val++;
 }
 return ret_val;
}

variable_types:
val
char *


decompiled_code:
char *__fastcall Int2Str(unsigned int a1)
{
char *v1; // rax
char *v2; // r12

v1 = (char *)malloc(0xAuLL);
v2 = v1;
if ( v1 )
sprintf(v1, "%d", a1);
return v2;
}

canonical_decompiled_code:
char *__fastcall func3(unsigned int a1)
{
char *v1; // rax
char *v2; // r12

v1 = (char *)malloc(0xAuLL);
v2 = v1;
if ( v1 )
sprintf(v1, "%d", a1);
return v2;
}

original_code:
char * Int2Str(int val){
 char * ret_val = malloc(10);
 if (!ret_val)
  return ((void *)0);
 sprintf(ret_val, "%d", val);
 return ret_val;
}

canonical_original_code:
char *Int2Str(int val){
 char *ret_val = malloc(10);
 if (!ret_val)
  return ((void *)0);
 sprintf(ret_val, "%d", val);
 return ret_val;
}


decompiled_code:
__int64 __fastcall Str2Int(char *a1)
{
_BYTE *v1; // rbx
__int64 v2; // rbp
const unsigned __int16 *v3; // rdx
int v4; // eax
unsigned int i; // er8

if ( !a1 )
return 0LL;
v1 = a1;
v2 = *a1;
if ( !(_BYTE)v2 )
return 0LL;
v3 = *_ctype_b_loc();
while ( (v3[v2] & 0x2000) != 0 )
{
v2 = (char)*++v1;
if ( !(_BYTE)v2 )
return 0LL;
}
v4 = (char)*v1;
for ( i = 0; *v1; v4 = (char)*v1 )
{
if ( (v3[(char)v4] & 0x800) == 0 )
break;
++v1;
i = v4 + 10 * i - 48;
}
return i;
}

canonical_decompiled_code:
__int64 __fastcall func4(char *a1)
{
_BYTE *v1; // rbx
__int64 v2; // rbp
const unsigned __int16 *v3; // rdx
int v4; // eax
unsigned int i; // er8

if ( !a1 )
return 0LL;
v1 = a1;
v2 = *a1;
if ( !(_BYTE)v2 )
return 0LL;
v3 = *_ctype_b_loc();
while ( (v3[v2] & 0x2000) != 0 )
{
v2 = (char)*++v1;
if ( !(_BYTE)v2 )
return 0LL;
}
v4 = (char)*v1;
for ( i = 0; *v1; v4 = (char)*v1 )
{
if ( (v3[(char)v4] & 0x800) == 0 )
break;
++v1;
i = v4 + 10 * i - 48;
}
return i;
}

original_code:
int Str2Int(char * val){
 int ret_val=0;
 if (!val)
  return 0;
 while(val[0] && ((*__ctype_b_loc ())[(int) ((val[0]))] & (unsigned short int) _ISspace)){
  val++;
 }
 while(val[0] && ((*__ctype_b_loc ())[(int) ((val[0]))] & (unsigned short int) _ISdigit)){
  ret_val=ret_val*10+val[0]-'0';
  val++;
 }
 return ret_val;
}

canonical_original_code:
int Str2Int(char *val){
 int ret_val = 0;
 if (!val)
  return 0;
 while(val[0] && ((*__ctype_b_loc ())[(int) ((val[0]))] & (unsigned short) _ISspace)){
  val++;
 }
 while(val[0] && ((*__ctype_b_loc ())[(int) ((val[0]))] & (unsigned short) _ISdigit)){
  ret_val=ret_val*10+val[0]-'0';
  val++;
 }
 return ret_val;
}


dup

decompiled_code:
char *__fastcall dup(char *src)
{
size_t v1; // r12
char *v2; // rax
char *v3; // r8

if ( !src )
return 0LL;
v1 = (int)(strlen(src) + 1);
v2 = (char *)malloc(v1);
v3 = v2;
if ( v2 )
v3 = strncpy(v2, src, v1);
return v3;
}

canonical_decompiled_code:
char *__fastcall func5(char *src)
{
size_t v1; // r12
char *v2; // rax
char *v3; // r8

if ( !src )
return 0LL;
v1 = (int)(strlen(src) + 1);
v2 = (char *)malloc(v1);
v3 = v2;
if ( v2 )
v3 = strncpy(v2, src, v1);
return v3;
}

original_code:
char * dup (char * val){
 int length;
 char * ret_val = ((void *)0);
 if (val == ((void *)0))
  return ((void *)0);
 length = strlen (val);
 ret_val = malloc (length+1);
 if (!ret_val)
  return ((void *)0);
 strncpy(ret_val, val, length+1);
 return ret_val;
}

canonical_original_code:
char *dup(char *val){
 int length;
 char *ret_val = ((void *)0);
 if (val == ((void *)0))
  return ((void *)0);
 length = strlen (val);
 ret_val = malloc (length+1);
 if (!ret_val)
  return ((void *)0);
 strncpy(ret_val, val, length+1);
 return ret_val;
}


clear

original_code:
void clear (DataObj this){
 this->str_set=0;
 this->str_val=((void *)0);
 this->int_set=0;
 this->int_val=0;
 this->hex_set=0;
 this->hex_val=((void *)0);
 this->real_set = 0;
 this->real_val = 0;
}

canonical_original_code:
void clear(struct Data *this){
 this->str_set=0;
 this->str_val=((void *)0);
 this->int_set=0;
 this->int_val=0;
 this->hex_set=0;
 this->hex_val=((void *)0);
 this->real_set = 0;
 this->real_val = 0;
}

variable_types: struct Data { int type; int (*call)(struct Data *, int, int, char *); int str_set; char *str_val; int int_set; int int_val; int hex_set; char *hex_val; int real_set; double real_val; } *


clearAll

decompiled_code:
void __fastcall clearAll(__int64 a1)
{
void *v2; // rdi
void *v3; // rdi

v2 = *(void **)(a1 + 24);
if ( v2 )
free(v2);
v3 = *(void **)(a1 + 48);
if ( v3 )
free(v3);
clear(a1);
}

canonical_decompiled_code:
void __fastcall func7(__int64 a1)
{
void *v2; // rdi
void *v3; // rdi

v2 = *(void **)(a1 + 24);
if ( v2 )
free(v2);
v3 = *(void **)(a1 + 48);
if ( v3 )
free(v3);
func6(a1);
}

original_code:
void clearAll (DataObj this){
 if (this->str_val)
  free(this->str_val);
 if (this->hex_val)
  free(this->hex_val);
 clear(this);
}

canonical_original_code:
void clearAll(struct Data *this){
 if (this->str_val)
  free(this->str_val);
 if (this->hex_val)
  free(this->hex_val);
 clear(this);
}

user_defined_types: struct Data { int type; int (*call)(struct Data *, int, int, char *); int str_set; char *str_val; int int_set; int int_val; int hex_set; char *hex_val; int real_set; double real_val; }


datafunc

decompiled_code:
__int64 __fastcall datafunc(__int64 a1, int a2, int a3, char *a4)
{
__int64 result; // rax
__int64 v7; // xmm0_8
char *v8; // rax
char *v9; // rax

if ( a2 != 1 )
{
clearAll(a1);
if ( a3 == 2 )
{
v9 = dup(a4);
*(_QWORD *)(a1 + 48) = v9;
if ( v9 )
{
*(_DWORD *)(a1 + 40) = 1;
return 1LL;
}
}
else if ( a3 > 2 )
{
if ( a3 == 3 )
{
v7 = *(_QWORD *)a4;
result = 1LL;
*(_DWORD *)(a1 + 56) = 1;
*(_QWORD *)(a1 + 64) = v7;
return result;
}
}
else if ( a3 )
{
if ( a3 == 1 )
{
*(_DWORD *)(a1 + 36) = (_DWORD)a4;
result = 1LL;
*(_DWORD *)(a1 + 32) = 1;
return result;
}
}
else
{
v8 = dup(a4);
*(_QWORD *)(a1 + 24) = v8;
if ( v8 )
{
*(_DWORD *)(a1 + 16) = 1;
return 1LL;
}
}
return 0LL;
}
if ( a3 == 2 )
{
if ( !*(_DWORD *)(a1 + 40) )
convert_localalias(a1, 2);
result = *(unsigned int *)(a1 + 48);
}
else if ( a3 > 2 )
{
if ( a3 != 3 )
return 0LL;
if ( !*(_DWORD *)(a1 + 56) )
convert_localalias(a1, 3);
result = (unsigned int)(a1 + 64);
}
else
{
if ( a3 )
{
if ( a3 == 1 )
{
if ( !*(_DWORD *)(a1 + 32) )
convert_localalias(a1, 1);
return *(unsigned int *)(a1 + 36);
}
return 0LL;
}
if ( !*(_DWORD *)(a1 + 16) )
convert_localalias(a1, 0);
result = *(unsigned int *)(a1 + 24);
}
return result;
}

original_code:
int datafunc(DataObj this, int kind, int type, char * val){
 if (kind == 1){
  switch (type) {
  case 1:
   if (!this->int_set) {
    convert(this, 1);
   }
   return this->int_val;
  case 0:
   if (!this->str_set){
    convert(this, 0);
   }
   return (int)this->str_val;
  case 2:
   if (!this->hex_set){
    convert(this, 2);
   }
   return (int)this->hex_val;
  case 3:
   if (!this->real_set){
    convert(this, 3);
   }
   return (int)&this->real_val;
  default:
   return 0;
  }
 } else {
  clearAll(this);
  switch (type){
  case 1:
   this->int_val=(int)val;
   this->int_set=1;
   return 1;
  case 0:
   this->str_val = dup(val);
   if (!this->str_val)
    return 0;
   this->str_set = 1;
   return 1;
  case 2:
   this->hex_val = dup(val);
   if (!this->hex_val)
    return 0;
   this->hex_set = 1;
   return 1;
  case 3:
   this->real_val = *(double*)val;
   this->real_set = 1;
   return 1;
  default:
   return 0;
  }
 }
 return 1;
}

canonical_original_code:
int datafunc(struct Data *this, int kind, int type, char *val){
 if (kind == 1){
  switch (type) {
  case 1:
   if (!this->int_set) {
    convert(this, 1);
   }
   return this->int_val;
  case 0:
   if (!this->str_set){
    convert(this, 0);
   }
   return (int)this->str_val;
  case 2:
   if (!this->hex_set){
    convert(this, 2);
   }
   return (int)this->hex_val;
  case 3:
   if (!this->real_set){
    convert(this, 3);
   }
   return (int)&this->real_val;
  default:
   return 0;
  }
 } else {
  clearAll(this);
  switch (type){
  case 1:
   this->int_val=(int)val;
   this->int_set=1;
   return 1;
  case 0:
   this->str_val = dup(val);
   if (!this->str_val)
    return 0;
   this->str_set = 1;
   return 1;
  case 2:
   this->hex_val = dup(val);
   if (!this->hex_val)
    return 0;
   this->hex_set = 1;
   return 1;
  case 3:
   this->real_val = *(double *)val;
   this->real_set = 1;
   return 1;
  default:
   return 0;
  }
 }
 return 1;
}

variable_types: kind int

variable_types: type int


GetStr

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

if ( a1 )
result = (*(int (__fastcall **)(__int64, __int64, _QWORD, _QWORD))(a1 + 8))(a1, 1LL, 0LL, 0LL);
else
result = 0LL;
return result;
}

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

if ( a1 )
result = (*(int (__fastcall **)(__int64, __int64, _QWORD, _QWORD))(a1 + 8))(a1, 1LL, 0LL, 0LL);
else
result = 0LL;
return result;
}

original_code:
char *
GetStr(DataObj this){
 if (!this)
  return 0;
 return (char *)this->call(this, 1, 0, ((void *)0));
}

canonical_original_code:
char *GetStr(struct Data *this){
 if (!this)
  return 0;
 return (char *)this->call(this, 1, 0, ((void *)0));
}


SetStr

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

if ( a1 )
result = (*(__int64 (__fastcall **)(__int64, _QWORD, _QWORD, __int64))(a1 + 8))(a1, 0LL, 0LL, a2);
else
result = 0LL;
return result;
}

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

if ( a1 )
result = (*(__int64 (__fastcall **)(__int64, _QWORD, _QWORD, __int64))(a1 + 8))(a1, 0LL, 0LL, a2);
else
result = 0LL;
return result;
}

original_code:
int
SetStr(DataObj this, char * value){
 if (!this)
  return 0;
 return this->call(this, 0, 0, value);
}

canonical_original_code:
int SetStr(struct Data *this, char *value){
 if (!this)
  return 0;
 return this->call(this, 0, 0, value);
}


SetInt

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

if ( a1 )
result = (*(__int64 (__fastcall **)(__int64, _QWORD, __int64, _QWORD))(a1 + 8))(a1, 0LL, 1LL, a2);
else
result = 0LL;
return result;
}

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

if ( a1 )
result = (*(__int64 (__fastcall **)(__int64, _QWORD, __int64, _QWORD))(a1 + 8))(a1, 0LL, 1LL, a2);
else
result = 0LL;
return result;
}

original_code:
int
SetInt(DataObj this, int value){
 if (!this)
  return 0;
 return this->call(this, 0, 1, (char *)value);
}

canonical_original_code:
int SetInt(struct Data *this, int value){
 if (!this)
  return 0;
 return this->call(this, 0, 1, (char *)value);
}


GetInt

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

if ( a1 )
result = (*(__int64 (__fastcall **)(__int64, __int64, __int64, _QWORD))(a1 + 8))(a1, 1LL, 1LL, 0LL);
else
result = 0LL;
return result;
}

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

if ( a1 )
result = (*(__int64 (__fastcall **)(__int64, __int64, __int64, _QWORD))(a1 + 8))(a1, 1LL, 1LL, 0LL);
else
result = 0LL;
return result;
}

original_code:
int
GetInt(DataObj this){
 if (!this)
  return 0;
 return this->call(this, 1, 1, ((void *)0));
}

canonical_original_code:
int GetInt(struct Data *this){
 if (!this)
  return 0;
 return this->call(this, 1, 1, ((void *)0));
}


SetHex

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

if ( a1 )
result = (*(__int64 (__fastcall **)(__int64, _QWORD, __int64, __int64))(a1 + 8))(a1, 0LL, 2LL, a2);
else
result = 0LL;
return result;
}

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

if ( a1 )
result = (*(__int64 (__fastcall **)(__int64, _QWORD, __int64, __int64))(a1 + 8))(a1, 0LL, 2LL, a2);
else
result = 0LL;
return result;
}

original_code:
int
SetHex(DataObj this, char * value){
 if (!this)
  return 0;
 return this->call(this, 0, 2, (char *)value);
}

canonical_original_code:
int SetHex(struct Data *this, char *value){
 if (!this)
  return 0;
 return this->call(this, 0, 2, (char *)value);
}


GetHex

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

if ( a1 )
result = (*(int (__fastcall **)(__int64, __int64, __int64, _QWORD))(a1 + 8))(a1, 1LL, 2LL, 0LL);
else
result = 0LL;
return result;
}

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

if ( a1 )
result = (*(int (__fastcall **)(__int64, __int64, __int64, _QWORD))(a1 + 8))(a1, 1LL, 2LL, 0LL);
else
result = 0LL;
return result;
}

original_code:
char *
GetHex(DataObj this){
 if (!this)
  return 0;
 return (char *)this->call(this, 1, 2, ((void *)0));
}

canonical_original_code:
char *GetHex(struct Data *this){
 if (!this)
  return 0;
 return (char *)this->call(this, 1, 2, ((void *)0));
}


SetReal

decompiled_code:
__int64 __fastcall SetReal(__int64 a1, double a2)
{
__int64 result; // rax
double v3[2]; // [rsp+8h] [rbp-10h] BYREF

v3[0] = a2;
if ( a1 )
result = (*(__int64 (__fastcall **)(__int64, _QWORD, __int64, double *))(a1 + 8))(a1, 0LL, 3LL, v3);
else
result = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func17(__int64 a1, double a2)
{
__int64 result; // rax
double v3[2]; // [rsp+8h] [rbp-10h] BYREF

v3[0] = a2;
if ( a1 )
result = (*(__int64 (__fastcall **)(__int64, _QWORD, __int64, double *))(a1 + 8))(a1, 0LL, 3LL, v3);
else
result = 0LL;
return result;
}

original_code:
int
SetReal(DataObj this, double value){
 if (!this)
  return 0;
 return this->call(this, 0, 3, (char *)&value);
}

canonical_original_code:
int SetReal(struct Data *this, double value){
 if (!this)
  return 0;
 return this->call(this, 0, 3, (char *)&value);
}

variable_types: value double


GetReal

decompiled_code:
double __fastcall GetReal(__int64 a1)
{
double result; // xmm0_8

if ( a1 )
result = *(double *)(*(int (__fastcall **)(__int64, __int64, __int64, _QWORD))(a1 + 8))(a1, 1LL, 3LL, 0LL);
else
result = 0.0;
return result;
}

canonical_decompiled_code:
double __fastcall func18(__int64 a1)
{
double result; // xmm0_8

if ( a1 )
result = *(double *)(*(int (__fastcall **)(__int64, __int64, __int64, _QWORD))(a1 + 8))(a1, 1LL, 3LL, 0LL);
else
result = 0.0;
return result;
}

original_code:
double
GetReal(DataObj this){
 char * result;
 if (!this)
  return 0;
 result = (char *)this->call(this, 1, 3, ((void *)0));
 return *(double *)result ;
}

canonical_original_code:
double GetReal(struct Data *this){
 char *result;
 if (!this)
  return 0;
 result = (char *)this->call(this, 1, 3, ((void *)0));
 return *(double *)result ;
}

variable_types:
result
char *

return_type: double


DataTest

decompiled_code:
int DataTest()
{
int *v0; // r14
int *v1; // r13
int *v2; // r12
int *v3; // rbp
unsigned int v4; // ebx
const char *v5; // r15
const char *v6; // r14
const char *v7; // r13
const char *v8; // r12
double v10; // [rsp+0h] [rbp-88h]
unsigned int v11; // [rsp+Ch] [rbp-7Ch]
const char *v12; // [rsp+10h] [rbp-78h]
double v13; // [rsp+18h] [rbp-70h]
const char *v14; // [rsp+20h] [rbp-68h]
double v15; // [rsp+28h] [rbp-60h]
unsigned int v16; // [rsp+30h] [rbp-58h]
unsigned int v17; // [rsp+34h] [rbp-54h]
const char *v18; // [rsp+38h] [rbp-50h]
double v19; // [rsp+40h] [rbp-48h]
const char *v20; // [rsp+48h] [rbp-40h]

v0 = NewData(0);
v1 = NewData(1);
v2 = NewData(2);
v3 = NewData(3);
SetStr((__int64)v0, (__int64)" 1000 test me ");
SetInt((__int64)v1, 67676);
SetHex((__int64)v2, (__int64)"BEEF");
SetReal((__int64)v3, 12344.56);
v20 = (const char *)GetStr((__int64)v0);
v4 = GetInt((__int64)v0);
v5 = (const char *)GetHex((__int64)v0);
v19 = GetReal((__int64)v0);
v18 = (const char *)GetStr((__int64)v1);
v17 = GetInt((__int64)v1);
v6 = (const char *)GetHex((__int64)v1);
v15 = GetReal((__int64)v1);
v14 = (const char *)GetStr((__int64)v2);
v16 = GetInt((__int64)v2);
v7 = (const char *)GetHex((__int64)v2);
v13 = GetReal((__int64)v2);
v12 = (const char *)GetStr((__int64)v3);
v11 = GetInt((__int64)v3);
v8 = (const char *)GetHex((__int64)v3);
v10 = GetReal((__int64)v3);
puts(" str\t\t\tint\t\t\thex\t\t\treal");
printf("str >%s<\t %s \t\t\t %s \t\t\t %s \n", v20, v18, v14, v12);
printf("int %d \t\t\t>%d<\t\t\t %d \t\t\t %d \n", v4, v17, v16, v11);
printf("hex %s \t\t\t %s \t\t\t>%s<\t\t\t %s \n", v5, v6, v7, v8);
return printf("real %e \t\t %e \t\t %e \t\t>%e<\n\n", v19, v15, v13, v10);
}

original_code:
void
DataTest (){
 char * str_str;
 char * str_int;
 char * str_hex;
 char * str_real;
 int int_str;
 int int_int;
 int int_hex;
 int int_real;
 char * hex_str;
 char * hex_int;
 char * hex_hex;
 char * hex_real;
 double real_str;
 double real_int;
 double real_hex;
 double real_real;
 DataObj str_do = NewData(0);
 DataObj int_do = NewData(1);
 DataObj hex_do = NewData(2);
 DataObj real_do = NewData(3);
 SetStr(str_do, "   1000  test me ");
 SetInt(int_do, 67676);
 SetHex(hex_do, "BEEF");
 SetReal(real_do, 12344.56 );
 str_str = GetStr(str_do);
 int_str = GetInt(str_do);
 hex_str = GetHex(str_do);
 real_str = GetReal(str_do);
 str_int = GetStr(int_do);
 int_int = GetInt(int_do);
 hex_int = GetHex(int_do);
 real_int = GetReal(int_do);
 str_hex = GetStr(hex_do);
 int_hex = GetInt(hex_do);
 hex_hex = GetHex(hex_do);
 real_hex = GetReal(hex_do);
 str_real = GetStr(real_do);
 int_real = GetInt(real_do);
 hex_real = GetHex(real_do);
 real_real = GetReal(real_do);
 printf("      str\t\t\tint\t\t\thex\t\t\treal\n");
 printf("str  >%s<\t %s \t\t\t %s \t\t\t %s \n", str_str, str_int, str_hex, str_real);
 printf("int   %d \t\t\t>%d<\t\t\t %d \t\t\t %d \n", int_str, int_int, int_hex, int_real);
 printf("hex   %s \t\t\t %s \t\t\t>%s<\t\t\t %s \n", hex_str, hex_int, hex_hex, hex_real);
 printf("real  %e \t\t %e \t\t %e \t\t>%e<\n\n", real_str, real_int, real_hex, real_real);
}

canonical_original_code:
void DataTest(){
 char *str_str;
 char *str_int;
 char *str_hex;
 char *str_real;
 int int_str;
 int int_int;
 int int_hex;
 int int_real;
 char *hex_str;
 char *hex_int;
 char *hex_hex;
 char *hex_real;
 double real_str;
 double real_int;
 double real_hex;
 double real_real;
 struct Data *str_do = NewData(0);
 struct Data *int_do = NewData(1);
 struct Data *hex_do = NewData(2);
 struct Data *real_do = NewData(3);
 SetStr(str_do, "   1000  test me ");
 SetInt(int_do, 67676);
 SetHex(hex_do, "BEEF");
 SetReal(real_do, 12344.56 );
 str_str = GetStr(str_do);
 int_str = GetInt(str_do);
 hex_str = GetHex(str_do);
 real_str = GetReal(str_do);
 str_int = GetStr(int_do);
 int_int = GetInt(int_do);
 hex_int = GetHex(int_do);
 real_int = GetReal(int_do);
 str_hex = GetStr(hex_do);
 int_hex = GetInt(hex_do);
 hex_hex = GetHex(hex_do);
 real_hex = GetReal(hex_do);
 str_real = GetStr(real_do);
 int_real = GetInt(real_do);
 hex_real = GetHex(real_do);
 real_real = GetReal(real_do);
 printf("      str\t\t\tint\t\t\thex\t\t\treal\n");
 printf("str  >%s<\t %s \t\t\t %s \t\t\t %s \n", str_str, str_int, str_hex, str_real);
 printf("int   %d \t\t\t>%d<\t\t\t %d \t\t\t %d \n", int_str, int_int, int_hex, int_real);
 printf("hex   %s \t\t\t %s \t\t\t>%s<\t\t\t %s \n", hex_str, hex_int, hex_hex, hex_real);
 printf("real  %e \t\t %e \t\t %e \t\t>%e<\n\n", real_str, real_int, real_hex, real_real);
}


testcallback

decompiled_code:
__int64 testcallback()
{
printf("!!! ");
return 1LL;
}

canonical_decompiled_code:
__int64 func0()
{
printf("!!! ");
return 1LL;
}

original_code:
int
testcallback(NodeObj object, NodeObj data, int value){
 printf("!!! ");
 return 1;
}

canonical_original_code:
int testcallback(void *object, void *data, int value){
 printf("!!! ");
 return 1;
}

variable_types:
object
void *

variable_types:
data
void *


CreateList

decompiled_code:
_QWORD *CreateList()
{
_QWORD *result; // rax

result = malloc(0x18uLL);
*result = 0LL;
result[1] = 0LL;
result[2] = 0LL;
return result;
}

canonical_decompiled_code:
_QWORD *func1()
{
_QWORD *result; // rax

result = malloc(0x18uLL);
*result = 0LL;
result[1] = 0LL;
result[2] = 0LL;
return result;
}

original_code:
TaskList
CreateList(){
 TaskList list = malloc(sizeof(task_list));
 list->head = ((void *)0);
 list->tail = ((void *)0);
 list->entry_count = 0;
 return list;
}

canonical_original_code:
struct task_list *CreateList(){
 struct task_list *list = malloc(sizeof(task_list));
 list->head = ((void *)0);
 list->tail = ((void *)0);
 list->entry_count = 0;
 return list;
}

variable_types: struct task_list { struct task_entry { struct task_entry *next; struct task_entry *prev; struct task_list *owner; unsigned long seconds; unsigned long millisecs; unsigned long start_seconds; unsigned long start_millisecs; int (*callback)(void *, void *, int); void *data; int trace; void *name; } *head; struct task_entry *tail; unsigned long entry_count; } *

user_defined_types: struct task_list { struct task_entry *head; struct task_entry *tail; unsigned long entry_count; }


RemoveTaskFromList

decompiled_code:
__int64 __fastcall RemoveTaskFromList(__int64 *a1)
{
_QWORD *v1; // rdx
_QWORD *v2; // rcx
__int64 result; // rax

v1 = (_QWORD *)a1[1];
v2 = (_QWORD *)a1[2];
result = *a1;
if ( v1 )
{
*v1 = result;
if ( result )
{
LABEL_3:
*(_QWORD *)(result + 8) = v1;
a1[1] = 0LL;
*a1 = 0LL;
return result;
}
}
else
{
*v2 = result;
if ( result )
goto LABEL_3;
}
v2[1] = v1;
a1[1] = 0LL;
*a1 = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 *a1)
{
_QWORD *v1; // rdx
_QWORD *v2; // rcx
__int64 result; // rax

v1 = (_QWORD *)a1[1];
v2 = (_QWORD *)a1[2];
result = *a1;
if ( v1 )
{
*v1 = result;
if ( result )
{
LABEL_3:
*(_QWORD *)(result + 8) = v1;
a1[1] = 0LL;
*a1 = 0LL;
return result;
}
}
else
{
*v2 = result;
if ( result )
goto LABEL_3;
}
v2[1] = v1;
a1[1] = 0LL;
*a1 = 0LL;
return result;
}

original_code:
void
RemoveTaskFromList(TaskPtr task){
 TaskList list = task->owner;
 if (!task->prev){
  list->head = task->next;
 } else {
  task->prev->next = task->next;
 }
 if (!task->next){
  list->tail = task->prev;
 } else {
  task->next->prev = task->prev;
 }
 task->prev = ((void *)0);
 task->next = ((void *)0);
}

canonical_original_code:
void RemoveTaskFromList(struct task_entry *task){
 struct task_list *list = task->owner;
 if (!task->prev){
  list->head = task->next;
 } else {
  task->prev->next = task->next;
 }
 if (!task->next){
  list->tail = task->prev;
 } else {
  task->next->prev = task->prev;
 }
 task->prev = ((void *)0);
 task->next = ((void *)0);
}

variable_types: struct task_entry { struct task_entry *next; struct task_entry *prev; struct task_list { struct task_entry *head; struct task_entry *tail; unsigned long entry_count; } *owner; unsigned long seconds; unsigned long millisecs; unsigned long start_seconds; unsigned long start_millisecs; int (*callback)(void *, void *, int); void *data; int trace; void *name; } *

user_defined_types: struct task_entry { struct task_entry *next; struct task_entry *prev; struct task_list *owner; unsigned long seconds; unsigned long millisecs; unsigned long start_seconds; unsigned long start_millisecs; int (*callback)(void *, void *, int); void *data; int trace; void *name; }


DeactivateTask

decompiled_code:
__int64 __fastcall DeactivateTask(__int64 a1)
{
RemoveTaskFromList((__int64 *)a1);
(*(void (__fastcall **)(__int64, _QWORD, __int64))(a1 + 56))(a1, *(_QWORD *)(a1 + 64), 1LL);
return 1LL;
}

original_code:
int
DeactivateTask(TaskPtr task){
 RemoveTaskFromList(task);
 (*task->callback)(task, task->data, task_deactivate);
 return 1;
}

canonical_original_code:
int DeactivateTask(struct task_entry *task){
 RemoveTaskFromList(task);
 (*task->callback)(task, task->data, task_deactivate);
 return 1;
}


DeleteTask

decompiled_code:
__int64 __fastcall DeleteTask(void *ptr)
{
DeactivateTask((__int64)ptr);
free(ptr);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(void *ptr)
{
func3((__int64)ptr);
free(ptr);
return 1LL;
}

original_code:
int
DeleteTask(TaskPtr task){
 DeactivateTask(task);
 free(task);
 task = ((void *)0);
 return 1;
}

canonical_original_code:
int DeleteTask(struct task_entry *task){
 DeactivateTask(task);
 free(task);
 task = ((void *)0);
 return 1;
}


DeleteList

decompiled_code:
__int64 __fastcall DeleteList(void *ptr)
{
_QWORD *v2; // rbx
void *v3; // rdi

v2 = *(_QWORD **)ptr;
if ( *(_QWORD *)ptr )
{
do
{
v3 = v2;
v2 = (_QWORD *)*v2;
DeleteTask(v3);
}
while ( v2 );
}
free(ptr);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(void *ptr)
{
_QWORD *v2; // rbx
void *v3; // rdi

v2 = *(_QWORD **)ptr;
if ( *(_QWORD *)ptr )
{
do
{
v3 = v2;
v2 = (_QWORD *)*v2;
func4(v3);
}
while ( v2 );
}
free(ptr);
return 1LL;
}

original_code:
int
DeleteList(TaskList list){
 TaskPtr current = list->head;
 TaskPtr next;
 while (current){
  next = current->next;
  DeleteTask(current);
  current = next;
 }
 free (list);
 list = ((void *)0);
 return 1;
}

canonical_original_code:
int DeleteList(struct task_list *list){
 struct task_entry *current = list->head;
 struct task_entry *next;
 while (current){
  next = current->next;
  DeleteTask(current);
  current = next;
 }
 free (list);
 list = ((void *)0);
 return 1;
}


AddTaskDelay

original_code:
int
AddTaskDelay(TaskPtr task, int delay_seconds, int delay_millisecs, FuncPtr func, int mesgid, NodeObj data){
 TaskList list = task->owner;
 TaskPtr current;
 unsigned long seconds;
 unsigned long millisecs;
 GetCurrentTime(&seconds, &millisecs);
 task->callback = func;
 delay_seconds = delay_seconds + seconds;
 delay_millisecs = delay_millisecs + millisecs;
 if (delay_millisecs > 1000) {
  delay_millisecs = delay_millisecs - 1000;
  delay_seconds += 1;
 }
 task->seconds = delay_seconds;
 task->millisecs = delay_millisecs;
 task->next=((void *)0);
 task->prev=((void *)0);
 if (!list->head) {
  list->head = list->tail = task;
  task->next = task->prev = ((void *)0);
  return 1;
 }
 for ( current = list->head; current && (current->seconds < delay_seconds
  || (current->seconds == delay_seconds && current->millisecs < delay_millisecs)); ) {
        current = current->next;
    }
 if (list->head == current) {
  list->head->prev = task;
  task->next = list->head;
  list->head = task;
 } else if (!current) {
  list->tail->next = task;
  task->prev = list->tail;
  list->tail = task;
 } else {
  task->next = current;
  task->prev = current->prev;
  current->prev = task;
  task->prev->next = task;
 }
 return 1;
}

canonical_original_code:
int AddTaskDelay(struct task_entry *task, int delay_seconds, int delay_millisecs, int (*func)(void *, void *, int), int mesgid, void *data){
 struct task_list *list = task->owner;
 struct task_entry *current;
 unsigned long seconds;
 unsigned long millisecs;
 GetCurrentTime(&seconds, &millisecs);
 task->callback = func;
 delay_seconds = delay_seconds + seconds;
 delay_millisecs = delay_millisecs + millisecs;
 if (delay_millisecs > 1000) {
  delay_millisecs = delay_millisecs - 1000;
  delay_seconds += 1;
 }
 task->seconds = delay_seconds;
 task->millisecs = delay_millisecs;
 task->next=((void *)0);
 task->prev=((void *)0);
 if (!list->head) {
  list->head = list->tail = task;
  task->next = task->prev = ((void *)0);
  return 1;
 }
 for ( current = list->head; current && (current->seconds < delay_seconds
  || (current->seconds == delay_seconds && current->millisecs < delay_millisecs)); ) {
        current = current->next;
    }
 if (list->head == current) {
  list->head->prev = task;
  task->next = list->head;
  list->head = task;
 } else if (!current) {
  list->tail->next = task;
  task->prev = list->tail;
  list->tail = task;
 } else {
  task->next = current;
  task->prev = current->prev;
  current->prev = task;
  task->prev->next = task;
 }
 return 1;
}

variable_types:
func
int (*)(void *, void *, int)

variable_types: mesgid int

variable_types:
seconds
unsigned long

variable_types:
millisecs
unsigned long


AddTaskNow

decompiled_code:
__int64 __fastcall AddTaskNow(_QWORD *a1, __int64 a2)
{
return AddTaskDelay(a1, 0, 0, a2);
}

canonical_decompiled_code:
__int64 __fastcall func7(_QWORD *a1, __int64 a2)
{
return func6(a1, 0, 0, a2);
}

original_code:
int
AddTaskNow(TaskPtr task, FuncPtr func, int mesgid, NodeObj data){
 return AddTaskDelay(task, 0, 0, func, mesgid, data);
}

canonical_original_code:
int AddTaskNow(struct task_entry *task, int (*func)(void *, void *, int), int mesgid, void *data){
 return AddTaskDelay(task, 0, 0, func, mesgid, data);
}


AddTaskMilli

decompiled_code:
__int64 __fastcall AddTaskMilli(_QWORD *a1, unsigned __int64 a2, __int64 a3)
{
return AddTaskDelay(a1, a2 / 0x3E8, a2 % 0x3E8, a3);
}

canonical_decompiled_code:
__int64 __fastcall func8(_QWORD *a1, unsigned __int64 a2, __int64 a3)
{
return func6(a1, a2 / 0x3E8, a2 % 0x3E8, a3);
}

original_code:
int
AddTaskMilli(TaskPtr task, unsigned long delay_millisecs, FuncPtr func, int mesgid, NodeObj data){
 return AddTaskDelay(task, delay_millisecs/1000, delay_millisecs%1000, func, mesgid, data);
}

canonical_original_code:
int AddTaskMilli(struct task_entry *task, unsigned long delay_millisecs, int (*func)(void *, void *, int), int mesgid, void *data){
 return AddTaskDelay(task, delay_millisecs/1000, delay_millisecs%1000, func, mesgid, data);
}


AddTaskSec

decompiled_code:
__int64 __fastcall AddTaskSec(_QWORD *a1, int a2, __int64 a3)
{
return AddTaskDelay(a1, a2, 0, a3);
}

canonical_decompiled_code:
__int64 __fastcall func9(_QWORD *a1, int a2, __int64 a3)
{
return func6(a1, a2, 0, a3);
}

original_code:
int
AddTaskSec(TaskPtr task, unsigned long delay_seconds, FuncPtr func, int mesgid, NodeObj data){
 return AddTaskDelay(task, delay_seconds, 0, func, mesgid, data);
}

canonical_original_code:
int AddTaskSec(struct task_entry *task, unsigned long delay_seconds, int (*func)(void *, void *, int), int mesgid, void *data){
 return AddTaskDelay(task, delay_seconds, 0, func, mesgid, data);
}


PrintDebugList

decompiled_code:
void PrintDebugList()
{
;
}

canonical_decompiled_code:
void func10()
{
;
}

original_code:
void
PrintDebugList(TaskList list){
}

canonical_original_code:
void PrintDebugList(struct task_list *list){
}


ExecTasks

decompiled_code:
__int64 __fastcall ExecTasks(__int64 **a1)
{
_QWORD *v1; // rbx
_QWORD *v2; // rax
_QWORD *v3; // rdx
void (__fastcall *v4)(_QWORD, _QWORD, _QWORD); // rcx
char v6; // dl

v1 = CreateList();
ActivateTimedTasks(a1, v1);
v2 = (_QWORD *)*v1;
if ( *v1 )
{
do
{
while ( 1 )
{
v3 = (_QWORD *)*v2;
v4 = (void (__fastcall *)(_QWORD, _QWORD, _QWORD))v2[7];
*v1 = *v2;
*v2 = 0LL;
v2[1] = 0LL;
if ( !v4 )
break;
v4(v2[8], v2[8], 0LL);
v2 = (_QWORD *)*v1;
if ( !*v1 )
goto LABEL_6;
}
v2 = v3;
}
while ( v3 );
LABEL_6:
v6 = 1;
}
else
{
v6 = 0;
}
return (unsigned __int8)(v6 | (*a1 != 0LL));
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 **a1)
{
_QWORD *v1; // rbx
_QWORD *v2; // rax
_QWORD *v3; // rdx
void (__fastcall *v4)(_QWORD, _QWORD, _QWORD); // rcx
char v6; // dl

v1 = func1();
ActivateTimedTasks(a1, v1);
v2 = (_QWORD *)*v1;
if ( *v1 )
{
do
{
while ( 1 )
{
v3 = (_QWORD *)*v2;
v4 = (void (__fastcall *)(_QWORD, _QWORD, _QWORD))v2[7];
*v1 = *v2;
*v2 = 0LL;
v2[1] = 0LL;
if ( !v4 )
break;
v4(v2[8], v2[8], 0LL);
v2 = (_QWORD *)*v1;
if ( !*v1 )
goto LABEL_6;
}
v2 = v3;
}
while ( v3 );
LABEL_6:
v6 = 1;
}
else
{
v6 = 0;
}
return (unsigned __int8)(v6 | (*a1 != 0LL));
}

original_code:
int
ExecTasks(TaskList list){
 TaskList runlist = CreateList();
 TaskPtr current;
 int taskcount = 0;
 ActivateTimedTasks(list, runlist);
 while (runlist->head){
  current = runlist->head;
  runlist->head = current->next;
  current->next = ((void *)0);
  current->prev = ((void *)0);
  if(current->callback)
   (*current->callback)(current->data, current->data, task_callback);
  taskcount++;
 }
 if (list->head || taskcount)
  return 1;
 else return 0;
}

canonical_original_code:
int ExecTasks(struct task_list *list){
 struct task_list *runlist = CreateList();
 struct task_entry *current;
 int taskcount = 0;
 ActivateTimedTasks(list, runlist);
 while (runlist->head){
  current = runlist->head;
  runlist->head = current->next;
  current->next = ((void *)0);
  current->prev = ((void *)0);
  if(current->callback)
   (*current->callback)(current->data, current->data, task_callback);
  taskcount++;
 }
 if (list->head || taskcount)
  return 1;
 else return 0;
}

variable_types: taskcount int


SchedTest

decompiled_code:
int SchedTest()
{
__int64 **v0; // rbp
_QWORD *v1; // r15
_QWORD *v2; // r14
_QWORD *v3; // r13
__int64 v4; // rbx
int v5; // ebx
_QWORD *v7; // [rsp+8h] [rbp-40h]

TimeUpdate();
v0 = (__int64 **)CreateList();
v7 = CreateTask((__int64)v0);
v1 = CreateTask((__int64)v0);
v2 = CreateTask((__int64)v0);
v3 = CreateTask((__int64)v0);
v4 = NewNode();
SetPropInt(v4, "TestData", 1LL);
AddTaskDelay(v7, 5, 500, (__int64)testcallback);
AddTaskNow(v1, (__int64)testcallback);
AddTaskMilli(v2, 0x64uLL, (__int64)testcallback);
AddTaskSec(v3, 10, (__int64)testcallback);
puts("Schedtest");
do
{
TimeUpdate();
v5 = ExecTasks(v0);
putchar(46);
fflush(stdout);
usleep(0x2710u);
}
while ( v5 );
return putchar(10);
}

canonical_decompiled_code:
int func12()
{
__int64 **v0; // rbp
_QWORD *v1; // r15
_QWORD *v2; // r14
_QWORD *v3; // r13
__int64 v4; // rbx
int v5; // ebx
_QWORD *v7; // [rsp+8h] [rbp-40h]

TimeUpdate();
v0 = (__int64 **)func1();
v7 = CreateTask((__int64)v0);
v1 = CreateTask((__int64)v0);
v2 = CreateTask((__int64)v0);
v3 = CreateTask((__int64)v0);
v4 = NewNode();
SetPropInt(v4, "TestData", 1LL);
func6(v7, 5, 500, (__int64)testcallback);
func7(v1, (__int64)testcallback);
func8(v2, 0x64uLL, (__int64)testcallback);
func9(v3, 10, (__int64)testcallback);
puts("Schedtest");
do
{
TimeUpdate();
v5 = func11(v0);
putchar(46);
fflush(stdout);
usleep(0x2710u);
}
while ( v5 );
return putchar(10);
}

original_code:
void
SchedTest (){
 int CountOfScheduledTasks = 1;
 TimeUpdate();
 TaskList testlist = CreateList();
 TaskPtr testtask1 = CreateTask(testlist);
 TaskPtr testtask2 = CreateTask(testlist);
 TaskPtr testtask3 = CreateTask(testlist);
 TaskPtr testtask4 = CreateTask(testlist);
 NodeObj testdata = NewNode();
 SetPropInt(testdata, "TestData", 1);
 AddTaskDelay(testtask1, 5, 500, &testcallback, 1000, testdata);
 AddTaskNow(testtask2, &testcallback, 1001, testdata);
 AddTaskMilli(testtask3, 100, &testcallback, 1002, testdata);
 AddTaskSec(testtask4, 10, &testcallback, 1003, testdata);
 printf("Schedtest\n");
 while(CountOfScheduledTasks){
  TimeUpdate();
  CountOfScheduledTasks = ExecTasks(testlist);
  printf(".");
  fflush(stdout);
  usleep(10000);
 }
 printf("\n");
}

canonical_original_code:
void SchedTest(){
 int CountOfScheduledTasks = 1;
 TimeUpdate();
 struct task_list *testlist = CreateList();
 struct task_entry *testtask1 = CreateTask(testlist);
 struct task_entry *testtask2 = CreateTask(testlist);
 struct task_entry *testtask3 = CreateTask(testlist);
 struct task_entry *testtask4 = CreateTask(testlist);
 void *testdata = NewNode();
 SetPropInt(testdata, "TestData", 1);
 AddTaskDelay(testtask1, 5, 500, &testcallback, 1000, testdata);
 AddTaskNow(testtask2, &testcallback, 1001, testdata);
 AddTaskMilli(testtask3, 100, &testcallback, 1002, testdata);
 AddTaskSec(testtask4, 10, &testcallback, 1003, testdata);
 printf("Schedtest\n");
 while(CountOfScheduledTasks){
  TimeUpdate();
  CountOfScheduledTasks = ExecTasks(testlist);
  printf(".");
  fflush(stdout);
  usleep(10000);
 }
 printf("\n");
}

variable_types: CountOfScheduledTasks int

variable_types:
testdata
void *


GetCurrentSeconds

decompiled_code:
__int64 GetCurrentSeconds()
{
return global_seconds;
}

canonical_decompiled_code:
__int64 func1()
{
return global_seconds;
}

original_code:
time_t
GetCurrentSeconds (){
 return (time_t)global_seconds;
}

canonical_original_code:
long GetCurrentSeconds(){
 return (long)global_seconds;
}

return_type: long


GetRunTime

decompiled_code:
__int64 GetRunTime()
{
return global_seconds - global_start_seconds;
}

canonical_decompiled_code:
__int64 func2()
{
return global_seconds - global_start_seconds;
}

original_code:
long
GetRunTime(){
 return global_seconds - global_start_seconds;
}


TimeUpdate

decompiled_code:
__time_t TimeUpdate()
{
__int64 v0; // rbx
__time_t result; // rax
struct timezone tz; // [rsp+8h] [rbp-20h] BYREF
struct timeval tv; // [rsp+10h] [rbp-18h] BYREF

v0 = global_seconds;
gettimeofday(&tv, &tz);
if ( v0 )
{
global_seconds = tv.tv_sec;
result = tv.tv_sec - v0;
global_milliseconds = tv.tv_usec / 1000;
if ( (unsigned __int64)(tv.tv_sec - v0) <= 1 )
result = 0LL;
else
global_start_seconds += result;
}
else
{
global_start_seconds = tv.tv_sec;
global_seconds = tv.tv_sec;
result = 0LL;
global_milliseconds = tv.tv_usec / 1000;
}
return result;
}

canonical_decompiled_code:
__time_t func4()
{
__int64 v0; // rbx
__time_t result; // rax
struct timezone tz; // [rsp+8h] [rbp-20h] BYREF
struct timeval tv; // [rsp+10h] [rbp-18h] BYREF

v0 = global_seconds;
gettimeofday(&tv, &tz);
if ( v0 )
{
global_seconds = tv.tv_sec;
result = tv.tv_sec - v0;
global_milliseconds = tv.tv_usec / 1000;
if ( (unsigned __int64)(tv.tv_sec - v0) <= 1 )
result = 0LL;
else
global_start_seconds += result;
}
else
{
global_start_seconds = tv.tv_sec;
global_seconds = tv.tv_sec;
result = 0LL;
global_milliseconds = tv.tv_usec / 1000;
}
return result;
}

original_code:
long
TimeUpdate (){
 struct timeval tv;
 struct timezone tz;
        long prevSecs = global_seconds;
        long offset;
 gettimeofday(&tv, &tz);
 if (!global_seconds){
  prevSecs = tv.tv_sec;
  global_start_seconds = tv.tv_sec;
 }
 global_seconds = tv.tv_sec;
 global_milliseconds = tv.tv_usec/1000;
        offset = global_seconds - prevSecs;
        if ( offset < 0 || offset > 1){
  global_start_seconds += offset;
  return offset;
 }
 return 0;
}

canonical_original_code:
long TimeUpdate(){
 struct timeval tv;
 struct timezone tz;
        long prevSecs = global_seconds;
        long offset;
 gettimeofday(&tv, &tz);
 if (!global_seconds){
  prevSecs = tv.tv_sec;
  global_start_seconds = tv.tv_sec;
 }
 global_seconds = tv.tv_sec;
 global_milliseconds = tv.tv_usec/1000;
        offset = global_seconds - prevSecs;
        if ( offset < 0 || offset > 1){
  global_start_seconds += offset;
  return offset;
 }
 return 0;
}

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

variable_types: struct timezone { int tz_minuteswest; int tz_dsttime; }

variable_types: prevSecs long

variable_types: offset long


IsLeapYear

original_code:
int
IsLeapYear (unsigned int year){
 return(((year % 4) && (year %100)) || (year % 400 == 0 ));
}

canonical_original_code:
int IsLeapYear(unsigned int year){
 return(((year % 4) && (year %100)) || (year % 400 == 0 ));
}

variable_types:
year
unsigned int


DaysInMonth

original_code:
int
DaysInMonth(int year, int month){
 int months[]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
 if ((month < 0) || (month > 11))
  return 0;
 if (month == 1 && IsLeapYear(year))
  return 29;
 return months[month];
}

canonical_original_code:
int DaysInMonth(int year, int month){
 int months[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
 if ((month < 0) || (month > 11))
  return 0;
 if (month == 1 && IsLeapYear(year))
  return 29;
 return months[month];
}

variable_types: year int

variable_types: month int

variable_types:
months
int []


FormatDate

decompiled_code:
char *__fastcall FormatDate(time_t a1)
{
struct tm *v1; // rbx
char *result; // rax
__int64 v3; // rdx
int v4; // eax
__int64 v5; // rdx
int v6; // ecx
int v7; // eax
int v8; // ecx
int v9; // eax
int v10; // ecx
int v11; // edx
int v12; // eax
int v13; // esi
int v14; // edx
int v15; // eax
time_t timer[4]; // [rsp+8h] [rbp-20h] BYREF

timer[0] = a1;
if ( !a1 )
localCacheTime(timer);
v1 = localtime(timer);
result = (char *)&LC0;
if ( v1 && v1->tm_year > 103 )
{
strcpy(dateStr_0, (const char *)*(&ShortDayNames + v1->tm_wday));
v3 = v1->tm_mon;
byte_BC3 = 32;
strcpy(dest, (const char *)*(&ShortMonthNames + v3));
v4 = v1->tm_mday;
byte_BC7 = 32;
if ( v4 <= 9 )
{
LOBYTE(v6) = 32;
v5 = v4;
}
else
{
v5 = v4;
v6 = v4 / 10 + 48;
}
byte_BC8 = v6;
byte_BCA = 32;
byte_BCF = 32;
byte_BC9 = v4 - 10 * (((1717986919 * v5) >> 34) - (v4 >> 31)) + 48;
v7 = v1->tm_year + 1900;
byte_BCB = v7 / 1000 + 48;
byte_BCC = v7 % 1000 / 100 + 48;
v8 = v7 % 1000 % 100;
byte_BCD = v8 / 10 + 48;
v9 = v8 % 10 + 48;
v10 = 0;
byte_BCE = v9;
v11 = v1->tm_hour;
if ( v11 > 11 )
{
v11 -= 12;
v10 = 1;
}
if ( v11 )
{
v12 = v11 / 10 + 48;
v13 = v11 % 10 + 48;
if ( v11 <= 9 )
LOBYTE(v12) = 48;
}
else
{
LOBYTE(v13) = 50;
LOBYTE(v12) = 49;
}
byte_BD0 = v12;
LOBYTE(v12) = 48;
byte_BD1 = v13;
byte_BD2 = 58;
v14 = v1->tm_min;
if ( v14 > 9 )
v12 = v14 / 10 + 48;
byte_BD3 = v12;
v15 = v1->tm_min;
byte_BD5 = 32;
byte_BD4 = v15 % 10 + 48;
byte_BD6 = v10 == 0 ? 65 : 80;
word_BD7 = 77;
result = dateStr_0;
}
return result;
}

original_code:
char *
FormatDate(time_t theTime){
 struct tm * formatTime;
 static char dateStr[29];
 char * current = dateStr;
 int pm = FALSE;
 int i, year;
 if(!theTime)
  localCacheTime(&theTime);
 formatTime = localtime ( &theTime );
 if ( !formatTime )
  return "";
 if (formatTime->tm_year < 104 )
  return "";
 strcpy ( current, ShortDayNames [ formatTime->tm_wday ] );
 current += 3;
 *current=' ';
 current++;
 strcpy ( current, ShortMonthNames [ formatTime->tm_mon ] );
 current += 3;
 *current=' ';
 current++;
 if ( formatTime->tm_mday < 10 ) {
  *current=' ';
  current++;
 } else {
  *current = formatTime->tm_mday/10+'0';
  current++;
 }
 *current = formatTime->tm_mday%10 + '0';
 current++;
 *current=' ';
 current++;
 year = formatTime->tm_year + 1900;
 i = year/1000;
 year = year - i*1000;
 *current= i + '0';
 current++;
 i = year/100;
 year = year - i*100;
 *current= i + '0';
 current++;
 i = year/10;
 year = year - i*10;
 *current= i + '0';
 current++;
 *current= year + '0';
 current++;
 *current=' ';
 current++;
 i = formatTime->tm_hour;
 if ( i >= 12) {
  i -= 12;
  pm = TRUE;
 }
 if (i == 0)
  i = 12;
 if (i < 10) {
  *current='0';
  current++;
 } else {
  *current=i/10+'0';
  current++;
 }
 *current=i%10+'0';
 current++;
 *current=':';
 current++;
 if ( formatTime->tm_min < 10 ) {
  *current='0';
  current++;
 } else {
  *current = formatTime->tm_min / 10+'0';
  current++;
 }
 *current = formatTime->tm_min % 10 + '0';
 current++;
 *current=' ';
 current++;
 if(pm)
  *current = 'P';
 else
  *current = 'A';
 current++;
 *current='M';
 current++;
 *current = 0;
 return dateStr;
}

canonical_original_code:
char *FormatDate(long theTime){
 struct tm *formatTime;
 static char dateStr[29];
 char *current = dateStr;
 int pm = FALSE;
 int i; int year;
 if(!theTime)
  localCacheTime(&theTime);
 formatTime = localtime ( &theTime );
 if ( !formatTime )
  return "";
 if (formatTime->tm_year < 104 )
  return "";
 strcpy ( current, ShortDayNames [ formatTime->tm_wday ] );
 current += 3;
 *current=' ';
 current++;
 strcpy ( current, ShortMonthNames [ formatTime->tm_mon ] );
 current += 3;
 *current=' ';
 current++;
 if ( formatTime->tm_mday < 10 ) {
  *current=' ';
  current++;
 } else {
  *current = formatTime->tm_mday/10+'0';
  current++;
 }
 *current = formatTime->tm_mday%10 + '0';
 current++;
 *current=' ';
 current++;
 year = formatTime->tm_year + 1900;
 i = year/1000;
 year = year - i*1000;
 *current= i + '0';
 current++;
 i = year/100;
 year = year - i*100;
 *current= i + '0';
 current++;
 i = year/10;
 year = year - i*10;
 *current= i + '0';
 current++;
 *current= year + '0';
 current++;
 *current=' ';
 current++;
 i = formatTime->tm_hour;
 if ( i >= 12) {
  i -= 12;
  pm = TRUE;
 }
 if (i == 0)
  i = 12;
 if (i < 10) {
  *current='0';
  current++;
 } else {
  *current=i/10+'0';
  current++;
 }
 *current=i%10+'0';
 current++;
 *current=':';
 current++;
 if ( formatTime->tm_min < 10 ) {
  *current='0';
  current++;
 } else {
  *current = formatTime->tm_min / 10+'0';
  current++;
 }
 *current = formatTime->tm_min % 10 + '0';
 current++;
 *current=' ';
 current++;
 if(pm)
  *current = 'P';
 else
  *current = 'A';
 current++;
 *current='M';
 current++;
 *current = 0;
 return dateStr;
}

variable_types: theTime long

variable_types: struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long tm_gmtoff; char *tm_zone; } *

variable_types:
dateStr
char [29]

variable_types:
current
char *

variable_types: pm int

variable_types: i int


DaylightSavings

decompiled_code:
__int64 __fastcall DaylightSavings(time_t a1)
{
struct tm *v1; // rax
unsigned int v2; // er8
time_t timer; // [rsp+8h] [rbp-10h] BYREF

timer = a1;
v1 = localtime(&timer);
v2 = 0;
if ( v1 )
v2 = v1->tm_isdst;
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func8(time_t a1)
{
struct tm *v1; // rax
unsigned int v2; // er8
time_t timer; // [rsp+8h] [rbp-10h] BYREF

timer = a1;
v1 = localtime(&timer);
v2 = 0;
if ( v1 )
v2 = v1->tm_isdst;
return v2;
}

original_code:
int
DaylightSavings(time_t theTime){
 struct tm *checktime;
 checktime = localtime(&theTime);
 if(checktime)
  return (checktime->tm_isdst);
 else
  return 0;
}

canonical_original_code:
int DaylightSavings(long theTime){
 struct tm *checktime;
 checktime = localtime(&theTime);
 if(checktime)
  return (checktime->tm_isdst);
 else
  return 0;
}

user_defined_types: struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long tm_gmtoff; char *tm_zone; }


GetWeek

decompiled_code:
__int64 __fastcall GetWeek(int a1, int a2, int a3)
{
int v4; // er15
int v5; // ebp
int v6; // ebx
int v7; // esi

if ( a1 <= 2003 )
return 0LL;
v4 = 2004;
v5 = 4;
LABEL_3:
while ( 2 )
{
v6 = 0;
while ( a2 != v6 || v4 != a1 )
{
v7 = v6++;
v5 += DaysInMonth(v4, v7);
if ( v6 == 12 )
{
if ( a1 >= ++v4 )
goto LABEL_3;
return (unsigned int)(v5 / 7);
}
}
++v4;
v5 += a3;
if ( a1 >= v4 )
continue;
return (unsigned int)(v5 / 7);
}
}

canonical_decompiled_code:
__int64 __fastcall func9(int a1, int a2, int a3)
{
int v4; // er15
int v5; // ebp
int v6; // ebx
int v7; // esi

if ( a1 <= 2003 )
return 0LL;
v4 = 2004;
v5 = 4;
LABEL_3:
while ( 2 )
{
v6 = 0;
while ( a2 != v6 || v4 != a1 )
{
v7 = v6++;
v5 += func6(v4, v7);
if ( v6 == 12 )
{
if ( a1 >= ++v4 )
goto LABEL_3;
return (unsigned int)(v5 / 7);
}
}
++v4;
v5 += a3;
if ( a1 >= v4 )
continue;
return (unsigned int)(v5 / 7);
}
}

original_code:
int
GetWeek ( int year, int month, int day ){
 int accumulateddays=4;
 int currentyear;
 int currentmonth;
 for(currentyear=2004; currentyear<=year; currentyear++)
  for (currentmonth=0; currentmonth < 12; currentmonth++){
   if((currentyear==year)&&(currentmonth==month)){
    accumulateddays +=day;
    break;
   }
   accumulateddays += DaysInMonth( currentyear, currentmonth);
  }
 return ((accumulateddays)/7);
}

canonical_original_code:
int GetWeek(int year, int month, int day){
 int accumulateddays = 4;
 int currentyear;
 int currentmonth;
 for(currentyear=2004; currentyear<=year; currentyear++)
  for (currentmonth=0; currentmonth < 12; currentmonth++){
   if((currentyear==year)&&(currentmonth==month)){
    accumulateddays +=day;
    break;
   }
   accumulateddays += DaysInMonth( currentyear, currentmonth);
  }
 return ((accumulateddays)/7);
}

variable_types: day int

variable_types: accumulateddays int

variable_types: currentyear int

variable_types: currentmonth int


NumberOfWeeksInMonth

decompiled_code:
__int64 __fastcall NumberOfWeeksInMonth(int a1, int a2)
{
int v2; // eax
int v3; // ebx

v2 = DaysInMonth(a1, a2);
v3 = GetWeek(a1, a2, v2);
return v3 - (unsigned int)GetWeek(a1, a2, 1) + 1;
}

canonical_decompiled_code:
__int64 __fastcall func10(int a1, int a2)
{
int v2; // eax
int v3; // ebx

v2 = func6(a1, a2);
v3 = func9(a1, a2, v2);
return v3 - (unsigned int)func9(a1, a2, 1) + 1;
}

original_code:
int
NumberOfWeeksInMonth(int year, int month){
 return(GetWeek(year, month, DaysInMonth(year, month))-GetWeek(year, month, 1)+1);
}


CurrentWeekInMonth

decompiled_code:
__int64 __fastcall CurrentWeekInMonth(int a1, int a2, int a3)
{
int v3; // ebx

v3 = GetWeek(a1, a2, a3);
return v3 - (unsigned int)GetWeek(a1, a2, 1) + 1;
}

canonical_decompiled_code:
__int64 __fastcall func11(int a1, int a2, int a3)
{
int v3; // ebx

v3 = func9(a1, a2, a3);
return v3 - (unsigned int)func9(a1, a2, 1) + 1;
}

original_code:
int
CurrentWeekInMonth(int year, int month, int day){
 return(GetWeek(year, month, day)-GetWeek(year, month, 1)+1);
}


EventDelay

original_code:
unsigned long
EventDelay ( mytime schedTime[], int type, time_t theTime ){
 struct tm *today;
 long seconds;
 int LastDay,
     year,
     yearrange,
     month,
     day,
     wday = 0;
 int accumulatedDays=1;
 int yearoffset =1900;
 int monthoffset = 0;
 int dayoffset = 0;
 int syear = schedTime[type].StartTime[5],
     smonth = schedTime[type].StartTime[4],
     sday = schedTime[type].StartTime[3],
     smeridian = schedTime[type].StartTime[2],
     sminute = schedTime[type].StartTime[1],
     shour = schedTime[type].StartTime[0],
     Interval = 0,
     Passed = 0;
 if (!theTime)
  localCacheTime(&theTime);
 today = localtime ( &theTime );
 if (!today)
  return 1;
 LastDay = DaysInMonth(today->tm_year+1900, today->tm_mon);
 if (shour == 12)
     shour = 0;
 seconds = ((shour + smeridian *12) * 60 + sminute ) *60 - ((today->tm_hour * 60 + today->tm_sec
 + 1));
 yearoffset = yearoffset + today->tm_year;
 yearrange = yearoffset + 6;
 monthoffset = today->tm_mon;
 dayoffset = today->tm_mday;
 switch (schedTime[type].State){
  case FixedInterval:
   Interval = ((schedTime[type].Every[0] *24 + schedTime[type].Every[1]) * 60 + schedTime[type].Every[2]) * 60;
   if (Interval < 60)
    Interval = 60;
   if (schedTime[type].StartOnNextMinute) {
    if (schedTime[type].Applied == FALSE){
     return 60 -today->tm_sec;
    } else {
     seconds = Interval -1;
     goto daylight_calculation;
    }
   }
   if (syear == 0)
    syear = today->tm_year+1900;
   if (smonth == 0)
    smonth = today->tm_mon;
   else
    smonth--;
   if (yearrange < syear)
    yearrange = syear + 1;
   if (sday == 0)
    sday = today->tm_mday;
   if(syear == today->tm_year+1900 && smonth == today->tm_mon && sday == today->tm_mday){
    while (seconds < 0)
     seconds = seconds + Interval;
    goto daylight_calculation;
   }
   Passed = FALSE;
   if (syear < today->tm_year+1900)
    Passed = TRUE;
   else if (syear == (today->tm_year+1900) && smonth < today->tm_mon)
    Passed = TRUE;
   else if (syear == (today->tm_year+1900) && smonth == today->tm_mon && sday < today->tm_mday)
    Passed = TRUE;
   if (Passed) {
    int x;
    x = syear;
    syear = yearoffset;
    yearoffset = x;
    x=smonth;
    smonth = monthoffset;
    monthoffset = x;
    x=sday;
    sday=dayoffset;
    dayoffset = x;
   }
   break;
 case EveryWeekDay:
  if (schedTime[type].DaysOfWeek[today->tm_wday] && (
   schedTime[type].WeeksOfMonth[(today->tm_mday-1)/7] || (
   !((LastDay-today->tm_mday)/7) && schedTime[type].WeeksOfMonth[5]
  )
  ) ) {
   if (seconds > 0)
    goto daylight_calculation;
  }
  wday = today->tm_wday;
  wday++;
  if (wday>=7)
   wday -= 7;
  break;
 case EveryMonthDay:
  if ( ( schedTime[type].MonthsOfYear[today->tm_mon] &&
   schedTime[type].DaysOfMonth[today->tm_mday-1] ) ||
   ( ( LastDay == today->tm_mday ) &&
     ( ( ( schedTime[type].DaysOfMonth[today->tm_mon] ) &&
    ( schedTime[type].DaysOfMonth[LastDay-1] ) ) ||
      schedTime[type].DaysOfMonth[31])
     )
   ) {
    if (seconds > 0)
     goto daylight_calculation;
   }
   break;
 }
 if(LastDay == dayoffset){
  dayoffset = 0;
  monthoffset++;
 }
 if(monthoffset > 11) {
  monthoffset=0;
  yearoffset++;
 }
 for (year = yearoffset; year < yearoffset + yearoffset; year++ ){
  for(month = 0+monthoffset; month < 12; month++ ){
   LastDay = DaysInMonth(year, month);
   for (day=1+dayoffset; day <= LastDay; day++){
    switch(schedTime[type].State){
     case FixedInterval:
      if(year == syear && month == smonth && day == sday){
       if(Passed){
        seconds = -1 * accumulatedDays * 86400 + seconds;
        while(seconds <0)
         seconds += Interval;
       } else {
        seconds = (accumulatedDays) * 86400 + seconds;
       }
       goto daylight_calculation;
      }
      break;
     case EveryWeekDay:
      if (schedTime[type].DaysOfWeek[wday] && (
       schedTime[type].WeeksOfMonth[(day-1)/7] || (
        !((LastDay-day)/7) && schedTime[type].WeeksOfMonth[5] ) ) ) {
       seconds = (accumulatedDays)*86400 + seconds;
       goto daylight_calculation;
      }
      wday++;
      if (wday>=7)
       wday -= 7;
      break;
     case EveryMonthDay:
      if ( ( ( schedTime[type].MonthsOfYear[month] ) && ( schedTime[type].DaysOfMonth[day-1] ) ) ||
       ( ( day == LastDay ) &&
         ( ( schedTime[type].MonthsOfYear[month] ) &&
           ( ( schedTime[type].DaysOfMonth[LastDay-1] ) ||
             ( schedTime[type].DaysOfMonth[31] )
           )
         )
       )
          ) {
       seconds = accumulatedDays * 86400 + seconds;
       goto daylight_calculation;
      }
      break;
     }
     accumulatedDays++;
    }
    dayoffset = 0;
   }
   monthoffset = 0;
  }
  return 1;
 daylight_calculation:
  if (DaylightSavings(theTime) && !(DaylightSavings(theTime+seconds)))
   seconds += 3600;
  if (!DaylightSavings(theTime) && (DaylightSavings(theTime+seconds)))
   seconds -= 3600;
  if (seconds == 1)
   seconds = seconds + 60;
  return ( seconds + 1 );
}

canonical_original_code:
unsigned long EventDelay(struct mytime schedTime[], int type, long theTime){
 struct tm *today;
 long seconds;
 int LastDay; int year; int yearrange; int month; int day; int wday = 0;
 int accumulatedDays = 1;
 int yearoffset = 1900;
 int monthoffset = 0;
 int dayoffset = 0;
 int syear = schedTime[type].StartTime[5]; int smonth = schedTime[type].StartTime[4]; int sday = schedTime[type].StartTime[3]; int smeridian = schedTime[type].StartTime[2]; int sminute = schedTime[type].StartTime[1]; int shour = schedTime[type].StartTime[0]; int Interval = 0; int Passed = 0;
 if (!theTime)
  localCacheTime(&theTime);
 today = localtime ( &theTime );
 if (!today)
  return 1;
 LastDay = DaysInMonth(today->tm_year+1900, today->tm_mon);
 if (shour == 12)
     shour = 0;
 seconds = ((shour + smeridian *12) * 60 + sminute ) *60 - ((today->tm_hour * 60 + today->tm_sec
 + 1));
 yearoffset = yearoffset + today->tm_year;
 yearrange = yearoffset + 6;
 monthoffset = today->tm_mon;
 dayoffset = today->tm_mday;
 switch (schedTime[type].State){
  case FixedInterval:
   Interval = ((schedTime[type].Every[0] *24 + schedTime[type].Every[1]) * 60 + schedTime[type].Every[2]) * 60;
   if (Interval < 60)
    Interval = 60;
   if (schedTime[type].StartOnNextMinute) {
    if (schedTime[type].Applied == FALSE){
     return 60 -today->tm_sec;
    } else {
     seconds = Interval -1;
     goto daylight_calculation;
    }
   }
   if (syear == 0)
    syear = today->tm_year+1900;
   if (smonth == 0)
    smonth = today->tm_mon;
   else
    smonth--;
   if (yearrange < syear)
    yearrange = syear + 1;
   if (sday == 0)
    sday = today->tm_mday;
   if(syear == today->tm_year+1900 && smonth == today->tm_mon && sday == today->tm_mday){
    while (seconds < 0)
     seconds = seconds + Interval;
    goto daylight_calculation;
   }
   Passed = FALSE;
   if (syear < today->tm_year+1900)
    Passed = TRUE;
   else if (syear == (today->tm_year+1900) && smonth < today->tm_mon)
    Passed = TRUE;
   else if (syear == (today->tm_year+1900) && smonth == today->tm_mon && sday < today->tm_mday)
    Passed = TRUE;
   if (Passed) {
    int x;
    x = syear;
    syear = yearoffset;
    yearoffset = x;
    x=smonth;
    smonth = monthoffset;
    monthoffset = x;
    x=sday;
    sday=dayoffset;
    dayoffset = x;
   }
   break;
 case EveryWeekDay:
  if (schedTime[type].DaysOfWeek[today->tm_wday] && (
   schedTime[type].WeeksOfMonth[(today->tm_mday-1)/7] || (
   !((LastDay-today->tm_mday)/7) && schedTime[type].WeeksOfMonth[5]
  )
  ) ) {
   if (seconds > 0)
    goto daylight_calculation;
  }
  wday = today->tm_wday;
  wday++;
  if (wday>=7)
   wday -= 7;
  break;
 case EveryMonthDay:
  if ( ( schedTime[type].MonthsOfYear[today->tm_mon] &&
   schedTime[type].DaysOfMonth[today->tm_mday-1] ) ||
   ( ( LastDay == today->tm_mday ) &&
     ( ( ( schedTime[type].DaysOfMonth[today->tm_mon] ) &&
    ( schedTime[type].DaysOfMonth[LastDay-1] ) ) ||
      schedTime[type].DaysOfMonth[31])
     )
   ) {
    if (seconds > 0)
     goto daylight_calculation;
   }
   break;
 }
 if(LastDay == dayoffset){
  dayoffset = 0;
  monthoffset++;
 }
 if(monthoffset > 11) {
  monthoffset=0;
  yearoffset++;
 }
 for (year = yearoffset; year < yearoffset + yearoffset; year++ ){
  for(month = 0+monthoffset; month < 12; month++ ){
   LastDay = DaysInMonth(year, month);
   for (day=1+dayoffset; day <= LastDay; day++){
    switch(schedTime[type].State){
     case FixedInterval:
      if(year == syear && month == smonth && day == sday){
       if(Passed){
        seconds = -1 * accumulatedDays * 86400 + seconds;
        while(seconds <0)
         seconds += Interval;
       } else {
        seconds = (accumulatedDays) * 86400 + seconds;
       }
       goto daylight_calculation;
      }
      break;
     case EveryWeekDay:
      if (schedTime[type].DaysOfWeek[wday] && (
       schedTime[type].WeeksOfMonth[(day-1)/7] || (
        !((LastDay-day)/7) && schedTime[type].WeeksOfMonth[5] ) ) ) {
       seconds = (accumulatedDays)*86400 + seconds;
       goto daylight_calculation;
      }
      wday++;
      if (wday>=7)
       wday -= 7;
      break;
     case EveryMonthDay:
      if ( ( ( schedTime[type].MonthsOfYear[month] ) && ( schedTime[type].DaysOfMonth[day-1] ) ) ||
       ( ( day == LastDay ) &&
         ( ( schedTime[type].MonthsOfYear[month] ) &&
           ( ( schedTime[type].DaysOfMonth[LastDay-1] ) ||
             ( schedTime[type].DaysOfMonth[31] )
           )
         )
       )
          ) {
       seconds = accumulatedDays * 86400 + seconds;
       goto daylight_calculation;
      }
      break;
     }
     accumulatedDays++;
    }
    dayoffset = 0;
   }
   monthoffset = 0;
  }
  return 1;
 daylight_calculation:
  if (DaylightSavings(theTime) && !(DaylightSavings(theTime+seconds)))
   seconds += 3600;
  if (!DaylightSavings(theTime) && (DaylightSavings(theTime+seconds)))
   seconds -= 3600;
  if (seconds == 1)
   seconds = seconds + 60;
  return ( seconds + 1 );
}

variable_types: struct mytime { int State; int StartOnNextMinute; int Applied; int MonthsOfYear[12]; int DaysOfWeek[7]; int StartTime[6]; int Every[3]; int WeeksOfMonth[7]; int DaysOfMonth[33]; } []

variable_types: type int

variable_types: seconds long

variable_types: LastDay int

variable_types: yearrange int

variable_types: wday int

variable_types: accumulatedDays int

variable_types: yearoffset int

variable_types: monthoffset int

variable_types: dayoffset int

variable_types: syear int

variable_types: smonth int

variable_types: sday int

variable_types: smeridian int

variable_types: sminute int

variable_types: shour int

variable_types: Interval int

variable_types: Passed int

variable_types: x int

return_type: unsigned long


PrintFileName

decompiled_code:
int __fastcall PrintFileName(const char *a1, unsigned int a2)
{
return printf("%s %d\n", a1, a2);
}

canonical_decompiled_code:
int __fastcall func0(const char *a1, unsigned int a2)
{
return printf("%s %d\n", a1, a2);
}

original_code:
void
PrintFileName (char *name, int depth)
{
  printf ("%s %d\n", name, depth);
}

canonical_original_code:
void PrintFileName(char *name, int depth)
{
  printf ("%s %d\n", name, depth);
}

variable_types:
name
char *

variable_types: depth int


extMatch

decompiled_code:
__int64 __fastcall extMatch(const char *a1, const char *a2)
{
int v2; // er12
__int64 v3; // rax
int v4; // er12

if ( !a1 )
return 0LL;
if ( !a2 )
return 0LL;
v2 = strlen(a1);
LODWORD(v3) = strlen(a2);
if ( v2 < (int)v3 )
return 0LL;
v4 = v2 - v3;
if ( (_DWORD)v3 )
{
v3 = (int)v3;
while ( a2[v3 - 1] == a1[v4 - 1 + v3] )
{
if ( !(_DWORD)--v3 )
return 1LL;
}
return 0LL;
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(const char *a1, const char *a2)
{
int v2; // er12
__int64 v3; // rax
int v4; // er12

if ( !a1 )
return 0LL;
if ( !a2 )
return 0LL;
v2 = strlen(a1);
LODWORD(v3) = strlen(a2);
if ( v2 < (int)v3 )
return 0LL;
v4 = v2 - v3;
if ( (_DWORD)v3 )
{
v3 = (int)v3;
while ( a2[v3 - 1] == a1[v4 - 1 + v3] )
{
if ( !(_DWORD)--v3 )
return 1LL;
}
return 0LL;
}
return 1LL;
}

original_code:
int extMatch(char * name, char * extension){
 int nameLen,
     extLen;
 if (!name || !extension)
  return 0;
 nameLen = strlen(name);
 extLen = strlen(extension);
 if (extLen > nameLen)
  return 0;
 nameLen = nameLen - extLen;
 for (; extLen && extension[extLen-1] == name[nameLen+extLen-1]; extLen--)
  ;
 if (extLen)
  return 0;
 else
  return 1;
}

canonical_original_code:
int extMatch(char *name, char *extension){
 int nameLen; int extLen;
 if (!name || !extension)
  return 0;
 nameLen = strlen(name);
 extLen = strlen(extension);
 if (extLen > nameLen)
  return 0;
 nameLen = nameLen - extLen;
 for (; extLen && extension[extLen-1] == name[nameLen+extLen-1]; extLen--)
  ;
 if (extLen)
  return 0;
 else
  return 1;
}

variable_types:
extension
char *

variable_types: nameLen int

variable_types: extLen int


ScanRegularFiles

decompiled_code:
void __fastcall ScanRegularFiles(__int64 a1, int a2, const char *a3, unsigned int a4, void (__fastcall *a5)(__int64, _QWORD))
{
__int64 v8; // rdx
__int64 v9; // rbp
__int64 *v10; // rbx
__int64 v11; // rax
struct stat v12; // [rsp-18h] [rbp-C8h] BYREF

if ( a2 )
{
v8 = 8LL * (a2 - 1);
v9 = a1 + v8 - 8 - 8LL * (unsigned int)(a2 - 1);
v10 = (__int64 *)(a1 + v8);
do
{
while ( lstat((const char *)(*v10 + 19), &v12) == -1
|| (v12.st_mode & 0xF000) != 0x8000
|| !(unsigned int)extMatch((const char *)(*v10 + 19), a3) )
{
if ( --v10 == (__int64 *)v9 )
return;
}
v11 = *v10--;
a5(v11 + 19, a4);
}
while ( v10 != (__int64 *)v9 );
}
}

original_code:
void
ScanRegularFiles (struct dirent **namelist, int n, char *extension,
    int currentDepth, FoundFile * function)
{
  struct stat sb;
  int length;
  while (n--)
    {
      length = strlen (namelist[n]->d_name);
      if (lstat (namelist[n]->d_name, &sb) != -1)
 {
   switch (sb.st_mode & 0170000)
     {
     case 0100000:
       if (extMatch(namelist[n]->d_name, extension))
  (*function) (namelist[n]->d_name, currentDepth);
       break;
     }
 }
    }
}

canonical_original_code:
void ScanRegularFiles(struct dirent **namelist, int n, char *extension, int currentDepth, void (*function)(char *name, int depth))
{
  struct stat sb;
  int length;
  while (n--)
    {
      length = strlen (namelist[n]->d_name);
      if (lstat (namelist[n]->d_name, &sb) != -1)
 {
   switch (sb.st_mode & 0170000)
     {
     case 0100000:
       if (extMatch(namelist[n]->d_name, extension))
  (*function) (namelist[n]->d_name, currentDepth);
       break;
     }
 }
    }
}

variable_types: struct dirent { unsigned long d_ino; long d_off; unsigned short d_reclen; unsigned char d_type; char d_name[256]; } **

variable_types: n int

variable_types: currentDepth int

variable_types:
function
void (*)(char *name, int depth)

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

variable_types: length int

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


PrivateScanDir

decompiled_code:
__int64 __fastcall PrivateScanDir(char *path, const char *a2, void (__fastcall *a3)(__int64, _QWORD), int a4, int a5, int a6, int a7)
{
int v9; // ebp
int v11; // er8
__int64 result; // rax
int v13; // eax
struct dirent **v14; // rdi
unsigned int v15; // er10
int v16; // edx
__int64 v17; // rbx
unsigned __int64 v18; // rbp
struct dirent *v19; // rdi
int v21; // [rsp+8h] [rbp-1050h]
int v22; // [rsp+Ch] [rbp-104Ch]
int v23; // [rsp+Ch] [rbp-104Ch]
struct dirent **namelist; // [rsp+18h] [rbp-1040h] BYREF
char buf[4152]; // [rsp+20h] [rbp-1038h] BYREF

v9 = (int)path;
getcwd(buf, 0x1000uLL);
v11 = chdir(path);
result = 1LL;
if ( v11 != -1 )
{
v13 = scandir(".", &namelist, 0LL, (int (*)(const struct dirent **, const struct dirent **))&alphasort);
if ( v13 < 0 )
{
perror("scandir");
chdir(buf);
return 0LL;
}
v14 = namelist;
v15 = a5 + 1;
if ( a7 )
{
if ( a7 != 1 )
{
v16 = v13 - 1;
if ( v13 )
goto LABEL_6;
LABEL_8:
free(v14);
chdir(buf);
return 1LL;
}
v22 = v13;
ScanDirectoryFiles(v9, (_DWORD)a2, (_DWORD)a3, a4, v15, a6, 1, (__int64)namelist, v13);
ScanRegularFiles((__int64)namelist, v22, a2, a5 + 1, a3);
v13 = v22;
v14 = namelist;
v16 = v22 - 1;
if ( !v22 )
goto LABEL_8;
}
else
{
v23 = a5 + 1;
v21 = v13;
ScanRegularFiles((__int64)namelist, v13, a2, v15, a3);
ScanDirectoryFiles(v9, (_DWORD)a2, (_DWORD)a3, a4, v23, a6, 0, (__int64)namelist, v21);
v13 = v21;
v14 = namelist;
v16 = v21 - 1;
if ( !v21 )
goto LABEL_8;
}
LABEL_6:
v17 = 8LL * v16;
v18 = 8 * (v13 - (unsigned __int64)(unsigned int)v16) - 16;
do
{
v19 = v14[(unsigned __int64)v17 / 8];
v17 -= 8LL;
free(v19);
v14 = namelist;
}
while ( v17 != v18 );
goto LABEL_8;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(char *path, const char *a2, void (__fastcall *a3)(__int64, _QWORD), int a4, int a5, int a6, int a7)
{
int v9; // ebp
int v11; // er8
__int64 result; // rax
int v13; // eax
struct dirent **v14; // rdi
unsigned int v15; // er10
int v16; // edx
__int64 v17; // rbx
unsigned __int64 v18; // rbp
struct dirent *v19; // rdi
int v21; // [rsp+8h] [rbp-1050h]
int v22; // [rsp+Ch] [rbp-104Ch]
int v23; // [rsp+Ch] [rbp-104Ch]
struct dirent **namelist; // [rsp+18h] [rbp-1040h] BYREF
char buf[4152]; // [rsp+20h] [rbp-1038h] BYREF

v9 = (int)path;
getcwd(buf, 0x1000uLL);
v11 = chdir(path);
result = 1LL;
if ( v11 != -1 )
{
v13 = scandir(".", &namelist, 0LL, (int (*)(const struct dirent **, const struct dirent **))&alphasort);
if ( v13 < 0 )
{
perror("scandir");
chdir(buf);
return 0LL;
}
v14 = namelist;
v15 = a5 + 1;
if ( a7 )
{
if ( a7 != 1 )
{
v16 = v13 - 1;
if ( v13 )
goto LABEL_6;
LABEL_8:
free(v14);
chdir(buf);
return 1LL;
}
v22 = v13;
func4(v9, (_DWORD)a2, (_DWORD)a3, a4, v15, a6, 1, (__int64)namelist, v13);
func2((__int64)namelist, v22, a2, a5 + 1, a3);
v13 = v22;
v14 = namelist;
v16 = v22 - 1;
if ( !v22 )
goto LABEL_8;
}
else
{
v23 = a5 + 1;
v21 = v13;
func2((__int64)namelist, v13, a2, v15, a3);
func4(v9, (_DWORD)a2, (_DWORD)a3, a4, v23, a6, 0, (__int64)namelist, v21);
v13 = v21;
v14 = namelist;
v16 = v21 - 1;
if ( !v21 )
goto LABEL_8;
}
LABEL_6:
v17 = 8LL * v16;
v18 = 8 * (v13 - (unsigned __int64)(unsigned int)v16) - 16;
do
{
v19 = v14[(unsigned __int64)v17 / 8];
v17 -= 8LL;
free(v19);
v14 = namelist;
}
while ( v17 != v18 );
goto LABEL_8;
}
return result;
}

original_code:
int
PrivateScanDir (char *name, char *extension, FoundFile * function,
  int maxDepth, int currentDepth, int includeDir,
  int SearchDirection)
{
  struct dirent **namelist;
  int n;
  char oldpath[4096];
  int ignore;
  ignore = (int) getcwd (oldpath, 4096);
  if (chdir (name) == -1)
    return Continue;
  n = scandir (".", &namelist, 0, alphasort);
  if (n < 0)
    {
      perror ("scandir");
       ignore = chdir (oldpath);
      return 0;
    }
  else
    {
      currentDepth++;
      switch (SearchDirection)
 {
 case PreOrder:
   ScanRegularFiles (namelist, n, extension, currentDepth, function);
   ScanDirectoryFiles (name, extension, function, maxDepth,
         currentDepth, includeDir, SearchDirection,
         namelist, n);
   break;
 case PostOrder:
   ScanDirectoryFiles (name, extension, function, maxDepth,
         currentDepth, includeDir, SearchDirection,
         namelist, n);
   ScanRegularFiles (namelist, n, extension, currentDepth, function);
   break;
 }
    }
  while (n--){
   free(namelist[n]);
  }
  free(namelist);
  ignore = chdir (oldpath);
  return 1;
}

canonical_original_code:
int PrivateScanDir(char *name, char *extension, void (*function)(char *name, int depth), int maxDepth, int currentDepth, int includeDir, int SearchDirection)
{
  struct dirent **namelist;
  int n;
  char oldpath[4096];
  int ignore;
  ignore = (int) getcwd (oldpath, 4096);
  if (chdir (name) == -1)
    return Continue;
  n = scandir (".", &namelist, 0, alphasort);
  if (n < 0)
    {
      perror ("scandir");
       ignore = chdir (oldpath);
      return 0;
    }
  else
    {
      currentDepth++;
      switch (SearchDirection)
 {
 case PreOrder:
   ScanRegularFiles (namelist, n, extension, currentDepth, function);
   ScanDirectoryFiles (name, extension, function, maxDepth,
         currentDepth, includeDir, SearchDirection,
         namelist, n);
   break;
 case PostOrder:
   ScanDirectoryFiles (name, extension, function, maxDepth,
         currentDepth, includeDir, SearchDirection,
         namelist, n);
   ScanRegularFiles (namelist, n, extension, currentDepth, function);
   break;
 }
    }
  while (n--){
   free(namelist[n]);
  }
  free(namelist);
  ignore = chdir (oldpath);
  return 1;
}

variable_types: maxDepth int

variable_types: includeDir int

variable_types: SearchDirection int

variable_types:
oldpath
char [4096]

variable_types: ignore int

user_defined_types: struct dirent { unsigned long d_ino; long d_off; unsigned short d_reclen; unsigned char d_type; char d_name[256]; }


ScanDirectoryFiles

original_code:
void
ScanDirectoryFiles (char *name, char *extension, FoundFile * function,
      int maxDepth, int currentDepth, int includeDir,
      int SearchDirection, struct dirent **namelist, int n)
{
  struct stat sb;
  int length;
  while (n--)
    {
      length = strlen (namelist[n]->d_name);
      if (lstat (namelist[n]->d_name, &sb) != -1)
 {
   switch (sb.st_mode & 0170000)
     {
     case 0040000:
       if (SearchDirection == PreOrder)
  if (includeDir && extMatch(namelist[n]->d_name, extension))
    (*function) (namelist[n]->d_name, currentDepth);
       if (!(length = 1 && namelist[n]->d_name[0] == '.'))
  if (!(length = 2 && namelist[n]->d_name[0] == '.'
        && namelist[n]->d_name[1] == '.'))
    if (maxDepth >= currentDepth)
      PrivateScanDir (namelist[n]->d_name, extension, function,
        maxDepth, currentDepth, includeDir,
        SearchDirection);
       if (SearchDirection == PostOrder)
  if (includeDir && extMatch(namelist[n]->d_name, extension))
    (*function) (namelist[n]->d_name, currentDepth);
       break;
     }
 }
    }
}

canonical_original_code:
void ScanDirectoryFiles(char *name, char *extension, void (*function)(char *name, int depth), int maxDepth, int currentDepth, int includeDir, int SearchDirection, struct dirent **namelist, int n)
{
  struct stat sb;
  int length;
  while (n--)
    {
      length = strlen (namelist[n]->d_name);
      if (lstat (namelist[n]->d_name, &sb) != -1)
 {
   switch (sb.st_mode & 0170000)
     {
     case 0040000:
       if (SearchDirection == PreOrder)
  if (includeDir && extMatch(namelist[n]->d_name, extension))
    (*function) (namelist[n]->d_name, currentDepth);
       if (!(length = 1 && namelist[n]->d_name[0] == '.'))
  if (!(length = 2 && namelist[n]->d_name[0] == '.'
        && namelist[n]->d_name[1] == '.'))
    if (maxDepth >= currentDepth)
      PrivateScanDir (namelist[n]->d_name, extension, function,
        maxDepth, currentDepth, includeDir,
        SearchDirection);
       if (SearchDirection == PostOrder)
  if (includeDir && extMatch(namelist[n]->d_name, extension))
    (*function) (namelist[n]->d_name, currentDepth);
       break;
     }
 }
    }
}

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


ScanDir

decompiled_code:
__int64 __fastcall ScanDir(char *a1, const char *a2, void (__fastcall *a3)(__int64, _QWORD), int a4, int a5, int a6)
{
return PrivateScanDir(a1, a2, a3, a4 - 1, 0, a5, a6);
}

canonical_decompiled_code:
__int64 __fastcall func5(char *a1, const char *a2, void (__fastcall *a3)(__int64, _QWORD), int a4, int a5, int a6)
{
return func3(a1, a2, a3, a4 - 1, 0, a5, a6);
}

original_code:
int
ScanDir (char *name, char *extension, FoundFile * function, int maxDepth,
  int includeDir, int SearchDirection)
{
  return PrivateScanDir (name, extension, function, --maxDepth, 0, includeDir,
    SearchDirection);
}

canonical_original_code:
int ScanDir(char *name, char *extension, void (*function)(char *name, int depth), int maxDepth, int includeDir, int SearchDirection)
{
  return PrivateScanDir (name, extension, function, --maxDepth, 0, includeDir,
    SearchDirection);
}


CreateObject

decompiled_code:
// attributes: thunk
__int64 __fastcall CreateObject(__int64 a1, __int64 a2)
{
return CreateContainer_localalias(a1, a2);
}

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

original_code:
NodeObj
CreateObject(NodeObj container, char * classname){
 NodeObj temp = NewNode();
 SetName(temp, classname);
 AddChild(container, temp);
 return temp;
}

canonical_original_code:
void *CreateObject(void *container, char *classname){
 void *temp = NewNode();
 SetName(temp, classname);
 AddChild(container, temp);
 return temp;
}

variable_types:
container
void *

variable_types:
classname
char *

variable_types:
temp
void *


AddConnectFrom

decompiled_code:
void AddConnectFrom()
{
;
}

canonical_decompiled_code:
void func3()
{
;
}

original_code:
void AddConnectFrom(NodeObj toNode, NodeObj fromNode){
}

canonical_original_code:
void AddConnectFrom(void *toNode, void *fromNode){
}

variable_types:
toNode
void *

variable_types:
fromNode
void *


Connect

decompiled_code:
__int64 __fastcall Connect(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
((void (*)(void))GetPropNode)();
GetPropNode(a3, a4);
AddConnectTo_localalias();
AddConnectFrom();
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
((void (*)(void))GetPropNode)();
GetPropNode(a3, a4);
func2();
func3();
return 0LL;
}

original_code:
int
Connect(NodeObj fromNode, char * from, NodeObj toNode, char * to){
 NodeObj nfrom = GetPropNode(fromNode, from);
 NodeObj nto= GetPropNode(toNode, to);
 AddConnectTo(nfrom, toNode);
 AddConnectFrom(fromNode, nto);
 return 0;
}

canonical_original_code:
int Connect(void *fromNode, char *from, void *toNode, char *to){
 void *nfrom = GetPropNode(fromNode, from);
 void *nto = GetPropNode(toNode, to);
 AddConnectTo(nfrom, toNode);
 AddConnectFrom(fromNode, nto);
 return 0;
}

variable_types:
from
char *

variable_types:
to
char *

variable_types:
nfrom
void *

variable_types:
nto
void *


Register

decompiled_code:
__int64 __fastcall Register(const char *a1, const char *a2, const char *a3, __int64 a4)
{
__int64 v6; // r12
char v8[312]; // [rsp+0h] [rbp-138h] BYREF

v6 = NewNode();
SetName(v6, a1);
SetPropStr(v6, "Company", a2);
SetPropStr(v6, "UUID", a3);
SetPropInt(v6, "ObjectHandle", (unsigned int)a4);
SetPropInt(v6, "State", 1LL);
sprintf(v8, "Registering object '%s' company '%s' uuid '%s' memhandle at %lu", a1, a2, a3, a4);
DebugPrint(v8, "object.c", 67LL, 3LL);
AddChild(RegObjList, v6);
return v6;
}

canonical_decompiled_code:
__int64 __fastcall func5(const char *a1, const char *a2, const char *a3, __int64 a4)
{
__int64 v6; // r12
char v8[312]; // [rsp+0h] [rbp-138h] BYREF

v6 = NewNode();
SetName(v6, a1);
SetPropStr(v6, "Company", a2);
SetPropStr(v6, "UUID", a3);
SetPropInt(v6, "ObjectHandle", (unsigned int)a4);
SetPropInt(v6, "State", 1LL);
sprintf(v8, "Registering object '%s' company '%s' uuid '%s' memhandle at %lu", a1, a2, a3, a4);
DebugPrint(v8, "object.c", 67LL, 3LL);
AddChild(RegObjList, v6);
return v6;
}

original_code:
NodeObj
Register(char * classname, char * company, char * uuid, msgobj objhndl){
 char buffer[255];
 NodeObj temp = NewNode();
 SetName(temp, classname);
 SetPropStr(temp, "Company", company);
 SetPropStr(temp, "UUID", uuid);
 SetPropInt(temp, "ObjectHandle", (int)objhndl);
 SetPropInt(temp, "State", 1);
 sprintf((char *)&buffer, "Registering object '%s' company '%s' uuid '%s' memhandle at %lu", classname, company, uuid, (unsigned long) objhndl);
 DebugPrint ((char *)&buffer, "object.c", 67, REGISTER);
 AddChild(RegObjList, temp);
 return temp;
}

canonical_original_code:
void *Register(char *classname, char *company, char *uuid, int (*objhndl)(void *instance, int message, void *data)){
 char buffer[255];
 void *temp = NewNode();
 SetName(temp, classname);
 SetPropStr(temp, "Company", company);
 SetPropStr(temp, "UUID", uuid);
 SetPropInt(temp, "ObjectHandle", (int)objhndl);
 SetPropInt(temp, "State", 1);
 sprintf((char *)&buffer, "Registering object '%s' company '%s' uuid '%s' memhandle at %lu", classname, company, uuid, (unsigned long) objhndl);
 DebugPrint ((char *)&buffer, "object.c", 67, REGISTER);
 AddChild(RegObjList, temp);
 return temp;
}

variable_types:
company
char *

variable_types:
uuid
char *

variable_types: int (*)(void *instance, int message, void *data)

variable_types:
buffer
char [255]


Unregister

decompiled_code:
__int64 __fastcall Unregister(__int64 a1)
{
const char *v1; // rax
char v3[280]; // [rsp+0h] [rbp-118h] BYREF

v1 = (const char *)GetNameStr();
sprintf(v3, "Unregistering object '%s'", v1);
DebugPrint(v3, "object.c", 83LL, 3LL);
return SetPropInt(a1, "State", 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
const char *v1; // rax
char v3[280]; // [rsp+0h] [rbp-118h] BYREF

v1 = (const char *)GetNameStr();
sprintf(v3, "Unregistering object '%s'", v1);
DebugPrint(v3, "object.c", 83LL, 3LL);
return SetPropInt(a1, "State", 0LL);
}

original_code:
void
Unregister(NodeObj node){
 char buffer[255];
 sprintf((char *)&buffer, "Unregistering object '%s'", GetNameStr(node));
 DebugPrint ((char *)&buffer, "object.c", 83, REGISTER);
 SetPropInt(node, "State", 0);
}

canonical_original_code:
void Unregister(void *node){
 char buffer[255];
 sprintf((char *)&buffer, "Unregistering object '%s'", GetNameStr(node));
 DebugPrint ((char *)&buffer, "object.c", 83, REGISTER);
 SetPropInt(node, "State", 0);
}

variable_types:
node
void *


AllocNSObj

decompiled_code:
void *AllocNSObj()
{
return NSCreate_localalias();
}

canonical_decompiled_code:
void *func2()
{
return func0();
}

original_code:
NSObj * AllocNSObj(){
 NSObj * Root;
        Root = (NSObj *)calloc(sizeof(NSObj), 1);
 if (Root == ((void *)0))
  return ((void *)0);
 return Root;
}

canonical_original_code:
struct NSObj *AllocNSObj(){
 struct NSObj *Root;
        Root = (struct NSObj *)calloc(sizeof(NSObj), 1);
 if (Root == ((void *)0))
  return ((void *)0);
 return Root;
}

variable_types: struct NSObj { struct NSObj *Child; struct NSObj *Next; char Character; long Value; } *