containObject

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

v2 = *a1;
if ( !*a1 )
return 0LL;
while ( strcmp(*(const char **)v2, a2) )
{
v2 = *(_QWORD *)(v2 + 8);
if ( !v2 )
return 0LL;
}
return 1LL;
}

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

v2 = *a1;
if ( !*a1 )
return 0LL;
while ( strcmp(*(const char **)v2, a2) )
{
v2 = *(_QWORD *)(v2 + 8);
if ( !v2 )
return 0LL;
}
return 1LL;
}

original_code:
int containObject(linkedList* list, char* obj){
 node* curr = list->head;
 while( curr != ((void *)0) ){
  char* objName = (char*)curr->data;
  if( strcmp(objName, obj) == 0){
   return 1;
  }
  curr = curr->next;
 }
 return 0;
}

canonical_original_code:
int containObject(struct list *list, char *obj){
 struct node_s *curr = list->head;
 while( curr != ((void *)0) ){
  char *objName = (char*)curr->data;
  if( strcmp(objName, obj) == 0){
   return 1;
  }
  curr = curr->next;
 }
 return 0;
}

variable_types:
objName
char *


getFileFromOther

decompiled_code:
__int64 __fastcall getFileFromOther(_QWORD **a1, const char *a2)
{
_QWORD *v2; // rbx
__int64 v3; // rbp

v2 = *a1;
if ( !*a1 )
return 0LL;
while ( 1 )
{
v3 = *v2;
if ( (unsigned int)containObject(*(__int64 **)(*v2 + 16LL), a2) )
break;
v2 = (_QWORD *)v2[1];
if ( !v2 )
return 0LL;
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func4(_QWORD **a1, const char *a2)
{
_QWORD *v2; // rbx
__int64 v3; // rbp

v2 = *a1;
if ( !*a1 )
return 0LL;
while ( 1 )
{
v3 = *v2;
if ( (unsigned int)func3(*(__int64 **)(*v2 + 16LL), a2) )
break;
v2 = (_QWORD *)v2[1];
if ( !v2 )
return 0LL;
}
return v3;
}

original_code:
routingEntry* getFileFromOther(linkedList* list, char* obj){
 node* curr = list->head;
 while( curr != ((void *)0) ){
  routingEntry* re = (routingEntry*)curr->data;
  if( containObject(re->objects, obj)){
   return re;
  }
  curr = curr->next;
 }
 return ((void *)0);
}

canonical_original_code:
struct re *getFileFromOther(struct list *list, char *obj){
 struct node_s *curr = list->head;
 while( curr != ((void *)0) ){
  struct re *re = (routingEntry*)curr->data;
  if( containObject(re->objects, obj)){
   return re;
  }
  curr = curr->next;
 }
 return ((void *)0);
}

variable_types:
list
struct list *

variable_types:
obj
char *

variable_types: struct re { int nodeId; int nextHop; struct list { struct node_s { void *data; struct node_s *next; } *head; struct node_s *tail; } *neighbors; struct list *objects; struct re *parent; int visited; char *hostName; int routingPort; int localPort; int serverPort; int isNeighbor; int seqNumReceive; int ttl; int numFiles; int numLinks; struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } cli_addr; int neighborCountDown; int LSACountDown; int isDown; } *

user_defined_types: struct re { int nodeId; int nextHop; struct list *neighbors; struct list *objects; struct re *parent; int visited; char *hostName; int routingPort; int localPort; int serverPort; int isNeighbor; int seqNumReceive; int ttl; int numFiles; int numLinks; struct sockaddr_in cli_addr; int neighborCountDown; int LSACountDown; int isDown; }

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

user_defined_types: struct list { struct node_s *head; struct node_s *tail; }


freeNode

decompiled_code:
__int64 __fastcall freeNode(void *ptr)
{
__int64 v2; // rbp
void *v3; // rdi

if ( !ptr )
return 0LL;
v2 = *((_QWORD *)ptr + 1);
v3 = *(void **)ptr;
if ( v3 )
free(v3);
free(ptr);
return v2;
}

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

if ( !ptr )
return 0LL;
v2 = *((_QWORD *)ptr + 1);
v3 = *(void **)ptr;
if ( v3 )
free(v3);
free(ptr);
return v2;
}

original_code:
node* freeNode(node* n){
 node* next;
 next = ((void *)0);
 if ( n != ((void *)0) ){
  next = n->next;
  if( n->data != ((void *)0) ){
   free(n->data);
  }
  free(n);
 }
 return next;
}

canonical_original_code:
struct node_s *freeNode(struct node_s *n){
 struct node_s *next;
 next = ((void *)0);
 if ( n != ((void *)0) ){
  next = n->next;
  if( n->data != ((void *)0) ){
   free(n->data);
  }
  free(n);
 }
 return next;
}

variable_types:
n
struct node_s *

variable_types: struct node_s { void *data; struct node_s *next; } *


deleteRoutingEntry

decompiled_code:
void __fastcall deleteRoutingEntry(int a1)
{
_QWORD *v1; // rcx
_QWORD *v3; // rdi
__int64 v4; // rax

v1 = routing;
if ( **(_DWORD **)routing == a1 )
{
if ( *(&routing + 1) == routing )
{
free(routing);
routing = 0LL;
*(&routing + 1) = 0LL;
}
else
{
routing = (void *)*((_QWORD *)routing + 1);
free(v1);
}
}
else
{
v3 = (_QWORD *)*((_QWORD *)routing + 1);
if ( v3 )
{
while ( *(_DWORD *)*v3 != a1 )
{
v1 = v3;
if ( !v3[1] )
return;
v3 = (_QWORD *)v3[1];
}
v4 = v3[1];
v1[1] = v4;
if ( !v4 )
*(&routing + 1) = v1;
v3[1] = 0LL;
freeNode(v3);
}
}
}

canonical_decompiled_code:
void __fastcall func6(int a1)
{
_QWORD *v1; // rcx
_QWORD *v3; // rdi
__int64 v4; // rax

v1 = routing;
if ( **(_DWORD **)routing == a1 )
{
if ( *(&routing + 1) == routing )
{
free(routing);
routing = 0LL;
*(&routing + 1) = 0LL;
}
else
{
routing = (void *)*((_QWORD *)routing + 1);
free(v1);
}
}
else
{
v3 = (_QWORD *)*((_QWORD *)routing + 1);
if ( v3 )
{
while ( *(_DWORD *)*v3 != a1 )
{
v1 = v3;
if ( !v3[1] )
return;
v3 = (_QWORD *)v3[1];
}
v4 = v3[1];
v1[1] = v4;
if ( !v4 )
*(&routing + 1) = v1;
v3[1] = 0LL;
func5(v3);
}
}
}

original_code:
void deleteRoutingEntry(int nodeId){
 node* head = routing.head;
 routingEntry* re = (routingEntry*) head->data;
 if( re->nodeId == nodeId ){
  if( routing.head == routing.tail ){
   free(head);
   routing.head = ((void *)0);
   routing.tail = ((void *)0);
  }else{
   routing.head = routing.head->next;
   head->next = ((void *)0);
   free(head);
  }
  return;
 }
 node* curr = routing.head->next;
 node* pre = routing.head;
 while( curr != ((void *)0)){
  re = (routingEntry*) curr->data;
  if( re->nodeId == nodeId ){
   pre->next = curr->next;
   if( curr->next == ((void *)0)){
    routing.tail = pre;
   }
   curr->next = ((void *)0);
   freeNode(curr);
   return;
  }
  pre = curr;
  curr = curr->next;
 }
}

canonical_original_code:
void deleteRoutingEntry(int nodeId){
 struct node_s *head = routing.head;
 struct re *re = (routingEntry*) head->data;
 if( re->nodeId == nodeId ){
  if( routing.head == routing.tail ){
   free(head);
   routing.head = ((void *)0);
   routing.tail = ((void *)0);
  }else{
   routing.head = routing.head->next;
   head->next = ((void *)0);
   free(head);
  }
  return;
 }
 struct node_s *curr = routing.head->next;
 struct node_s *pre = routing.head;
 while( curr != ((void *)0)){
  re = (struct re *) curr->data;
  if( re->nodeId == nodeId ){
   pre->next = curr->next;
   if( curr->next == ((void *)0)){
    routing.tail = pre;
   }
   curr->next = ((void *)0);
   freeNode(curr);
   return;
  }
  pre = curr;
  curr = curr->next;
 }
}

variable_types: nodeId int

return_type: void

user_defined_types: struct node_s { void *data; struct node_s *next; }


printFile

decompiled_code:
int __fastcall printFile(__int64 a1)
{
__int64 i; // rbx
const char **v2; // rbp
int result; // eax

for ( i = a1; i; i = *(_QWORD *)(i + 8) )
{
v2 = *(const char ***)i;
puts(**(const char ***)i);
result = puts(v2[1]);
}
return result;
}

canonical_decompiled_code:
int __fastcall func8(__int64 a1)
{
__int64 i; // rbx
const char **v2; // rbp
int result; // eax

for ( i = a1; i; i = *(_QWORD *)(i + 8) )
{
v2 = *(const char ***)i;
puts(**(const char ***)i);
result = puts(v2[1]);
}
return result;
}

original_code:
void printFile(linkedList list){
 node* currentp = list.head;
    while(currentp != ((void *)0)){
        fileEntry* entryp = (fileEntry *)currentp->data;
        printf("%s\n",entryp->objectName);
        printf("%s\n",entryp->path);
        currentp = currentp->next;
    }
}

canonical_original_code:
void printFile(struct list list){
 struct node_s *currentp = list.head;
    while(currentp != ((void *)0)){
        struct fe *entryp = (fileEntry *)currentp->data;
        printf("%s\n",entryp->objectName);
        printf("%s\n",entryp->path);
        currentp = currentp->next;
    }
}

variable_types: struct list { struct node_s { void *data; struct node_s *next; } *head; struct node_s *tail; }

variable_types: struct fe { char *objectName; char *path; } *


printObjects

decompiled_code:
int __fastcall printObjects(__int64 *a1)
{
__int64 v1; // rbx

v1 = *a1;
printf("Objects: ");
for ( ; v1; v1 = *(_QWORD *)(v1 + 8) )
printf("%s ", *(const char **)v1);
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func9(__int64 *a1)
{
__int64 v1; // rbx

v1 = *a1;
printf("Objects: ");
for ( ; v1; v1 = *(_QWORD *)(v1 + 8) )
printf("%s ", *(const char **)v1);
return putchar(10);
}

original_code:
void printObjects(linkedList* list){
 node* currentp = list->head;
 printf("Objects: ");
    while(currentp != ((void *)0)){
        char* objectName = (char *)currentp->data;
        printf("%s  ",objectName);
        currentp = currentp->next;
    }
 printf("\n");
}

canonical_original_code:
void printObjects(struct list *list){
 struct node_s *currentp = list->head;
 printf("Objects: ");
    while(currentp != ((void *)0)){
        char *objectName = (char *)currentp->data;
        printf("%s  ",objectName);
        currentp = currentp->next;
    }
 printf("\n");
}

variable_types: struct list { struct node_s { void *data; struct node_s *next; } *head; struct node_s *tail; } *

variable_types:
objectName
char *


printLinks

decompiled_code:
int __fastcall printLinks(unsigned int ***a1)
{
unsigned int **v1; // rbx

v1 = *a1;
printf("Neighbors: ");
for ( ; v1; v1 = (unsigned int **)v1[1] )
printf("%d ", **v1);
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func10(unsigned int ***a1)
{
unsigned int **v1; // rbx

v1 = *a1;
printf("Neighbors: ");
for ( ; v1; v1 = (unsigned int **)v1[1] )
printf("%d ", **v1);
return putchar(10);
}

original_code:
void printLinks(linkedList* list){
 node* currentp = list->head;
 printf("Neighbors: ");
    while(currentp != ((void *)0)){
        int* id = (int *)currentp->data;
        printf("%d  ",*id);
        currentp = currentp->next;
    }
 printf("\n");
}

canonical_original_code:
void printLinks(struct list *list){
 struct node_s *currentp = list->head;
 printf("Neighbors: ");
    while(currentp != ((void *)0)){
        int *id = (int *)currentp->data;
        printf("%d  ",*id);
        currentp = currentp->next;
    }
 printf("\n");
}

variable_types:
id
int *


printRouting

decompiled_code:
int __fastcall printRouting(_QWORD *a1)
{
_QWORD *v1; // rbp
unsigned int *v3; // rax
unsigned int *v4; // rbx
__int64 v5; // rsi

v1 = a1;
puts("\n--------------ROUTING TABLE-------------");
if ( a1 )
{
do
{
v4 = (unsigned int *)*v1;
if ( !*(_DWORD *)(*v1 + 104LL) )
{
v5 = *v4;
if ( (_DWORD)v5 == mynodeID )
printf("*Node %d, ", v5);
else
printf("Node %d, ", v5);
printf("nextHop %d, ", v4[1]);
printf("isDown %d, ", v4[26]);
printf("isVisited %d, ", v4[8]);
v3 = (unsigned int *)*((_QWORD *)v4 + 3);
if ( v3 )
printf("parentNode: %d\n", *v3);
else
puts("parent: unknown");
printObjects(*((__int64 **)v4 + 2));
printLinks(*((unsigned int ****)v4 + 1));
}
v1 = (_QWORD *)v1[1];
}
while ( v1 );
}
return puts("----------------------------------------\n");
}

canonical_decompiled_code:
int __fastcall func11(_QWORD *a1)
{
_QWORD *v1; // rbp
unsigned int *v3; // rax
unsigned int *v4; // rbx
__int64 v5; // rsi

v1 = a1;
puts("\n--------------ROUTING TABLE-------------");
if ( a1 )
{
do
{
v4 = (unsigned int *)*v1;
if ( !*(_DWORD *)(*v1 + 104LL) )
{
v5 = *v4;
if ( (_DWORD)v5 == mynodeID )
printf("*Node %d, ", v5);
else
printf("Node %d, ", v5);
printf("nextHop %d, ", v4[1]);
printf("isDown %d, ", v4[26]);
printf("isVisited %d, ", v4[8]);
v3 = (unsigned int *)*((_QWORD *)v4 + 3);
if ( v3 )
printf("parentNode: %d\n", *v3);
else
puts("parent: unknown");
func9(*((__int64 **)v4 + 2));
func10(*((unsigned int ****)v4 + 1));
}
v1 = (_QWORD *)v1[1];
}
while ( v1 );
}
return puts("----------------------------------------\n");
}

original_code:
void printRouting(linkedList list){
    node* currentp = list.head;
 printf("\n--------------ROUTING TABLE-------------\n");
    while( currentp != ((void *)0) ){
        routingEntry* entryp = (routingEntry *)currentp->data;
  if( !entryp->isDown){
  if( entryp->nodeId == mynodeID){
   printf("*Node %d, ", entryp->nodeId);
  }else{
   printf("Node %d, ", entryp->nodeId);
  }
  printf("nextHop %d, ", entryp->nextHop);
  printf("isDown %d, ", entryp->isDown);
  printf("isVisited %d, ", entryp->visited);
  if( entryp->parent == ((void *)0) ){
   printf("parent: unknown\n");
  }else{
   printf("parentNode: %d\n", entryp->parent->nodeId);
  }
  printObjects(entryp->objects);
  printLinks(entryp->neighbors);
 }
        currentp = currentp->next;
    }
 printf("----------------------------------------\n\n");
}

canonical_original_code:
void printRouting(struct list list){
    struct node_s *currentp = list.head;
 printf("\n--------------ROUTING TABLE-------------\n");
    while( currentp != ((void *)0) ){
        struct re *entryp = (routingEntry *)currentp->data;
  if( !entryp->isDown){
  if( entryp->nodeId == mynodeID){
   printf("*Node %d, ", entryp->nodeId);
  }else{
   printf("Node %d, ", entryp->nodeId);
  }
  printf("nextHop %d, ", entryp->nextHop);
  printf("isDown %d, ", entryp->isDown);
  printf("isVisited %d, ", entryp->visited);
  if( entryp->parent == ((void *)0) ){
   printf("parent: unknown\n");
  }else{
   printf("parentNode: %d\n", entryp->parent->nodeId);
  }
  printObjects(entryp->objects);
  printLinks(entryp->neighbors);
 }
        currentp = currentp->next;
    }
 printf("----------------------------------------\n\n");
}


printRoutingEntry

decompiled_code:
int __fastcall printRoutingEntry(unsigned int *a1)
{
printf("NodeId: %d\n", *a1);
printf("TTL: %d\n", a1[17]);
printf("Seq Num received: %d\n", a1[16]);
printf("Number of files: %d\n", a1[18]);
return printf("Number of links: %d\n", a1[19]);
}

canonical_decompiled_code:
int __fastcall func12(unsigned int *a1)
{
printf("NodeId: %d\n", *a1);
printf("TTL: %d\n", a1[17]);
printf("Seq Num received: %d\n", a1[16]);
printf("Number of files: %d\n", a1[18]);
return printf("Number of links: %d\n", a1[19]);
}

original_code:
void printRoutingEntry(routingEntry* re){
 printf("NodeId: %d\n", re->nodeId);
 printf("TTL: %d\n", re->ttl);
 printf("Seq Num received: %d\n", re->seqNumReceive);
 printf("Number of files: %d\n", re->numFiles);
 printf("Number of links: %d\n", re->numLinks);
}

canonical_original_code:
void printRoutingEntry(struct re *re){
 printf("NodeId: %d\n", re->nodeId);
 printf("TTL: %d\n", re->ttl);
 printf("Seq Num received: %d\n", re->seqNumReceive);
 printf("Number of files: %d\n", re->numFiles);
 printf("Number of links: %d\n", re->numLinks);
}


resolvNeighbor

decompiled_code:
__int64 __fastcall resolvNeighbor(__int64 a1)
{
const char ***v1; // rbx
const char **v2; // rbp
char *v3; // rax

v1 = (const char ***)routing;
if ( !routing )
return 0xFFFFFFFFLL;
do
{
v2 = *v1;
if ( *((_DWORD *)*v1 + 15) )
{
v3 = inet_ntoa(*(struct in_addr *)((char *)&a1 + 4));
if ( !strcmp(v2[5], v3) && *((_DWORD *)v2 + 12) == (unsigned __int16)_bswap_16(SWORD1(a1)) )
return *(unsigned int *)v2;
}
v1 = (const char ***)v1[1];
}
while ( v1 );
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1)
{
const char ***v1; // rbx
const char **v2; // rbp
char *v3; // rax

v1 = (const char ***)routing;
if ( !routing )
return 0xFFFFFFFFLL;
do
{
v2 = *v1;
if ( *((_DWORD *)*v1 + 15) )
{
v3 = inet_ntoa(*(struct in_addr *)((char *)&a1 + 4));
if ( !strcmp(v2[5], v3) && *((_DWORD *)v2 + 12) == (unsigned __int16)func0(SWORD1(a1)) )
return *(unsigned int *)v2;
}
v1 = (const char ***)v1[1];
}
while ( v1 );
return 0xFFFFFFFFLL;
}

original_code:
int resolvNeighbor(struct sockaddr_in cli_addr){
 node* curr = routing.head;
 while( curr != ((void *)0)){
  routingEntry* re = (routingEntry *)curr->data;
  if( re->isNeighbor){
   if( strcmp(re->hostName, inet_ntoa(cli_addr.sin_addr)) == 0 && re->routingPort ==ntohs(cli_addr.sin_port) ){
    return re->nodeId;
   }
  }
  curr = curr->next;
 }
 return -1;
}

canonical_original_code:
int resolvNeighbor(struct sockaddr_in cli_addr){
 struct node_s *curr = routing.head;
 while( curr != ((void *)0)){
  struct re *re = (routingEntry *)curr->data;
  if( re->isNeighbor){
   if( strcmp(re->hostName, inet_ntoa(cli_addr.sin_addr)) == 0 && re->routingPort ==ntohs(cli_addr.sin_port) ){
    return re->nodeId;
   }
  }
  curr = curr->next;
 }
 return -1;
}

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

return_type: int


decreaseTTL

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

result = routing;
if ( routing )
{
do
{
--*(_DWORD *)(*result + 68LL);
result = (_QWORD *)result[1];
}
while ( result );
}
return result;
}

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

result = routing;
if ( routing )
{
do
{
--*(_DWORD *)(*result + 68LL);
result = (_QWORD *)result[1];
}
while ( result );
}
return result;
}

original_code:
void decreaseTTL(){
 node* curr = routing.head;
 while ( curr != ((void *)0) ){
  routingEntry* entryp = (routingEntry *)curr->data;
  entryp->ttl -= 1;
  curr = curr->next;
 }
}

canonical_original_code:
void decreaseTTL(){
 struct node_s *curr = routing.head;
 while ( curr != ((void *)0) ){
  struct re *entryp = (routingEntry *)curr->data;
  entryp->ttl -= 1;
  curr = curr->next;
 }
}


decompiled_code:
int __fastcall close_socket(int a1)
{
int result; // eax

result = close(a1);
if ( result )
{
fwrite("Failed closing socket.\n", 1uLL, 0x17uLL, stderr);
result = 1;
}
return result;
}

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

result = close(a1);
if ( result )
{
fwrite("Failed closing socket.\n", 1uLL, 0x17uLL, stderr);
result = 1;
}
return result;
}

original_code:
int close_socket(int sock)
{
    if (close(sock))
    {
        fprintf(stderr, "Failed closing socket.\n");
        return 1;
    }
    return 0;
}

variable_types: sock int


computeNextHop

decompiled_code:
__int64 __fastcall computeNextHop(unsigned int *a1, int a2)
{
unsigned int *v2; // rax

a1[8] = 0;
while ( 1 )
{
v2 = a1;
a1 = (unsigned int *)*((_QWORD *)a1 + 3);
if ( !a1 )
break;
if ( *a1 == a2 )
return *v2;
}
return 0xFFFFFFFFLL;
}

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

a1[8] = 0;
while ( 1 )
{
v2 = a1;
a1 = (unsigned int *)*((_QWORD *)a1 + 3);
if ( !a1 )
break;
if ( *a1 == a2 )
return *v2;
}
return 0xFFFFFFFFLL;
}

original_code:
int computeNextHop(routingEntry* destination,int srcId){
 destination->visited = 0;
 routingEntry* curr = destination;
 while( (curr->parent) && (curr->parent->nodeId != srcId )){
  curr = curr->parent;
 }
 if(curr->parent == ((void *)0)){
  return -1;
 }
 return curr->nodeId;
}

canonical_original_code:
int computeNextHop(struct re *destination, int srcId){
 destination->visited = 0;
 struct re *curr = destination;
 while( (curr->parent) && (curr->parent->nodeId != srcId )){
  curr = curr->parent;
 }
 if(curr->parent == ((void *)0)){
  return -1;
 }
 return curr->nodeId;
}

variable_types: srcId int


popQue

original_code:
routingEntry* popQue(linkedList* que){
 node* temp = que->head;
 if(que->head == que->tail){
  que->head = ((void *)0);
  que->tail = ((void *)0);
 }
 else{
  que->head = que->head->next;
 }
 temp->next = ((void *)0);
 free(temp);
 routingEntry* re = temp->data;
 return re;
}

canonical_original_code:
struct re *popQue(struct list *que){
 struct node_s *temp = que->head;
 if(que->head == que->tail){
  que->head = ((void *)0);
  que->tail = ((void *)0);
 }
 else{
  que->head = que->head->next;
 }
 temp->next = ((void *)0);
 free(temp);
 struct re *re = temp->data;
 return re;
}

variable_types:
que
struct list *

return_type: struct re { int nodeId; int nextHop; struct list { struct node_s { void *data; struct node_s *next; } *head; struct node_s *tail; } *neighbors; struct list *objects; struct re *parent; int visited; char *hostName; int routingPort; int localPort; int serverPort; int isNeighbor; int seqNumReceive; int ttl; int numFiles; int numLinks; struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } cli_addr; int neighborCountDown; int LSACountDown; int isDown; } *


computeParent

decompiled_code:
unsigned int *__fastcall computeParent(__int64 a1, __int64 a2)
{
unsigned int *result; // rax
unsigned int *v3; // rbp
unsigned int *v4; // rbx
unsigned int *v5; // r13
__int64 v6[7]; // [rsp+0h] [rbp-38h] BYREF

v6[0] = 0LL;
v6[1] = 0LL;
*(_DWORD *)(a2 + 32) = 1;
*(_QWORD *)(a2 + 24) = 0LL;
result = (unsigned int *)insert(v6, a2, 112LL);
while ( v6[0] )
{
v5 = (unsigned int *)popQue((__int64)v6);
printf("Pop node %d\n", *v5);
result = (unsigned int *)*((_QWORD *)v5 + 1);
v3 = *(unsigned int **)result;
if ( *(_QWORD *)result )
{
do
{
result = (unsigned int *)getRoutingEntry(a1, **(unsigned int **)v3);
v4 = result;
if ( result && !result[8] && !result[26] )
{
printf("child id: %d\n", *result);
*((_QWORD *)v4 + 3) = v5;
v4[8] = 1;
result = (unsigned int *)insert(v6, v4, 112LL);
}
v3 = (unsigned int *)*((_QWORD *)v3 + 1);
}
while ( v3 );
}
}
return result;
}

canonical_decompiled_code:
unsigned int *__fastcall func3(__int64 a1, __int64 a2)
{
unsigned int *result; // rax
unsigned int *v3; // rbp
unsigned int *v4; // rbx
unsigned int *v5; // r13
__int64 v6[7]; // [rsp+0h] [rbp-38h] BYREF

v6[0] = 0LL;
v6[1] = 0LL;
*(_DWORD *)(a2 + 32) = 1;
*(_QWORD *)(a2 + 24) = 0LL;
result = (unsigned int *)insert(v6, a2, 112LL);
while ( v6[0] )
{
v5 = (unsigned int *)func2((__int64)v6);
printf("Pop node %d\n", *v5);
result = (unsigned int *)*((_QWORD *)v5 + 1);
v3 = *(unsigned int **)result;
if ( *(_QWORD *)result )
{
do
{
result = (unsigned int *)getRoutingEntry(a1, **(unsigned int **)v3);
v4 = result;
if ( result && !result[8] && !result[26] )
{
printf("child id: %d\n", *result);
*((_QWORD *)v4 + 3) = v5;
v4[8] = 1;
result = (unsigned int *)insert(v6, v4, 112LL);
}
v3 = (unsigned int *)*((_QWORD *)v3 + 1);
}
while ( v3 );
}
}
return result;
}

original_code:
void computeParent(linkedList* rTable, routingEntry* sourcep){
 linkedList que;
 que.head = ((void *)0);
 que.tail = ((void *)0);
 sourcep->visited = 1;
 sourcep->parent = ((void *)0);
 insert(&que, sourcep, sizeof(routingEntry));
 while(que.head != ((void *)0)){
  routingEntry* cur = popQue(&que);
  printf("Pop node %d\n", cur->nodeId);
  node* child = cur->neighbors->head;
  while(child != ((void *)0)){
   routingEntry* childEntry = getRoutingEntry(rTable, *(int *)child->data);
   if((childEntry) && (childEntry->visited == 0) && (!childEntry->isDown)){
    printf("child id: %d\n", childEntry->nodeId);
    childEntry->parent = cur;
    childEntry->visited = 1;
    insert(&que, childEntry, sizeof(routingEntry));
   }
   child = child->next;
  }
 }
}

canonical_original_code:
void computeParent(struct list *rTable, struct re *sourcep){
 struct list que;
 que.head = ((void *)0);
 que.tail = ((void *)0);
 sourcep->visited = 1;
 sourcep->parent = ((void *)0);
 insert(&que, sourcep, sizeof(routingEntry));
 while(que.head != ((void *)0)){
  struct re *cur = popQue(&que);
  printf("Pop node %d\n", cur->nodeId);
  struct node_s *child = cur->neighbors->head;
  while(child != ((void *)0)){
   struct re *childEntry = getRoutingEntry(rTable, *(int *)child->data);
   if((childEntry) && (childEntry->visited == 0) && (!childEntry->isDown)){
    printf("child id: %d\n", childEntry->nodeId);
    childEntry->parent = cur;
    childEntry->visited = 1;
    insert(&que, childEntry, sizeof(routingEntry));
   }
   child = child->next;
  }
 }
}

variable_types: struct re { int nodeId; int nextHop; struct list *neighbors; struct list *objects; struct re *parent; int visited; char *hostName; int routingPort; int localPort; int serverPort; int isNeighbor; int seqNumReceive; int ttl; int numFiles; int numLinks; struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } cli_addr; int neighborCountDown; int LSACountDown; int isDown; } *


main

canonical_name: main

repo: dsiroky/phpchroot

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

v3 = getenv("PHPCFG_EXE");
v4 = getenv("PHPCFG_CFG");
if ( v3 && v4 )
execl(v3, v3, "-c", v4, 0LL);
else
printf("Content-type: text/html\n\ncfgerror\n%s\n%s", v3, v4);
return 0;
}

original_code:
int main(int argc, char **argv)
{
  char *phpexe = getenv("PHPCFG_EXE");
  char *phpcfg = getenv("PHPCFG_CFG");
  if ((phpexe == ((void *)0)) || (phpcfg == ((void *)0)))
  {
    printf("Content-type: text/html\n\ncfgerror\n%s\n%s", phpexe, phpcfg);
    return 0;
  }
  execl(phpexe, phpexe, "-c", phpcfg, ((void *)0));
  return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types:
phpexe
char *

variable_types:
phpcfg
char *


ccdprocparam

repo: dstndstn/dolphot

decompiled_code:
__int64 __fastcall ccdprocparam(char *s1, char *src)
{
unsigned int v2; // ebp
__int64 result; // rax
char *endptr; // [rsp+8h] [rbp-20h] BYREF

if ( !strcasecmp(s1, "imager") )
{
strcpy(imager, src);
result = 1LL;
}
else if ( !strcasecmp(s1, "typekw") )
{
strcpy(typekw, src);
result = 1LL;
}
else if ( !strcasecmp(s1, "filtkw") )
{
strcpy(filtkw, src);
result = 1LL;
}
else if ( !strcasecmp(s1, "oversec") )
{
strcpy(oversec, src);
result = 1LL;
}
else if ( !strcasecmp(s1, "zerobase") )
{
strcpy(zerobase, src);
result = 1LL;
}
else if ( !strcasecmp(s1, "darkbase") )
{
strcpy(darkbase, src);
result = 1LL;
}
else if ( !strcasecmp(s1, "darktime") )
{
strcpy(darktime, src);
result = 1LL;
}
else if ( !strcasecmp(s1, "flatbase") )
{
strcpy(flatbase, src);
result = 1LL;
}
else if ( !strcasecmp(s1, "trimsec") )
{
strcpy(trimsec, src);
result = 1LL;
}
else if ( !strcasecmp(s1, "datasec") )
{
strcpy(datasec, src);
result = 1LL;
}
else if ( !strcasecmp(s1, "ccdsize") )
{
strcpy(ccdsize, src);
result = 1LL;
}
else if ( !strcasecmp(s1, "ccdsec") )
{
strcpy(ccdsec, src);
result = 1LL;
}
else if ( !strcasecmp(s1, "detsec") )
{
strcpy(detsec, src);
result = 1LL;
}
else
{
v2 = strtol(src, &endptr, 10);
if ( *endptr )
{
result = 0LL;
}
else if ( !strcasecmp(s1, "SPECIAL") )
{
SPECIAL = v2;
if ( v2 > 1 )
perr("Mask image must be 0 or 1");
result = 1LL;
}
else if ( !strcasecmp(s1, "MASK") )
{
MASK = v2;
if ( v2 > 1 )
perr("Mask image must be 0 or 1");
result = 1LL;
}
else if ( !strcasecmp(s1, "OVERSCAN") )
{
OVERSCAN = v2;
if ( v2 > 2 )
perr("Overscan correction must be 0, 1, or 2");
result = 1LL;
}
else if ( !strcasecmp(s1, "ZERO") )
{
ZERO = v2;
if ( v2 > 1 )
perr("Zero correction must be 0 or 1");
result = 1LL;
}
else if ( !strcasecmp(s1, "DARK") )
{
DARK = v2;
result = 1LL;
if ( v2 > 1 )
perr("Dark correction must be 0 or 1");
}
else if ( !strcasecmp(s1, "FLAT") )
{
FLAT = v2;
result = 1LL;
if ( v2 > 1 )
perr("Flat correction must be 0 or 1");
}
else if ( !strcasecmp(s1, "TRIM") )
{
TRIM = v2;
result = 1LL;
if ( v2 > 1 )
perr("Trim image must be 0 or 1");
}
else if ( !strcasecmp(s1, "MERGEAMP") )
{
MERGEAMP = v2;
result = 1LL;
if ( v2 > 1 )
perr("Merge amplifiers must be 0 or 1");
}
else
{
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(char *s1, char *src)
{
unsigned int v2; // ebp
__int64 result; // rax
char *endptr; // [rsp+8h] [rbp-20h] BYREF

if ( !strcasecmp(s1, "imager") )
{
strcpy(imager, src);
result = 1LL;
}
else if ( !strcasecmp(s1, "typekw") )
{
strcpy(typekw, src);
result = 1LL;
}
else if ( !strcasecmp(s1, "filtkw") )
{
strcpy(filtkw, src);
result = 1LL;
}
else if ( !strcasecmp(s1, "oversec") )
{
strcpy(oversec, src);
result = 1LL;
}
else if ( !strcasecmp(s1, "zerobase") )
{
strcpy(zerobase, src);
result = 1LL;
}
else if ( !strcasecmp(s1, "darkbase") )
{
strcpy(darkbase, src);
result = 1LL;
}
else if ( !strcasecmp(s1, "darktime") )
{
strcpy(darktime, src);
result = 1LL;
}
else if ( !strcasecmp(s1, "flatbase") )
{
strcpy(flatbase, src);
result = 1LL;
}
else if ( !strcasecmp(s1, "trimsec") )
{
strcpy(trimsec, src);
result = 1LL;
}
else if ( !strcasecmp(s1, "datasec") )
{
strcpy(datasec, src);
result = 1LL;
}
else if ( !strcasecmp(s1, "ccdsize") )
{
strcpy(ccdsize, src);
result = 1LL;
}
else if ( !strcasecmp(s1, "ccdsec") )
{
strcpy(ccdsec, src);
result = 1LL;
}
else if ( !strcasecmp(s1, "detsec") )
{
strcpy(detsec, src);
result = 1LL;
}
else
{
v2 = strtol(src, &endptr, 10);
if ( *endptr )
{
result = 0LL;
}
else if ( !strcasecmp(s1, "SPECIAL") )
{
SPECIAL = v2;
if ( v2 > 1 )
func0("Mask image must be 0 or 1");
result = 1LL;
}
else if ( !strcasecmp(s1, "MASK") )
{
MASK = v2;
if ( v2 > 1 )
func0("Mask image must be 0 or 1");
result = 1LL;
}
else if ( !strcasecmp(s1, "OVERSCAN") )
{
OVERSCAN = v2;
if ( v2 > 2 )
func0("Overscan correction must be 0, 1, or 2");
result = 1LL;
}
else if ( !strcasecmp(s1, "ZERO") )
{
ZERO = v2;
if ( v2 > 1 )
func0("Zero correction must be 0 or 1");
result = 1LL;
}
else if ( !strcasecmp(s1, "DARK") )
{
DARK = v2;
result = 1LL;
if ( v2 > 1 )
func0("Dark correction must be 0 or 1");
}
else if ( !strcasecmp(s1, "FLAT") )
{
FLAT = v2;
result = 1LL;
if ( v2 > 1 )
func0("Flat correction must be 0 or 1");
}
else if ( !strcasecmp(s1, "TRIM") )
{
TRIM = v2;
result = 1LL;
if ( v2 > 1 )
func0("Trim image must be 0 or 1");
}
else if ( !strcasecmp(s1, "MERGEAMP") )
{
MERGEAMP = v2;
result = 1LL;
if ( v2 > 1 )
func0("Merge amplifiers must be 0 or 1");
}
else
{
result = 0LL;
}
}
return result;
}

original_code:
int ccdprocparam(char*var,char*val) {
   int i;
   char *ptr;
   if (!strcasecmp(var,"imager")) {strcpy(imager,val); return 1;}
   if (!strcasecmp(var,"typekw")) {strcpy(typekw,val); return 1;}
   if (!strcasecmp(var,"filtkw")) {strcpy(filtkw,val); return 1;}
   if (!strcasecmp(var,"oversec")) {strcpy(oversec,val); return 1;}
   if (!strcasecmp(var,"zerobase")) {strcpy(zerobase,val); return 1;}
   if (!strcasecmp(var,"darkbase")) {strcpy(darkbase,val); return 1;}
   if (!strcasecmp(var,"darktime")) {strcpy(darktime,val); return 1;}
   if (!strcasecmp(var,"flatbase")) {strcpy(flatbase,val); return 1;}
   if (!strcasecmp(var,"trimsec")) {strcpy(trimsec,val); return 1;}
   if (!strcasecmp(var,"datasec")) {strcpy(datasec,val); return 1;}
   if (!strcasecmp(var,"ccdsize")) {strcpy(ccdsize,val); return 1;}
   if (!strcasecmp(var,"ccdsec")) {strcpy(ccdsec,val); return 1;}
   if (!strcasecmp(var,"detsec")) {strcpy(detsec,val); return 1;}
   i=strtol(val,&ptr,10);
   if (!*ptr) {
      if (!strcasecmp(var,"SPECIAL")) {SPECIAL=i; if (SPECIAL<0 || SPECIAL>1) perr("Mask image must be 0 or 1"); return 1;}
      if (!strcasecmp(var,"MASK")) {MASK=i; if (MASK<0 || MASK>1) perr("Mask image must be 0 or 1"); return 1;}
      if (!strcasecmp(var,"OVERSCAN")) {OVERSCAN=i; if (OVERSCAN<0 || OVERSCAN>2) perr("Overscan correction must be 0, 1, or 2"); return 1;}
      if (!strcasecmp(var,"ZERO")) {ZERO=i; if (ZERO<0 || ZERO>1) perr("Zero correction must be 0 or 1"); return 1;}
      if (!strcasecmp(var,"DARK")) {DARK=i; if (DARK<0 || DARK>1) perr("Dark correction must be 0 or 1"); return 1;}
      if (!strcasecmp(var,"FLAT")) {FLAT=i; if (FLAT<0 || FLAT>1) perr("Flat correction must be 0 or 1"); return 1;}
      if (!strcasecmp(var,"TRIM")) {TRIM=i; if (TRIM<0 || TRIM>1) perr("Trim image must be 0 or 1"); return 1;}
      if (!strcasecmp(var,"MERGEAMP")) {MERGEAMP=i; if (MERGEAMP<0 || MERGEAMP>1) perr("Merge amplifiers must be 0 or 1"); return 1;}
   }
   return 0;
}

canonical_original_code:
int ccdprocparam(char *var, char *val) {
   int i;
   char *ptr;
   if (!strcasecmp(var,"imager")) {strcpy(imager,val); return 1;}
   if (!strcasecmp(var,"typekw")) {strcpy(typekw,val); return 1;}
   if (!strcasecmp(var,"filtkw")) {strcpy(filtkw,val); return 1;}
   if (!strcasecmp(var,"oversec")) {strcpy(oversec,val); return 1;}
   if (!strcasecmp(var,"zerobase")) {strcpy(zerobase,val); return 1;}
   if (!strcasecmp(var,"darkbase")) {strcpy(darkbase,val); return 1;}
   if (!strcasecmp(var,"darktime")) {strcpy(darktime,val); return 1;}
   if (!strcasecmp(var,"flatbase")) {strcpy(flatbase,val); return 1;}
   if (!strcasecmp(var,"trimsec")) {strcpy(trimsec,val); return 1;}
   if (!strcasecmp(var,"datasec")) {strcpy(datasec,val); return 1;}
   if (!strcasecmp(var,"ccdsize")) {strcpy(ccdsize,val); return 1;}
   if (!strcasecmp(var,"ccdsec")) {strcpy(ccdsec,val); return 1;}
   if (!strcasecmp(var,"detsec")) {strcpy(detsec,val); return 1;}
   i=strtol(val,&ptr,10);
   if (!*ptr) {
      if (!strcasecmp(var,"SPECIAL")) {SPECIAL=i; if (SPECIAL<0 || SPECIAL>1) perr("Mask image must be 0 or 1"); return 1;}
      if (!strcasecmp(var,"MASK")) {MASK=i; if (MASK<0 || MASK>1) perr("Mask image must be 0 or 1"); return 1;}
      if (!strcasecmp(var,"OVERSCAN")) {OVERSCAN=i; if (OVERSCAN<0 || OVERSCAN>2) perr("Overscan correction must be 0, 1, or 2"); return 1;}
      if (!strcasecmp(var,"ZERO")) {ZERO=i; if (ZERO<0 || ZERO>1) perr("Zero correction must be 0 or 1"); return 1;}
      if (!strcasecmp(var,"DARK")) {DARK=i; if (DARK<0 || DARK>1) perr("Dark correction must be 0 or 1"); return 1;}
      if (!strcasecmp(var,"FLAT")) {FLAT=i; if (FLAT<0 || FLAT>1) perr("Flat correction must be 0 or 1"); return 1;}
      if (!strcasecmp(var,"TRIM")) {TRIM=i; if (TRIM<0 || TRIM>1) perr("Trim image must be 0 or 1"); return 1;}
      if (!strcasecmp(var,"MERGEAMP")) {MERGEAMP=i; if (MERGEAMP<0 || MERGEAMP>1) perr("Merge amplifiers must be 0 or 1"); return 1;}
   }
   return 0;
}

variable_types:
var
char *

variable_types:
val
char *

variable_types: i int

variable_types:
ptr
char *


parsesec

original_code:
int parsesec(imtype*img,char*str,int*x1,int*x2,int*y1,int*y2,int*z1,int*z2) {
   char*ptr;
   while (*str==32) str++;
   if (*(str++)!='[') return 1;
   while (*str==32) str++;
   if (*str=='*') {
      *x1=0;
      *x2=img->X;
      str++;
   }
   else {
      *x1=strtol(str,&ptr,10)-1;
      if (ptr==str) return 1;
      str=ptr;
      while (*str==32) str++;
      if (*(str++)!=':') return 1;
      *x2=strtol(str,&ptr,10);
      if (ptr==str) return 1;
      str=ptr;
   }
   while (*str==32) str++;
   if (*(str++)!=',') return 1;
   while (*str==32) str++;
   if (*str=='*') {
      *y1=0;
      *y2=img->Y;
      str++;
   }
   else {
      *y1=strtol(str,&ptr,10)-1;
      if (ptr==str) return 1;
      str=ptr;
      while (*str==32) str++;
      if (*(str++)!=':') return 1;
      *y2=strtol(str,&ptr,10);
      if (ptr==str) return 1;
      str=ptr;
   }
   while (*str==32) str++;
   if (*str==']') {
      *z1=0;
      *z2=img->Z;
      return 0;
   }
   if (*(str++)!=',') return 1;
   while (*str==32) str++;
   if (*str=='*') {
      *z1=0;
      *z2=img->Z;
      str++;
   }
   else {
      *z1=strtol(str,&ptr,10)-1;
      if (ptr==str) return 1;
      str=ptr;
      while (*str==32) str++;
      if (*(str++)!=':') return 1;
      *z2=strtol(str,&ptr,10);
      if (ptr==str) return 1;
      str=ptr;
   }
   while (*str==32) str++;
   if (*(str++)!=']') return 1;
   return 0;
}

canonical_original_code:
int parsesec(struct imtype *img, char *str, int *x1, int *x2, int *y1, int *y2, int *z1, int *z2) {
   char *ptr;
   while (*str==32) str++;
   if (*(str++)!='[') return 1;
   while (*str==32) str++;
   if (*str=='*') {
      *x1=0;
      *x2=img->X;
      str++;
   }
   else {
      *x1=strtol(str,&ptr,10)-1;
      if (ptr==str) return 1;
      str=ptr;
      while (*str==32) str++;
      if (*(str++)!=':') return 1;
      *x2=strtol(str,&ptr,10);
      if (ptr==str) return 1;
      str=ptr;
   }
   while (*str==32) str++;
   if (*(str++)!=',') return 1;
   while (*str==32) str++;
   if (*str=='*') {
      *y1=0;
      *y2=img->Y;
      str++;
   }
   else {
      *y1=strtol(str,&ptr,10)-1;
      if (ptr==str) return 1;
      str=ptr;
      while (*str==32) str++;
      if (*(str++)!=':') return 1;
      *y2=strtol(str,&ptr,10);
      if (ptr==str) return 1;
      str=ptr;
   }
   while (*str==32) str++;
   if (*str==']') {
      *z1=0;
      *z2=img->Z;
      return 0;
   }
   if (*(str++)!=',') return 1;
   while (*str==32) str++;
   if (*str=='*') {
      *z1=0;
      *z2=img->Z;
      str++;
   }
   else {
      *z1=strtol(str,&ptr,10)-1;
      if (ptr==str) return 1;
      str=ptr;
      while (*str==32) str++;
      if (*(str++)!=':') return 1;
      *z2=strtol(str,&ptr,10);
      if (ptr==str) return 1;
      str=ptr;
   }
   while (*str==32) str++;
   if (*(str++)!=']') return 1;
   return 0;
}

variable_types: struct imtype { int Ncards; double bzero; char xtension[81]; char (*cards)[81]; float ***data; struct bintabledatatype { char name[81]; int length; char type; unsigned long offset; } *bintabdata; } *

variable_types:
str
char *

user_defined_types: struct imtype { int Ncards; double bzero; char xtension[81]; char (*cards)[81]; float ***data; struct bintabledatatype *bintabdata; }


getsec

decompiled_code:
__int64 __fastcall getsec(_DWORD *a1, _BYTE *a2, _DWORD *a3, _DWORD *a4, _DWORD *a5, _DWORD *a6, _DWORD *a7, _DWORD *a8)
{
int v12; // edx
__int64 result; // rax
_BYTE *v14; // rax
int v15; // edx

v12 = parsesec(a1, a2, a3, a4, a5, a6, a7, a8);
result = 1LL;
if ( v12 )
{
v14 = (_BYTE *)getcardval(a1, a2, 0LL);
v15 = parsesec(a1, v14, a3, a4, a5, a6, a7, a8);
result = 1LL;
if ( v15 )
{
*a7 = 0;
*a5 = 0;
*a3 = 0;
*a4 = a1[2];
*a6 = a1[3];
*a8 = a1[4];
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(_DWORD *a1, _BYTE *a2, _DWORD *a3, _DWORD *a4, _DWORD *a5, _DWORD *a6, _DWORD *a7, _DWORD *a8)
{
int v12; // edx
__int64 result; // rax
_BYTE *v14; // rax
int v15; // edx

v12 = func2(a1, a2, a3, a4, a5, a6, a7, a8);
result = 1LL;
if ( v12 )
{
v14 = (_BYTE *)getcardval(a1, a2, 0LL);
v15 = func2(a1, v14, a3, a4, a5, a6, a7, a8);
result = 1LL;
if ( v15 )
{
*a7 = 0;
*a5 = 0;
*a3 = 0;
*a4 = a1[2];
*a6 = a1[3];
*a8 = a1[4];
result = 0LL;
}
}
return result;
}

original_code:
int getsec(imtype*img,cardtype str,int*x1,int*x2,int*y1,int*y2,int*z1,int*z2) {
   if (!parsesec(img,str,x1,x2,y1,y2,z1,z2)) return 1;
   if (!parsesec(img,getcardval(img,str,0),x1,x2,y1,y2,z1,z2)) return 1;
   *x1=*y1=*z1=0;
   *x2=img->X;
   *y2=img->Y;
   *z2=img->Z;
   return 0;
}

canonical_original_code:
int getsec(struct imtype *img, char str[81], int *x1, int *x2, int *y1, int *y2, int *z1, int *z2) {
   if (!parsesec(img,str,x1,x2,y1,y2,z1,z2)) return 1;
   if (!parsesec(img,getcardval(img,str,0),x1,x2,y1,y2,z1,z2)) return 1;
   *x1=*y1=*z1=0;
   *x2=img->X;
   *y2=img->Y;
   *z2=img->Z;
   return 0;
}

variable_types:
str
char [81]

user_defined_types: struct bintabledatatype { char name[81]; int length; char type; unsigned long offset; }


perr

decompiled_code:
void __fastcall __noreturn perr(const char *a1)
{
puts(a1);
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func0(const char *a1)
{
puts(a1);
exit(1);
}

original_code:
void perr(char *str) {
   printf("%s\n",str);
   exit(1);
}


variable_types: cm int

variable_types: filt int

variable_types:
x
double *

variable_types:
y
double *


decompiled_code:
double __fastcall WFC3pixsize(int a1, int a2, double a3, double a4)
{
double v5; // [rsp+0h] [rbp-50h] BYREF
double v6; // [rsp+8h] [rbp-48h] BYREF
double v7; // [rsp+10h] [rbp-40h] BYREF
double v8; // [rsp+18h] [rbp-38h] BYREF
double v9; // [rsp+20h] [rbp-30h] BYREF
double v10; // [rsp+28h] [rbp-28h] BYREF
double v11; // [rsp+30h] [rbp-20h] BYREF
double v12[3]; // [rsp+38h] [rbp-18h] BYREF

v12[0] = a3 - 0.5;
v11 = a4 - 0.5;
v10 = a3 + 0.5;
v9 = a4 + 0.5;
v8 = a3 - 0.5;
v7 = a4 + 0.5;
v6 = a3 + 0.5;
v5 = a4 - 0.5;
WFC3fwddistort(a1, a2, v12, &v11);
WFC3fwddistort(a1, a2, &v10, &v9);
WFC3fwddistort(a1, a2, &v8, &v7);
WFC3fwddistort(a1, a2, &v6, &v5);
return COERCE_DOUBLE(COERCE_UNSIGNED_INT64((v8 - v12[0]) * (v9 - v11) - (v7 - v11) * (v10 - v12[0])) & LC1) * 0.5
+ COERCE_DOUBLE(COERCE_UNSIGNED_INT64((v6 - v12[0]) * (v9 - v11) - (v5 - v11) * (v10 - v12[0])) & LC1) * 0.5;
}

original_code:
double WFC3pixsize(int cm,int filt,double x,double y) {
   double x1=x-0.5; double y1=y-0.5;
   double x2=x+0.5; double y2=y+0.5;
   double xa=x-0.5; double ya=y+0.5;
   double xb=x+0.5; double yb=y-0.5;
   WFC3fwddistort(cm,filt,&x1,&y1);
   WFC3fwddistort(cm,filt,&x2,&y2);
   WFC3fwddistort(cm,filt,&xa,&ya);
   WFC3fwddistort(cm,filt,&xb,&yb);
   y2-=y1;
   x2-=x1;
   return 0.5*fabs((xa-x1)*y2-(ya-y1)*x2)+0.5*fabs((xb-x1)*y2-(yb-y1)*x2);
}

canonical_original_code:
double WFC3pixsize(int cm, int filt, double x, double y) {
   double x1 = x-0.5; double y1 = y-0.5;
   double x2 = x+0.5; double y2 = y+0.5;
   double xa = x-0.5; double ya = y+0.5;
   double xb = x+0.5; double yb = y-0.5;
   WFC3fwddistort(cm,filt,&x1,&y1);
   WFC3fwddistort(cm,filt,&x2,&y2);
   WFC3fwddistort(cm,filt,&xa,&ya);
   WFC3fwddistort(cm,filt,&xb,&yb);
   y2-=y1;
   x2-=x1;
   return 0.5*fabs((xa-x1)*y2-(ya-y1)*x2)+0.5*fabs((xb-x1)*y2-(yb-y1)*x2);
}

variable_types: x double

variable_types: y double

variable_types: xa double

variable_types: ya double

variable_types: xb double

variable_types: yb double

return_type: double


repo: dsw/proquint

decompiled_code:
__int64 __fastcall my_atoi(int a1, const char *a2)
{
char v2; // al
unsigned int v3; // er9
const char *v4; // r8
unsigned int v5; // ecx
int v6; // eax

v2 = *a2;
v3 = *a2;
if ( !*a2 )
return 0LL;
v4 = a2;
v5 = 0;
do
{
switch ( v2 )
{
case '0':
v6 = 0;
break;
case '1':
v6 = 1;
break;
case '2':
v6 = 2;
break;
case '3':
v6 = 3;
break;
case '4':
v6 = 4;
break;
case '5':
v6 = 5;
break;
case '6':
v6 = 6;
break;
case '7':
v6 = 7;
break;
case '8':
v6 = 8;
break;
case '9':
v6 = 9;
break;
case 'A':
case 'a':
v6 = 10;
break;
case 'B':
case 'b':
v6 = 11;
break;
case 'C':
case 'c':
v6 = 12;
break;
case 'D':
case 'd':
v6 = 13;
break;
case 'E':
case 'e':
v6 = 14;
break;
case 'F':
case 'f':
v6 = 15;
break;
default:
fprintf(stderr, "Illegal character in uint-word '%s': '%c'.\n", v4, v3);
exit(1);
}
if ( v6 >= a1 )
{
fprintf(stderr, "Numbers of base %d may not contain the digit '%c': '%s'.\n", (unsigned int)a1, v3, v4);
exit(1);
}
v5 = v6 + a1 * v5;
v2 = *++a2;
v3 = *a2;
}
while ( *a2 );
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func9(int a1, const char *a2)
{
char v2; // al
unsigned int v3; // er9
const char *v4; // r8
unsigned int v5; // ecx
int v6; // eax

v2 = *a2;
v3 = *a2;
if ( !*a2 )
return 0LL;
v4 = a2;
v5 = 0;
do
{
switch ( v2 )
{
case '0':
v6 = 0;
break;
case '1':
v6 = 1;
break;
case '2':
v6 = 2;
break;
case '3':
v6 = 3;
break;
case '4':
v6 = 4;
break;
case '5':
v6 = 5;
break;
case '6':
v6 = 6;
break;
case '7':
v6 = 7;
break;
case '8':
v6 = 8;
break;
case '9':
v6 = 9;
break;
case 'A':
case 'a':
v6 = 10;
break;
case 'B':
case 'b':
v6 = 11;
break;
case 'C':
case 'c':
v6 = 12;
break;
case 'D':
case 'd':
v6 = 13;
break;
case 'E':
case 'e':
v6 = 14;
break;
case 'F':
case 'f':
v6 = 15;
break;
default:
fprintf(stderr, "Illegal character in uint-word '%s': '%c'.\n", v4, v3);
exit(1);
}
if ( v6 >= a1 )
{
fprintf(stderr, "Numbers of base %d may not contain the digit '%c': '%s'.\n", (unsigned int)a1, v3, v4);
exit(1);
}
v5 = v6 + a1 * v5;
v2 = *++a2;
v3 = *a2;
}
while ( *a2 );
return v5;
}

original_code:
static uint32_t my_atoi(int base, char const *s) {
  char const *const s_orig = s;
  uint32_t ret = 0;
  int c;
  for(; (c=*s); ++s) {
    int value = -1;
    switch(c) {
    case '0': value = 0; break;
    case '1': value = 1; break;
    case '2': value = 2; break;
    case '3': value = 3; break;
    case '4': value = 4; break;
    case '5': value = 5; break;
    case '6': value = 6; break;
    case '7': value = 7; break;
    case '8': value = 8; break;
    case '9': value = 9; break;
    case 'a': case 'A': value = 10; break;
    case 'b': case 'B': value = 11; break;
    case 'c': case 'C': value = 12; break;
    case 'd': case 'D': value = 13; break;
    case 'e': case 'E': value = 14; break;
    case 'f': case 'F': value = 15; break;
    default:
      fprintf(stderr, "Illegal character in uint-word '%s': '%c'.\n",
              s_orig, c);
      exit(1);
      break;
    }
    if (value < 0) {
      fprintf(stderr, "This cannot happen.");
      exit(1);
    }
    if (value >= base) {
      fprintf(stderr,
              "Numbers of base %d may not contain the digit '%c': '%s'.\n",
              base, c, s_orig);
      exit(1);
    }
    ret *= base;
    ret += value;
  }
  return ret;
}

canonical_original_code:
static unsigned int my_atoi(int base, char *s) {
  char *s_orig = s;
  unsigned int ret = 0;
  int c;
  for(; (c=*s); ++s) {
    int value = -1;
    switch(c) {
    case '0': value = 0; break;
    case '1': value = 1; break;
    case '2': value = 2; break;
    case '3': value = 3; break;
    case '4': value = 4; break;
    case '5': value = 5; break;
    case '6': value = 6; break;
    case '7': value = 7; break;
    case '8': value = 8; break;
    case '9': value = 9; break;
    case 'a': case 'A': value = 10; break;
    case 'b': case 'B': value = 11; break;
    case 'c': case 'C': value = 12; break;
    case 'd': case 'D': value = 13; break;
    case 'e': case 'E': value = 14; break;
    case 'f': case 'F': value = 15; break;
    default:
      fprintf(stderr, "Illegal character in uint-word '%s': '%c'.\n",
              s_orig, c);
      exit(1);
      break;
    }
    if (value < 0) {
      fprintf(stderr, "This cannot happen.");
      exit(1);
    }
    if (value >= base) {
      fprintf(stderr,
              "Numbers of base %d may not contain the digit '%c': '%s'.\n",
              base, c, s_orig);
      exit(1);
    }
    ret *= base;
    ret += value;
  }
  return ret;
}

variable_types: base int

variable_types:
s
char *

variable_types:
ret
unsigned int

variable_types: c int

variable_types: value int

return_type: unsigned int


decompiled_code:
int __fastcall main_convertNumber(int a1, const char *a2)
{
unsigned int v2; // esi
char *v3; // rax
char v5[24]; // [rsp+0h] [rbp-28h] BYREF
char v6; // [rsp+18h] [rbp-10h] BYREF

v2 = my_atoi(a1, a2);
v3 = v5;
do
*v3++ = 0;
while ( v3 != &v6 );
uint2quint(v5, v2, 45);
return printf("%s ", v5);
}

canonical_decompiled_code:
int __fastcall func10(int a1, const char *a2)
{
unsigned int v2; // esi
char *v3; // rax
char v5[24]; // [rsp+0h] [rbp-28h] BYREF
char v6; // [rsp+18h] [rbp-10h] BYREF

v2 = func9(a1, a2);
v3 = v5;
do
*v3++ = 0;
while ( v3 != &v6 );
func7(v5, v2, 45);
return printf("%s ", v5);
}

original_code:
static void main_convertNumber(int base, char const *s) {
  int const QUINT_LEN = 5*2 + 1;
  int const DOUBLE_QUINT_LEN = 2*QUINT_LEN + 1;
  int const n = my_atoi(base, s);
  char quint[DOUBLE_QUINT_LEN+1];
  int i;
  for(i=0; i<DOUBLE_QUINT_LEN+1; ++i) quint[i] = '\0';
  uint2quint(quint, n, '-');
  printf("%s ", quint);
}

canonical_original_code:
static void main_convertNumber(int base, char *s) {
  int QUINT_LEN = 5*2 + 1;
  int DOUBLE_QUINT_LEN = 2*QUINT_LEN + 1;
  int n = my_atoi(base, s);
  char quint[-1];
  int i;
  for(i=0; i<DOUBLE_QUINT_LEN+1; ++i) quint[i] = '\0';
  uint2quint(quint, n, '-');
  printf("%s ", quint);
}

variable_types: n int

variable_types:
quint
char [-1]

variable_types: i int


decompiled_code:
int __fastcall main_convertQuint(char *a1)
{
unsigned int v1; // eax

v1 = quint2uint(a1);
return printf("x%x ", v1);
}

canonical_decompiled_code:
int __fastcall func11(char *a1)
{
unsigned int v1; // eax

v1 = func8(a1);
return printf("x%x ", v1);
}

original_code:
static void main_convertQuint(char const *s) {
  uint32_t uint0 = quint2uint(s);
  printf("x%x ", uint0);
}

canonical_original_code:
static void main_convertQuint(char *s) {
  unsigned int uint0 = quint2uint(s);
  printf("x%x ", uint0);
}


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char **v3; // r12
char *v4; // rbp
char v6; // bl

v3 = (char **)(argv + 1);
v4 = (char *)argv[1];
if ( v4 )
{
do
{
v6 = *v4;
if ( *v4 )
{
if ( v6 == 48 )
{
fwrite(
"Do not lead input strings with a zero.\n"
"For decimal, trim leading zeros.\n"
"For hex, lead with an 'x'.\n"
"We do not process octal.\n",
1uLL,
0x7CuLL,
stderr);
exit(1);
}
if ( (v6 & 0xDF) == 88 )
{
main_convertNumber(16, v4 + 1);
}
else if ( ((*__ctype_b_loc())[v6] & 0x800) != 0 )
{
main_convertNumber(10, v4);
}
else
{
main_convertQuint(v4);
}
}
v4 = *++v3;
}
while ( *v3 );
}
putchar(10);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char **v3; // r12
char *v4; // rbp
char v6; // bl

v3 = (char **)(argv + 1);
v4 = (char *)argv[1];
if ( v4 )
{
do
{
v6 = *v4;
if ( *v4 )
{
if ( v6 == 48 )
{
fwrite(
"Do not lead input strings with a zero.\n"
"For decimal, trim leading zeros.\n"
"For hex, lead with an 'x'.\n"
"We do not process octal.\n",
1uLL,
0x7CuLL,
stderr);
exit(1);
}
if ( (v6 & 0xDF) == 88 )
{
func10(16, v4 + 1);
}
else if ( ((*__ctype_b_loc())[v6] & 0x800) != 0 )
{
func10(10, v4);
}
else
{
func11(v4);
}
}
v4 = *++v3;
}
while ( *v3 );
}
putchar(10);
return 0;
}

original_code:
int main(int argc, char const **argv) {
  --argc; ++argv;
  for(; *argv; --argc, ++argv) {
    char const *s = *argv;
    if (!s[0]) continue;
    if (s[0] == '0') {
      fprintf(stderr,
              "Do not lead input strings with a zero.\n"
              "For decimal, trim leading zeros.\n"
              "For hex, lead with an 'x'.\n"
              "We do not process octal.\n");
      exit(1);
    } else if (s[0] == 'x' || s[0] == 'X') {
      main_convertNumber(16, s+1);
    } else if (((*__ctype_b_loc ())[(int) ((s[0]))] & (unsigned short int) _ISdigit)) {
      main_convertNumber(10, s);
    } else {
      main_convertQuint(s);
    }
  }
  printf("\n");
  return 0;
}

canonical_original_code:
int main(int argc, char **argv) {
  --argc; ++argv;
  for(; *argv; --argc, ++argv) {
    char *s = *argv;
    if (!s[0]) continue;
    if (s[0] == '0') {
      fprintf(stderr,
              "Do not lead input strings with a zero.\n"
              "For decimal, trim leading zeros.\n"
              "For hex, lead with an 'x'.\n"
              "We do not process octal.\n");
      exit(1);
    } else if (s[0] == 'x' || s[0] == 'X') {
      main_convertNumber(16, s+1);
    } else if (((*__ctype_b_loc ())[(int) ((s[0]))] & (unsigned short) _ISdigit)) {
      main_convertNumber(10, s);
    } else {
      main_convertQuint(s);
    }
  }
  printf("\n");
  return 0;
}

variable_types: argc int

variable_types:
argv
char **


decompiled_code:
__int64 __fastcall mkdir_rec(char *src)
{
int v1; // eax
_BYTE *v2; // rbx
char *v3; // rbp
__int64 v5[2]; // [rsp+0h] [rbp-218h] BYREF
char v6[496]; // [rsp+10h] [rbp-208h] BYREF

v5[0] = 0LL;
v5[1] = 0LL;
memset(v6, 0, sizeof(v6));
strcpy((char *)v5, src);
v1 = strlen((const char *)v5);
if ( v1 > 1 )
{
v2 = (char *)v5 + 1;
v3 = (char *)v5 + (unsigned int)(v1 - 2) + 2;
do
{
if ( *v2 == 47 )
{
*v2 = 0;
mkdir((const char *)v5, 0x1FFu);
*v2 = 47;
}
++v2;
}
while ( v2 != v3 );
}
mkdir((const char *)v5, 0x1FFu);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(char *src)
{
int v1; // eax
_BYTE *v2; // rbx
char *v3; // rbp
__int64 v5[2]; // [rsp+0h] [rbp-218h] BYREF
char v6[496]; // [rsp+10h] [rbp-208h] BYREF

v5[0] = 0LL;
v5[1] = 0LL;
memset(v6, 0, sizeof(v6));
strcpy((char *)v5, src);
v1 = strlen((const char *)v5);
if ( v1 > 1 )
{
v2 = (char *)v5 + 1;
v3 = (char *)v5 + (unsigned int)(v1 - 2) + 2;
do
{
if ( *v2 == 47 )
{
*v2 = 0;
mkdir((const char *)v5, 0x1FFu);
*v2 = 47;
}
++v2;
}
while ( v2 != v3 );
}
mkdir((const char *)v5, 0x1FFu);
return 1LL;
}

original_code:
int mkdir_rec(const char* path)
{
 char szpath[512] = {0};
 int i = 0;
 int len = 0;
 sprintf (szpath, "%s", path);
 len = strlen(szpath);
 for (i = 1; i < len; i++)
 {
  if (szpath[i] == '/')
  {
   szpath[i] = '\0';
   mkdir (szpath, 0777);
   szpath[i] = '/';
  }
 }
 mkdir (szpath, 0777);
 return 1;
}

canonical_original_code:
int mkdir_rec(char *path)
{
 char szpath[512] = {0};
 int i = 0;
 int len = 0;
 sprintf (szpath, "%s", path);
 len = strlen(szpath);
 for (i = 1; i < len; i++)
 {
  if (szpath[i] == '/')
  {
   szpath[i] = '\0';
   mkdir (szpath, 0777);
   szpath[i] = '/';
  }
 }
 mkdir (szpath, 0777);
 return 1;
}

variable_types:
path
char *

variable_types:
szpath
char [512]

variable_types: len int


InitArgs

decompiled_code:
void __fastcall InitArgs(int a1, const char **a2)
{
if ( a1 > 1 && !strncasecmp(a2[1], "-v", 2uLL) )
{
printf("%s: v1.2 2011-03-24 version list:\n", *a2);
puts("\tv1.2: 2011-03-24:creating ");
exit(0);
}
}

canonical_decompiled_code:
void __fastcall func2(int a1, const char **a2)
{
if ( a1 > 1 && !strncasecmp(a2[1], "-v", 2uLL) )
{
printf("%s: v1.2 2011-03-24 version list:\n", *a2);
puts("\tv1.2: 2011-03-24:creating ");
exit(0);
}
}

original_code:
void InitArgs(int argc, char* argv[])
{
 if (argc > 1)
 {
  if (strncasecmp(argv[1], "-v", 2) == 0)
  {
   printf("%s: v1.2 2011-03-24 version list:\n", argv[0]);
   printf("\tv1.2: 2011-03-24:creating \n");
   exit(0);
  }
 }
}

canonical_original_code:
void InitArgs(int argc, char *argv[])
{
 if (argc > 1)
 {
  if (strncasecmp(argv[1], "-v", 2) == 0)
  {
   printf("%s: v1.2 2011-03-24 version list:\n", argv[0]);
   printf("\tv1.2: 2011-03-24:creating \n");
   exit(0);
  }
 }
}

variable_types:
argv
char *[]


original_code:
int deliver_app_task (thread_pool_t * pool, config_t * conf)
{
 unsigned int index = 0;
 for (index = 0; index < pool->thread_num; index++)
 {
  g_plist[index].func = repo_build_func;
  g_plist[index].data = ((void *)0);
  g_plist[index].conf = conf;
  g_plist[index].index = index+1;
  pool->thread_list[index].param = &g_plist[index];
 }
 for (index = 0; index < conf->repo_num; index++)
 {
   repo_t * pr = conf->repo_list + index;
   if (g_plist[index % pool->thread_num].data == ((void *)0) )
    g_plist[index % pool->thread_num].data = pr;
   else
   {
    pr->next = g_plist[index % pool->thread_num].data;
    g_plist[index % pool->thread_num].data = pr;
   }
 }
 return 1;
}

canonical_original_code:
int deliver_app_task(struct thread_pool_t *pool, struct config_t *conf)
{
 unsigned int index = 0;
 for (index = 0; index < pool->thread_num; index++)
 {
  g_plist[index].func = repo_build_func;
  g_plist[index].data = ((void *)0);
  g_plist[index].conf = conf;
  g_plist[index].index = index+1;
  pool->thread_list[index].param = &g_plist[index];
 }
 for (index = 0; index < conf->repo_num; index++)
 {
   struct _repo *pr = conf->repo_list + index;
   if (g_plist[index % pool->thread_num].data == ((void *)0) )
    g_plist[index % pool->thread_num].data = pr;
   else
   {
    pr->next = g_plist[index % pool->thread_num].data;
    g_plist[index % pool->thread_num].data = pr;
   }
 }
 return 1;
}

variable_types: struct thread_pool_t { struct thread_t { unsigned long thread; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } mutex; unsigned char status; unsigned int index; struct param_t { int (*func)(void *data); void *data; int index; void *conf; } *param; } thread_list[100]; unsigned int thread_num; } *

variable_types: struct config_t { unsigned short nthread; unsigned char daemon; unsigned char verb; char conf[256]; char user[64]; char basedir[256]; char sigfile[64]; int interval; struct _repo { char path[256]; char sigfile[256]; int intv; void *next; long last_update; } repo_list[100]; int repo_num; int loop; } *

variable_types:
index
unsigned int

variable_types: struct _repo { char path[256]; char sigfile[256]; int intv; void *next; long last_update; } *

user_defined_types: struct thread_pool_t { struct thread_t thread_list[100]; unsigned int thread_num; }

user_defined_types: struct config_t { unsigned short nthread; unsigned char daemon; unsigned char verb; char conf[256]; char user[64]; char basedir[256]; char sigfile[64]; int interval; struct _repo repo_list[100]; int repo_num; int loop; }

user_defined_types: struct thread_t { unsigned long thread; union pthread_mutex_t mutex; unsigned char status; unsigned int index; struct param_t *param; }

user_defined_types: union pthread_mutex_t { struct __pthread_mutex_s __data; char __size[40]; long __align; }

user_defined_types: struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list __list; }


decompiled_code:
__int64 __fastcall start_thread(__int64 a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // rbx
unsigned int v4; // ebp

result = *(unsigned int *)(a1 + 6400);
if ( (_DWORD)result )
{
v3 = a1 + 48;
v4 = 0;
do
{
*(_BYTE *)v3 = 2;
if ( *(_BYTE *)(a2 + 3) )
printf("starting thread \x1B[0;32;32m%03d\x1B[m\n", *(unsigned int *)(v3 + 4));
++v4;
result = *(unsigned int *)(a1 + 6400);
v3 += 64LL;
}
while ( (unsigned int)result > v4 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // rbx
unsigned int v4; // ebp

result = *(unsigned int *)(a1 + 6400);
if ( (_DWORD)result )
{
v3 = a1 + 48;
v4 = 0;
do
{
*(_BYTE *)v3 = 2;
if ( *(_BYTE *)(a2 + 3) )
printf("starting thread \x1B[0;32;32m%03d\x1B[m\n", *(unsigned int *)(v3 + 4));
++v4;
result = *(unsigned int *)(a1 + 6400);
v3 += 64LL;
}
while ( (unsigned int)result > v4 );
}
return result;
}

original_code:
int start_thread(thread_pool_t * pool, const config_t * conf)
{
 unsigned int index = 0;
 for (index = 0; index < pool->thread_num; index++)
 {
  pool->thread_list[index].status = status_ready;
  if (conf->verb) printf ("starting thread ""\033[0;32;32m""%03d""\033[m""\n",pool->thread_list[index].index);
 }
 return pool->thread_num;
}

canonical_original_code:
int start_thread(struct thread_pool_t *pool, struct config_t *conf)
{
 unsigned int index = 0;
 for (index = 0; index < pool->thread_num; index++)
 {
  pool->thread_list[index].status = status_ready;
  if (conf->verb) printf ("starting thread ""\033[0;32;32m""%03d""\033[m""\n",pool->thread_list[index].index);
 }
 return pool->thread_num;
}

user_defined_types: struct _repo { char path[256]; char sigfile[256]; int intv; void *next; long last_update; }

user_defined_types: struct param_t { int (*func)(void *data); void *data; int index; void *conf; }

user_defined_types: struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; }


decompiled_code:
__int64 __fastcall init_config(char *a1, int a2, const char **a3)
{
unsigned int v4; // ebx

memset(a1, 0, 0xD3F0uLL);
while ( 1 )
{
v4 = getopt(a2, (char *const *)a3, "f:dv");
if ( v4 == -1 )
break;
switch ( v4 )
{
case 'f':
strcpy(a1 + 4, optarg);
break;
case 'v':
a1[3] = 1;
break;
case 'd':
a1[2] = 1;
break;
default:
printf("usage:%s\n%s\n", *a3, "\t-f\tconfigfile\n\t-d\t[daemon]\n\t-v\t[verbose]\n");
break;
}
}
if ( a1[4] )
{
if ( access(a1 + 4, 4) )
printf("access file '%s' failed\n", a1 + 4);
else
v4 = 1;
}
else
{
puts("specify a command with '-c command'");
printf("usage:%s\n%s\n", *a3, "\t-f\tconfigfile\n\t-d\t[daemon]\n\t-v\t[verbose]\n");
}
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func5(char *a1, int a2, const char **a3)
{
unsigned int v4; // ebx

memset(a1, 0, 0xD3F0uLL);
while ( 1 )
{
v4 = getopt(a2, (char *const *)a3, "f:dv");
if ( v4 == -1 )
break;
switch ( v4 )
{
case 'f':
strcpy(a1 + 4, optarg);
break;
case 'v':
a1[3] = 1;
break;
case 'd':
a1[2] = 1;
break;
default:
printf("usage:%s\n%s\n", *a3, "\t-f\tconfigfile\n\t-d\t[daemon]\n\t-v\t[verbose]\n");
break;
}
}
if ( a1[4] )
{
if ( access(a1 + 4, 4) )
printf("access file '%s' failed\n", a1 + 4);
else
v4 = 1;
}
else
{
puts("specify a command with '-c command'");
printf("usage:%s\n%s\n", *a3, "\t-f\tconfigfile\n\t-d\t[daemon]\n\t-v\t[verbose]\n");
}
return v4;
}

original_code:
int init_config (config_t * config, int argc, char* argv[])
{
 int c = 0;
 const char* szuse = "\t-f\tconfigfile\n\t-d\t[daemon]\n\t-v\t[verbose]\n";
 memset (config, 0, sizeof(config_t));
 config->daemon = 0;
 config->verb = 0;
 while ((c = getopt (argc, argv, "f:dv")) != -1)
 {
  switch (c)
  {
   case 'f':
    strcpy(config->conf, optarg);
    break;
   case 'd':
    config->daemon = 1;
    break;
   case 'v':
    config->verb = 1;
    break;
   default:
     printf ("usage:%s\n%s\n", argv[0], szuse);
   break;
  }
 }
 if (!strlen(config->conf))
 {
  printf ("specify a command with '-c command'\n");
  printf ("usage:%s\n%s\n", argv[0], szuse);
  return -1;
 }
 if (access (config->conf, 4))
 {
  printf ("access file '%s' failed\n", config->conf);
  return -1;
 }
 return 1;
}

canonical_original_code:
int init_config(struct config_t *config, int argc, char *argv[])
{
 int c = 0;
 char *szuse = "\t-f\tconfigfile\n\t-d\t[daemon]\n\t-v\t[verbose]\n";
 memset (config, 0, sizeof(config_t));
 config->daemon = 0;
 config->verb = 0;
 while ((c = getopt (argc, argv, "f:dv")) != -1)
 {
  switch (c)
  {
   case 'f':
    strcpy(config->conf, optarg);
    break;
   case 'd':
    config->daemon = 1;
    break;
   case 'v':
    config->verb = 1;
    break;
   default:
     printf ("usage:%s\n%s\n", argv[0], szuse);
   break;
  }
 }
 if (!strlen(config->conf))
 {
  printf ("specify a command with '-c command'\n");
  printf ("usage:%s\n%s\n", argv[0], szuse);
  return -1;
 }
 if (access (config->conf, 4))
 {
  printf ("access file '%s' failed\n", config->conf);
  return -1;
 }
 return 1;
}

variable_types:
szuse
char *


decompiled_code:
char *__fastcall get_time_str(const time_t *a1)
{
struct tm *v1; // rax
time_t timer; // [rsp+8h] [rbp-10h] BYREF

if ( a1 )
{
v1 = gmtime(a1);
}
else
{
time(&timer);
v1 = gmtime(&timer);
}
sprintf(
s_0,
"%04d-%02d-%02d %02d:%02d:%02d",
(unsigned int)(v1->tm_year + 1900),
(unsigned int)((v1->tm_mon + 1) % 12),
(unsigned int)v1->tm_mday,
(unsigned int)((v1->tm_hour + 8) % 24),
(unsigned int)v1->tm_min,
(unsigned int)v1->tm_sec);
return s_0;
}

canonical_decompiled_code:
char *__fastcall func6(const time_t *a1)
{
struct tm *v1; // rax
time_t timer; // [rsp+8h] [rbp-10h] BYREF

if ( a1 )
{
v1 = gmtime(a1);
}
else
{
time(&timer);
v1 = gmtime(&timer);
}
sprintf(
s_0,
"%04d-%02d-%02d %02d:%02d:%02d",
(unsigned int)(v1->tm_year + 1900),
(unsigned int)((v1->tm_mon + 1) % 12),
(unsigned int)v1->tm_mday,
(unsigned int)((v1->tm_hour + 8) % 24),
(unsigned int)v1->tm_min,
(unsigned int)v1->tm_sec);
return s_0;
}

original_code:
char* get_time_str(time_t * tm)
{
 struct tm * newtime;
 static char s[32]= {0};
  if(tm == ((void *)0))
 {
  time_t ct;
         time(&ct);
         newtime = gmtime(&ct);
 }else
 {
  newtime = gmtime(tm);
 }
 sprintf( s,"%04d-%02d-%02d %02d:%02d:%02d",
 newtime->tm_year + 1900,
    (newtime->tm_mon + 1)%12,
    newtime->tm_mday,
           (newtime->tm_hour + 8)%24,
    newtime->tm_min, newtime->tm_sec );
  return s;
}

canonical_original_code:
char *get_time_str(long *tm)
{
 struct tm *newtime;
 static char s[32] = {0};
  if(tm == ((void *)0))
 {
  long ct;
         time(&ct);
         newtime = gmtime(&ct);
 }else
 {
  newtime = gmtime(tm);
 }
 sprintf( s,"%04d-%02d-%02d %02d:%02d:%02d",
 newtime->tm_year + 1900,
    (newtime->tm_mon + 1)%12,
    newtime->tm_mday,
           (newtime->tm_hour + 8)%24,
    newtime->tm_min, newtime->tm_sec );
  return s;
}

variable_types:
tm
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:
s
char [32]

variable_types: ct long

return_type: char *


decompiled_code:
__int64 __fastcall repo_build_func(__int64 a1)
{
__int64 v1; // r14
__int64 result; // rax
__int64 v3; // rbx
unsigned int v4; // er13
unsigned int v5; // er12
char *v6; // rax
__int64 v7; // [rsp+8h] [rbp-2E0h]
__uid_t uid; // [rsp+1Ch] [rbp-2CCh] BYREF
struct stat v9; // [rsp+20h] [rbp-2C8h] BYREF
char s[8]; // [rsp+B0h] [rbp-238h] BYREF
__int64 v11; // [rsp+B8h] [rbp-230h]
char v12[496]; // [rsp+C0h] [rbp-228h] BYREF

v1 = *(_QWORD *)(a1 + 24);
v7 = *(_QWORD *)(a1 + 8);
if ( v7 )
{
do
{
sleep(1u);
v3 = v7;
do
{
if ( *(_QWORD *)(v3 + 528) + *(int *)(v3 + 512) <= time(0LL) || !access((const char *)(v3 + 256), 0) )
{
unlink((const char *)(v3 + 256));
v4 = *(_DWORD *)(v3 + 512);
v5 = *(_DWORD *)(a1 + 16);
v6 = get_time_str(0LL);
printf("%s:time for thread_%03d to update <path=%s,interval=%d>\n", v6, v5, (const char *)v3, v4);
if ( stat((const char *)v3, &v9) )
{
*(_QWORD *)s = 0LL;
v11 = 0LL;
memset(v12, 0, sizeof(v12));
sprintf(s, "/bin/mkdir -p %s", (const char *)v3);
system(s);
}
if ( stat((const char *)v3, &v9) )
{
if ( *(_BYTE *)(v1 + 3) )
printf("stat \x1B[0;32;31m%s\x1B[m failed\n", (const char *)v3);
}
else if ( (v9.st_mode & 0xF000) == 0x4000 )
{
*(_QWORD *)s = 0LL;
v11 = 0LL;
memset(v12, 0, sizeof(v12));
if ( (int)get_userid((const char *)(v1 + 260), (int *)&uid) <= 0 )
{
puts("get uid failed");
}
else if ( !getuid() && setuid(uid) )
{
puts("getuid and setuid faild");
}
else
{
sprintf(s, "/usr/bin/createrepo -d -p --update -o %s %s", (const char *)v3, (const char *)v3);
printf("Run commad:\x1B[1;33m%s\x1B[m\n", s);
system(s);
}
}
else if ( *(_BYTE *)(v1 + 3) )
{
printf("\x1B[0;32;31m%s\x1B[m is not a directory\n", (const char *)v3);
}
*(_QWORD *)(v3 + 528) = time(0LL);
}
v3 = *(_QWORD *)(v3 + 520);
usleep(0x64u);
}
while ( v3 );
}
while ( *(_DWORD *)(v1 + 54252) );
result = 1LL;
}
else
{
printf("invalid repo list for thread:%d\n", *(unsigned int *)(a1 + 16));
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
__int64 v1; // r14
__int64 result; // rax
__int64 v3; // rbx
unsigned int v4; // er13
unsigned int v5; // er12
char *v6; // rax
__int64 v7; // [rsp+8h] [rbp-2E0h]
__uid_t uid; // [rsp+1Ch] [rbp-2CCh] BYREF
struct stat v9; // [rsp+20h] [rbp-2C8h] BYREF
char s[8]; // [rsp+B0h] [rbp-238h] BYREF
__int64 v11; // [rsp+B8h] [rbp-230h]
char v12[496]; // [rsp+C0h] [rbp-228h] BYREF

v1 = *(_QWORD *)(a1 + 24);
v7 = *(_QWORD *)(a1 + 8);
if ( v7 )
{
do
{
sleep(1u);
v3 = v7;
do
{
if ( *(_QWORD *)(v3 + 528) + *(int *)(v3 + 512) <= time(0LL) || !access((const char *)(v3 + 256), 0) )
{
unlink((const char *)(v3 + 256));
v4 = *(_DWORD *)(v3 + 512);
v5 = *(_DWORD *)(a1 + 16);
v6 = func6(0LL);
printf("%s:time for thread_%03d to update <path=%s,interval=%d>\n", v6, v5, (const char *)v3, v4);
if ( stat((const char *)v3, &v9) )
{
*(_QWORD *)s = 0LL;
v11 = 0LL;
memset(v12, 0, sizeof(v12));
sprintf(s, "/bin/mkdir -p %s", (const char *)v3);
system(s);
}
if ( stat((const char *)v3, &v9) )
{
if ( *(_BYTE *)(v1 + 3) )
printf("stat \x1B[0;32;31m%s\x1B[m failed\n", (const char *)v3);
}
else if ( (v9.st_mode & 0xF000) == 0x4000 )
{
*(_QWORD *)s = 0LL;
v11 = 0LL;
memset(v12, 0, sizeof(v12));
if ( (int)func0((const char *)(v1 + 260), (int *)&uid) <= 0 )
{
puts("get uid failed");
}
else if ( !getuid() && setuid(uid) )
{
puts("getuid and setuid faild");
}
else
{
sprintf(s, "/usr/bin/createrepo -d -p --update -o %s %s", (const char *)v3, (const char *)v3);
printf("Run commad:\x1B[1;33m%s\x1B[m\n", s);
system(s);
}
}
else if ( *(_BYTE *)(v1 + 3) )
{
printf("\x1B[0;32;31m%s\x1B[m is not a directory\n", (const char *)v3);
}
*(_QWORD *)(v3 + 528) = time(0LL);
}
v3 = *(_QWORD *)(v3 + 520);
usleep(0x64u);
}
while ( v3 );
}
while ( *(_DWORD *)(v1 + 54252) );
result = 1LL;
}
else
{
printf("invalid repo list for thread:%d\n", *(unsigned int *)(a1 + 16));
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int repo_build_func (void*data)
{
 param_t * pa = (param_t*)data;
 repo_t * pr = ((void *)0);
 config_t * conf = (config_t*)pa->conf;
 if (!pa)
 {
  printf ("%s-%d:invalid parameter data\n", "configserver.c", 136);
  return -1;
 }
 repo_t * rp = (repo_t*)pa->data;
 if (!rp)
 {
  printf ("invalid repo list for thread:%d\n", pa->index);
  return -1;
 }
 do{
  sleep (1);
  pr = rp;
  while (pr)
  {
    time_t ct = time (0);
    if ( (ct >= pr->last_update + pr->intv) || (access(pr->sigfile, 0) == 0))
    {
     struct stat st;
     unlink (pr->sigfile);
     printf ("%s:time for thread_%03d to update <path=%s,interval=%d>\n",
     get_time_str(((void *)0)),
     pa->index, pr->path, pr->intv);
     if (stat(pr->path, &st))
     {
      char cmd[512] = {0};
      sprintf (cmd, "/bin/mkdir -p %s", pr->path);
      system (cmd);
     }
     if (!stat(pr->path, &st))
     {
       if (((((st.st_mode)) & 0170000) == (0040000)))
       {
        char cmd[512] = {0};
        uid_t uid;
        if( get_userid (conf->user, &uid) <= 0)
        {
         printf("get uid failed\n");
        }else
        {
         if (!getuid()&& setuid(uid))
         {
          printf("getuid and setuid faild\n");
         }else
         {
           sprintf (cmd, "/usr/bin/createrepo -d -p --update -o %s %s", pr->path, pr->path);
          printf ("Run commad:""\033[1;33m""%s""\033[m""\n", cmd);
          system(cmd);
         }
        }
       }else
       {
        if(conf->verb)
        printf ("""\033[0;32;31m""%s""\033[m"" is not a directory\n", pr->path);
       }
     }else
     {
      if(conf->verb)
      printf ("stat ""\033[0;32;31m""%s""\033[m"" failed\n", pr->path);
     }
     pr->last_update = time(0);
    }
    pr=pr->next;
    usleep(100);
  }
 }while(conf->loop);
 return 1;
}

canonical_original_code:
int repo_build_func(void *data)
{
 struct param_t *pa = (param_t*)data;
 struct _repo *pr = ((void *)0);
 struct config_t *conf = (config_t*)pa->conf;
 if (!pa)
 {
  printf ("%s-%d:invalid parameter data\n", "configserver.c", 136);
  return -1;
 }
 struct _repo *rp = (repo_t*)pa->data;
 if (!rp)
 {
  printf ("invalid repo list for thread:%d\n", pa->index);
  return -1;
 }
 do{
  sleep (1);
  pr = rp;
  while (pr)
  {
    long ct = time (0);
    if ( (ct >= pr->last_update + pr->intv) || (access(pr->sigfile, 0) == 0))
    {
     struct stat st;
     unlink (pr->sigfile);
     printf ("%s:time for thread_%03d to update <path=%s,interval=%d>\n",
     get_time_str(((void *)0)),
     pa->index, pr->path, pr->intv);
     if (stat(pr->path, &st))
     {
      char cmd[512] = {0};
      sprintf (cmd, "/bin/mkdir -p %s", pr->path);
      system (cmd);
     }
     if (!stat(pr->path, &st))
     {
       if (((((st.st_mode)) & 0170000) == (0040000)))
       {
        char cmd[512] = {0};
        unsigned int uid;
        if( get_userid (conf->user, &uid) <= 0)
        {
         printf("get uid failed\n");
        }else
        {
         if (!getuid()&& setuid(uid))
         {
          printf("getuid and setuid faild\n");
         }else
         {
           sprintf (cmd, "/usr/bin/createrepo -d -p --update -o %s %s", pr->path, pr->path);
          printf ("Run commad:""\033[1;33m""%s""\033[m""\n", cmd);
          system(cmd);
         }
        }
       }else
       {
        if(conf->verb)
        printf ("""\033[0;32;31m""%s""\033[m"" is not a directory\n", pr->path);
       }
     }else
     {
      if(conf->verb)
      printf ("stat ""\033[0;32;31m""%s""\033[m"" failed\n", pr->path);
     }
     pr->last_update = time(0);
    }
    pr=pr->next;
    usleep(100);
  }
 }while(conf->loop);
 return 1;
}

variable_types:
data
void *

variable_types: struct param_t { int (*func)(void *data); void *data; int index; void *conf; } *

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:
cmd
char [512]

variable_types:
uid
unsigned 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]; }


decompiled_code:
__int64 __fastcall load_repo_conf(unsigned __int16 *a1)
{
__int64 v2; // rax
__int64 v3; // r14
const char *v4; // rax
const char *v5; // rax
const char *v6; // rax
const char *v7; // rax
const char *v8; // rax
const char *v9; // rax
__int64 result; // rax
int v11; // ebx
const char *v12; // rbp
int v13; // eax
unsigned __int16 *v14; // rcx
unsigned __int16 *v15; // rax
bool v16; // zf
const char *v17; // [rsp+0h] [rbp-98B8h]
const char *v18; // [rsp+8h] [rbp-98B0h]
char s[8]; // [rsp+10h] [rbp-98A8h] BYREF
char v20[256]; // [rsp+110h] [rbp-97A8h] BYREF
unsigned int v21; // [rsp+210h] [rbp-96A8h]
__int64 v22; // [rsp+220h] [rbp-9698h]
char v23[128]; // [rsp+230h] [rbp-9688h] BYREF
char v24; // [rsp+2B0h] [rbp-9608h] BYREF
int v25; // [rsp+9870h] [rbp-48h]

v2 = init_ini(a1 + 2);
if ( v2 )
{
v3 = v2;
v4 = (const char *)read_string(v2, "general", "interval", "600");
*((_DWORD *)a1 + 161) = atoi(v4);
v5 = (const char *)read_string(v3, "general", "thread_num", "10");
*a1 = atoi(v5);
v6 = (const char *)read_string(v3, "general", "loop", "0");
*((_DWORD *)a1 + 13563) = atoi(v6);
v7 = (const char *)read_string(v3, "general", "basedir", "NONE");
v17 = (const char *)(a1 + 162);
strcpy((char *)a1 + 324, v7);
v8 = (const char *)read_string(v3, "general", "signalfile", "update.txt");
v18 = (const char *)(a1 + 290);
strcpy((char *)a1 + 580, v8);
v9 = (const char *)read_string(v3, "general", "user", "root");
strcpy((char *)a1 + 260, v9);
if ( *((_BYTE *)a1 + 3) )
printf(
"repobuilder conf:\n"
"\tinterval = \x1B[1;33m%d\x1B[m\n"
"\tthread_num = \x1B[1;33m%d\x1B[m\n"
"\tsignalfile=\x1B[1;33m%s\x1B[m\n",
*((unsigned int *)a1 + 161),
*a1,
v18);
*((_DWORD *)a1 + 13562) = 0;
LABEL_26:
while ( (unsigned int)read_section(v3, v23) )
{
v21 = *((_DWORD *)a1 + 161);
v16 = memcmp(v23, "repo", 4uLL) == 0;
v11 = !v16;
if ( !v16 )
goto LABEL_26;
if ( v25 > 0 )
{
v12 = &v24;
do
{
if ( !strncasecmp(v12 - 64, "path", 4uLL) )
{
if ( !strcmp(v17, "NONE") )
strcpy(s, v12);
else
sprintf(s, "%s/%s", v17, v12);
}
else if ( !strncasecmp(v12 - 64, "on", 2uLL) )
{
if ( !atoi(v12) )
{
if ( *((_BYTE *)a1 + 3) )
printf("just ignore \x1B[1;33m'%s'\x1B[m..\n", s);
goto LABEL_26;
}
}
else if ( !strncasecmp(v12 - 64, "interval", 8uLL) )
{
v13 = atoi(v12);
if ( v13 > 0 )
v21 = v13;
}
++v11;
v12 += 192;
}
while ( v25 > v11 );
}
sprintf(v20, "%s/%s", s, v18);
v14 = &a1[268 * *((int *)a1 + 13562) + 324];
*(_QWORD *)v14 = *(_QWORD *)s;
*((_QWORD *)v14 + 66) = v22;
qmemcpy(
(void *)((unsigned __int64)(v14 + 4) & 0xFFFFFFFFFFFFFFF8LL),
(const void *)(s - ((char *)v14 - ((unsigned __int64)(v14 + 4) & 0xFFFFFFFFFFFFFFF8LL))),
8LL * (((unsigned int)v14 - (((_DWORD)v14 + 8) & 0xFFFFFFF8) + 536) >> 3));
v15 = &a1[268 * *((int *)a1 + 13562)];
*((_QWORD *)v15 + 146) = 0LL;
*((_QWORD *)v15 + 147) = 0LL;
if ( *((_BYTE *)a1 + 3) )
printf(
"load repo conf:\tpath=\t\x1B[1;33m%s\x1B[m\tinterval=\t\x1B[1;33m%d\x1B[m\tsigfile=\x1B[1;33m%s\x1B[m\n",
s,
v21,
v20);
++*((_DWORD *)a1 + 13562);
}
close_ini(v3);
if ( *((_BYTE *)a1 + 3) )
printf("totally \x1B[1;33m%d\x1B[m repo loaded\n", *((unsigned int *)a1 + 13562));
result = *((unsigned int *)a1 + 13562);
if ( *a1 > (int)result )
*a1 = result;
}
else
{
printf("%s-%d:open file '%s' for reading failed\n", "configserver.c", 301LL, (const char *)a1 + 4);
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(unsigned __int16 *a1)
{
__int64 v2; // rax
__int64 v3; // r14
const char *v4; // rax
const char *v5; // rax
const char *v6; // rax
const char *v7; // rax
const char *v8; // rax
const char *v9; // rax
__int64 result; // rax
int v11; // ebx
const char *v12; // rbp
int v13; // eax
unsigned __int16 *v14; // rcx
unsigned __int16 *v15; // rax
bool v16; // zf
const char *v17; // [rsp+0h] [rbp-98B8h]
const char *v18; // [rsp+8h] [rbp-98B0h]
char s[8]; // [rsp+10h] [rbp-98A8h] BYREF
char v20[256]; // [rsp+110h] [rbp-97A8h] BYREF
unsigned int v21; // [rsp+210h] [rbp-96A8h]
__int64 v22; // [rsp+220h] [rbp-9698h]
char v23[128]; // [rsp+230h] [rbp-9688h] BYREF
char v24; // [rsp+2B0h] [rbp-9608h] BYREF
int v25; // [rsp+9870h] [rbp-48h]

v2 = init_ini(a1 + 2);
if ( v2 )
{
v3 = v2;
v4 = (const char *)read_string(v2, "general", "interval", "600");
*((_DWORD *)a1 + 161) = atoi(v4);
v5 = (const char *)read_string(v3, "general", "thread_num", "10");
*a1 = atoi(v5);
v6 = (const char *)read_string(v3, "general", "loop", "0");
*((_DWORD *)a1 + 13563) = atoi(v6);
v7 = (const char *)read_string(v3, "general", "basedir", "NONE");
v17 = (const char *)(a1 + 162);
strcpy((char *)a1 + 324, v7);
v8 = (const char *)read_string(v3, "general", "signalfile", "update.txt");
v18 = (const char *)(a1 + 290);
strcpy((char *)a1 + 580, v8);
v9 = (const char *)read_string(v3, "general", "user", "root");
strcpy((char *)a1 + 260, v9);
if ( *((_BYTE *)a1 + 3) )
printf(
"repobuilder conf:\n"
"\tinterval = \x1B[1;33m%d\x1B[m\n"
"\tthread_num = \x1B[1;33m%d\x1B[m\n"
"\tsignalfile=\x1B[1;33m%s\x1B[m\n",
*((unsigned int *)a1 + 161),
*a1,
v18);
*((_DWORD *)a1 + 13562) = 0;
LABEL_26:
while ( (unsigned int)read_section(v3, v23) )
{
v21 = *((_DWORD *)a1 + 161);
v16 = memcmp(v23, "repo", 4uLL) == 0;
v11 = !v16;
if ( !v16 )
goto LABEL_26;
if ( v25 > 0 )
{
v12 = &v24;
do
{
if ( !strncasecmp(v12 - 64, "path", 4uLL) )
{
if ( !strcmp(v17, "NONE") )
strcpy(s, v12);
else
sprintf(s, "%s/%s", v17, v12);
}
else if ( !strncasecmp(v12 - 64, "on", 2uLL) )
{
if ( !atoi(v12) )
{
if ( *((_BYTE *)a1 + 3) )
printf("just ignore \x1B[1;33m'%s'\x1B[m..\n", s);
goto LABEL_26;
}
}
else if ( !strncasecmp(v12 - 64, "interval", 8uLL) )
{
v13 = atoi(v12);
if ( v13 > 0 )
v21 = v13;
}
++v11;
v12 += 192;
}
while ( v25 > v11 );
}
sprintf(v20, "%s/%s", s, v18);
v14 = &a1[268 * *((int *)a1 + 13562) + 324];
*(_QWORD *)v14 = *(_QWORD *)s;
*((_QWORD *)v14 + 66) = v22;
qmemcpy(
(void *)((unsigned __int64)(v14 + 4) & 0xFFFFFFFFFFFFFFF8LL),
(const void *)(s - ((char *)v14 - ((unsigned __int64)(v14 + 4) & 0xFFFFFFFFFFFFFFF8LL))),
8LL * (((unsigned int)v14 - (((_DWORD)v14 + 8) & 0xFFFFFFF8) + 536) >> 3));
v15 = &a1[268 * *((int *)a1 + 13562)];
*((_QWORD *)v15 + 146) = 0LL;
*((_QWORD *)v15 + 147) = 0LL;
if ( *((_BYTE *)a1 + 3) )
printf(
"load repo conf:\tpath=\t\x1B[1;33m%s\x1B[m\tinterval=\t\x1B[1;33m%d\x1B[m\tsigfile=\x1B[1;33m%s\x1B[m\n",
s,
v21,
v20);
++*((_DWORD *)a1 + 13562);
}
close_ini(v3);
if ( *((_BYTE *)a1 + 3) )
printf("totally \x1B[1;33m%d\x1B[m repo loaded\n", *((unsigned int *)a1 + 13562));
result = *((unsigned int *)a1 + 13562);
if ( *a1 > (int)result )
*a1 = result;
}
else
{
printf("%s-%d:open file '%s' for reading failed\n", "configserver.c", 301LL, (const char *)a1 + 4);
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int load_repo_conf (config_t * conf)
{
 void * ini = ((void *)0);
 section sc;
 if(((void *)0) == (ini = init_ini(conf->conf)))
     {
   printf ("%s-%d:open file '%s' for reading failed\n","configserver.c", 301, conf->conf);
            return -1;
     }
 conf->interval = atoi (read_string(ini, "general", "interval", "600"));
 conf->nthread = atoi (read_string(ini, "general", "thread_num", "10"));
 conf->loop = atoi (read_string(ini, "general", "loop", "0"));
 sprintf (conf->basedir, "%s", read_string(ini, "general", "basedir", "NONE"));
 sprintf (conf->sigfile, "%s", read_string(ini, "general", "signalfile", "update.txt"));
 sprintf (conf->user, "%s", read_string(ini, "general", "user", "root"));
 if (conf->verb)
 {
  printf ("repobuilder conf:\n\tinterval = ""\033[1;33m""%d""\033[m""\n\tthread_num = ""\033[1;33m""%d""\033[m""\n\tsignalfile=""\033[1;33m""%s""\033[m""\n",
  conf->interval, conf->nthread, conf->sigfile);
 }
 conf->repo_num = 0;
 while (read_section(ini, &sc))
    {
        int i = 0;
  repo_t rp;
  int on = 1;
  int valid = 1;
  rp.intv = conf->interval;
  if (strncmp(sc.title, "repo", 4))continue;
        for ( i = 0; i < sc.entry_number; i++)
           {
                  if (strncasecmp(sc.entry_list[i].var_name, "path", 4) == 0)
                    {
       if(strcmp(conf->basedir, "NONE"))
                             sprintf(rp.path, "%s/%s", conf->basedir, sc.entry_list[i].var_value);
       else
        sprintf(rp.path, "%s", sc.entry_list[i].var_value);
                            continue;
                     }
     if (strncasecmp(sc.entry_list[i].var_name, "on", 2) == 0)
                    {
                            on = atoi(sc.entry_list[i].var_value);
       if (!on)
       {
        valid = 0;
        break;
       }
                           continue;
                     }
     if (strncasecmp(sc.entry_list[i].var_name, "interval", 8) == 0)
                    {
       int intv = 0;
                            intv = atoi(sc.entry_list[i].var_value);
       if (intv > 0) rp.intv = intv;
                            continue;
                     }
   }
   if (!valid )
   {
    if (conf->verb) printf ("just ignore ""\033[1;33m""'%s'""\033[m""..\n", rp.path);
    continue;
   }
   sprintf (rp.sigfile, "%s/%s", rp.path, conf->sigfile);
   memcpy (conf->repo_list + conf->repo_num, &rp, sizeof(repo_t));
   conf->repo_list[conf->repo_num].next = ((void *)0);
   conf->repo_list[conf->repo_num].last_update = 0;
      if (conf->verb)
   {
    printf ("load repo conf:\tpath=\t""\033[1;33m""%s""\033[m""\tinterval=\t""\033[1;33m""%d""\033[m""\tsigfile=""\033[1;33m""%s""\033[m""\n",
     rp.path,rp.intv,rp.sigfile);
   }
   conf->repo_num++;
 }
 close_ini (ini);
 if (conf->verb)
 {
  printf ("totally ""\033[1;33m""%d""\033[m"" repo loaded\n", conf->repo_num);
 }
 if (conf->nthread > conf->repo_num) conf->nthread = conf->repo_num;
 return conf->repo_num;
}

canonical_original_code:
int load_repo_conf(struct config_t *conf)
{
 void *ini = ((void *)0);
 struct _section sc;
 if(((void *)0) == (ini = init_ini(conf->conf)))
     {
   printf ("%s-%d:open file '%s' for reading failed\n","configserver.c", 301, conf->conf);
            return -1;
     }
 conf->interval = atoi (read_string(ini, "general", "interval", "600"));
 conf->nthread = atoi (read_string(ini, "general", "thread_num", "10"));
 conf->loop = atoi (read_string(ini, "general", "loop", "0"));
 sprintf (conf->basedir, "%s", read_string(ini, "general", "basedir", "NONE"));
 sprintf (conf->sigfile, "%s", read_string(ini, "general", "signalfile", "update.txt"));
 sprintf (conf->user, "%s", read_string(ini, "general", "user", "root"));
 if (conf->verb)
 {
  printf ("repobuilder conf:\n\tinterval = ""\033[1;33m""%d""\033[m""\n\tthread_num = ""\033[1;33m""%d""\033[m""\n\tsignalfile=""\033[1;33m""%s""\033[m""\n",
  conf->interval, conf->nthread, conf->sigfile);
 }
 conf->repo_num = 0;
 while (read_section(ini, &sc))
    {
        int i = 0;
  struct _repo rp;
  int on = 1;
  int valid = 1;
  rp.intv = conf->interval;
  if (strncmp(sc.title, "repo", 4))continue;
        for ( i = 0; i < sc.entry_number; i++)
           {
                  if (strncasecmp(sc.entry_list[i].var_name, "path", 4) == 0)
                    {
       if(strcmp(conf->basedir, "NONE"))
                             sprintf(rp.path, "%s/%s", conf->basedir, sc.entry_list[i].var_value);
       else
        sprintf(rp.path, "%s", sc.entry_list[i].var_value);
                            continue;
                     }
     if (strncasecmp(sc.entry_list[i].var_name, "on", 2) == 0)
                    {
                            on = atoi(sc.entry_list[i].var_value);
       if (!on)
       {
        valid = 0;
        break;
       }
                           continue;
                     }
     if (strncasecmp(sc.entry_list[i].var_name, "interval", 8) == 0)
                    {
       int intv = 0;
                            intv = atoi(sc.entry_list[i].var_value);
       if (intv > 0) rp.intv = intv;
                            continue;
                     }
   }
   if (!valid )
   {
    if (conf->verb) printf ("just ignore ""\033[1;33m""'%s'""\033[m""..\n", rp.path);
    continue;
   }
   sprintf (rp.sigfile, "%s/%s", rp.path, conf->sigfile);
   memcpy (conf->repo_list + conf->repo_num, &rp, sizeof(repo_t));
   conf->repo_list[conf->repo_num].next = ((void *)0);
   conf->repo_list[conf->repo_num].last_update = 0;
      if (conf->verb)
   {
    printf ("load repo conf:\tpath=\t""\033[1;33m""%s""\033[m""\tinterval=\t""\033[1;33m""%d""\033[m""\tsigfile=""\033[1;33m""%s""\033[m""\n",
     rp.path,rp.intv,rp.sigfile);
   }
   conf->repo_num++;
 }
 close_ini (ini);
 if (conf->verb)
 {
  printf ("totally ""\033[1;33m""%d""\033[m"" repo loaded\n", conf->repo_num);
 }
 if (conf->nthread > conf->repo_num) conf->nthread = conf->repo_num;
 return conf->repo_num;
}

variable_types:
ini
void *

variable_types: struct _section { char title[64]; struct _var_entry { char var_name[64]; char var_value[128]; } entry_list[200]; int entry_number; }

variable_types: i int

variable_types: struct _repo { char path[256]; char sigfile[256]; int intv; void *next; long last_update; }

variable_types: on int

variable_types: valid int

variable_types: intv int

user_defined_types: struct _section { char title[64]; struct _var_entry entry_list[200]; int entry_number; }


decompiled_code:
int __fastcall act_uploadpkg_init(int argc, char **argv, char *a3)
{
char *v4; // r13
int v5; // eax
int result; // eax
const char *v7; // r12
struct stat v8; // [rsp+0h] [rbp-B8h] BYREF

optind = 1;
v4 = a3 + 1028;
while ( 2 )
{
v5 = getopt(argc, argv, "hc:k:f:v:r:a:i:e:m:");
if ( v5 == -1 )
{
if ( a3[132] )
{
if ( a3[260] )
{
if ( a3[324] )
{
if ( a3[388] )
{
v7 = a3 + 132;
result = stat(v7, &v8);
if ( result )
{
printf("can not access file: '%s'\n", v7);
result = 1;
}
}
else
{
puts("instance name is needed");
my_usage((unsigned int)argc, (const char **)argv);
result = 1;
}
}
else
{
puts("version is needed");
my_usage((unsigned int)argc, (const char **)argv);
result = 1;
}
}
else
{
puts("repo is needed");
my_usage((unsigned int)argc, (const char **)argv);
result = 1;
}
}
else
{
puts("uploadpkg file is needed");
my_usage((unsigned int)argc, (const char **)argv);
result = 1;
}
}
else
{
switch ( v5 )
{
case 'f':
sprintf(a3 + 132, optarg);
continue;
case 'h':
my_usage((unsigned int)argc, (const char **)argv);
result = 1;
break;
case 'i':
sprintf(a3 + 388, optarg);
continue;
case 'm':
sprintf(v4, optarg);
continue;
case 'r':
sprintf(a3 + 260, optarg);
continue;
case 'v':
sprintf(a3 + 324, optarg);
continue;
default:
continue;
}
}
break;
}
return result;
}

canonical_decompiled_code:
int __fastcall func1(int argc, char **argv, char *a3)
{
char *v4; // r13
int v5; // eax
int result; // eax
const char *v7; // r12
struct stat v8; // [rsp+0h] [rbp-B8h] BYREF

optind = 1;
v4 = a3 + 1028;
while ( 2 )
{
v5 = getopt(argc, argv, "hc:k:f:v:r:a:i:e:m:");
if ( v5 == -1 )
{
if ( a3[132] )
{
if ( a3[260] )
{
if ( a3[324] )
{
if ( a3[388] )
{
v7 = a3 + 132;
result = stat(v7, &v8);
if ( result )
{
printf("can not access file: '%s'\n", v7);
result = 1;
}
}
else
{
puts("instance name is needed");
func0((unsigned int)argc, (const char **)argv);
result = 1;
}
}
else
{
puts("version is needed");
func0((unsigned int)argc, (const char **)argv);
result = 1;
}
}
else
{
puts("repo is needed");
func0((unsigned int)argc, (const char **)argv);
result = 1;
}
}
else
{
puts("uploadpkg file is needed");
func0((unsigned int)argc, (const char **)argv);
result = 1;
}
}
else
{
switch ( v5 )
{
case 'f':
sprintf(a3 + 132, optarg);
continue;
case 'h':
func0((unsigned int)argc, (const char **)argv);
result = 1;
break;
case 'i':
sprintf(a3 + 388, optarg);
continue;
case 'm':
sprintf(v4, optarg);
continue;
case 'r':
sprintf(a3 + 260, optarg);
continue;
case 'v':
sprintf(a3 + 324, optarg);
continue;
default:
continue;
}
}
break;
}
return result;
}

original_code:
int act_uploadpkg_init(int argc, char* argv[], gk_conf_t * gc)
{
 int opt;
 struct stat st;
    char *string = "hc:k:f:v:r:a:i:e:m:";
 optind = 1;
    while ((opt = getopt(argc, argv, string))!= -1)
    {
  switch(opt)
  {
   case 'f':
     sprintf(gc->file, optarg);
     break;
   case 'r':
     sprintf(gc->repo, optarg);
     break;
   case 'v':
     sprintf(gc->osv, optarg);
     break;
   case 'i':
     sprintf(gc->app, optarg);
     break;
   case 'm':
     sprintf(gc->info, optarg);
     break;
   case 'h':
    my_usage(argc, argv);
    return 1;
  }
    }
 if(strlen(gc->file) == 0) {printf("uploadpkg file is needed\n"); my_usage(argc, argv);return 1;}
 if(strlen(gc->repo) == 0) {printf("repo is needed\n"); my_usage(argc, argv);return 1;}
 if(strlen(gc->osv) == 0) {printf("version is needed\n"); my_usage(argc, argv);return 1;}
 if(strlen(gc->app) == 0) {printf("instance name is needed\n"); my_usage(argc, argv);return 1;}
 if(stat(gc->file, &st)) {printf("can not access file: '%s'\n",gc->file);return 1;}
 return 0;
}

canonical_original_code:
int act_uploadpkg_init(int argc, char *argv[], struct _gk_conf_t *gc)
{
 int opt;
 struct stat st;
    char *string = "hc:k:f:v:r:a:i:e:m:";
 optind = 1;
    while ((opt = getopt(argc, argv, string))!= -1)
    {
  switch(opt)
  {
   case 'f':
     sprintf(gc->file, optarg);
     break;
   case 'r':
     sprintf(gc->repo, optarg);
     break;
   case 'v':
     sprintf(gc->osv, optarg);
     break;
   case 'i':
     sprintf(gc->app, optarg);
     break;
   case 'm':
     sprintf(gc->info, optarg);
     break;
   case 'h':
    my_usage(argc, argv);
    return 1;
  }
    }
 if(strlen(gc->file) == 0) {printf("uploadpkg file is needed\n"); my_usage(argc, argv);return 1;}
 if(strlen(gc->repo) == 0) {printf("repo is needed\n"); my_usage(argc, argv);return 1;}
 if(strlen(gc->osv) == 0) {printf("version is needed\n"); my_usage(argc, argv);return 1;}
 if(strlen(gc->app) == 0) {printf("instance name is needed\n"); my_usage(argc, argv);return 1;}
 if(stat(gc->file, &st)) {printf("can not access file: '%s'\n",gc->file);return 1;}
 return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: struct _gk_conf_t { enum GK_ACTION { ACT_MIN_ACTION=0, ACT_UPLOAD_PKG=1, ACT_LIST_REPO=2, ACT_LIST_PKG=3, ACT_MAX_ACTION=4 } action; char conf[128]; char file[128]; char repo[64]; char osv[64]; char app[64]; char ak[64]; char as[64]; char uid[64]; char url[128]; char user[64]; char output[64]; char upload_method[64]; char endpoint[64]; char info[512]; } *

variable_types: opt int

variable_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; long st_atime; unsigned long st_atimensec; long st_mtime; unsigned long st_mtimensec; long st_ctime; unsigned long st_ctimensec; long __glibc_reserved[3]; }

variable_types:
string
char *

user_defined_types: struct _gk_conf_t { enum GK_ACTION action; char conf[128]; char file[128]; char repo[64]; char osv[64]; char app[64]; char ak[64]; char as[64]; char uid[64]; char url[128]; char user[64]; char output[64]; char upload_method[64]; char endpoint[64]; char info[512]; }


original_code:
int get_nic_list(nic_t *list)
{
 int _sock;
 int nRet = 0;
 int i = 0;
 struct ifreq _ifr;
 struct ifconf _ifc;
 int n;
 struct ifreq *pifr = 0;
 nic_t _device;
 _sock = socket( 2, SOCK_DGRAM, 0 );
 if (_sock <= 0)
 {
  printf ("socket failed\n");
   return -1;
 }
 bzero( &_ifc, sizeof(_ifc) );
 int ret = ioctl( _sock, 0x8912, &_ifc, sizeof(_ifc) );
 if (ret != 0)
 {
  printf ("ioclt SIOCGIFCONF, failed:%d:%d\n", ret, _sock);
   return -1;
 }
 _ifc.ifc_ifcu.ifcu_buf = (char *)malloc( _ifc.ifc_len );
 bzero( _ifc.ifc_ifcu.ifcu_buf, _ifc.ifc_len );
 ret = ioctl( _sock, 0x8912, &_ifc, sizeof(_ifc) );
 if (ret != 0) goto out;
  n = _ifc.ifc_len / sizeof(struct ifreq);
 pifr = (struct ifreq *)_ifc.ifc_ifcu.ifcu_buf;
 for ( i = 0; i < n; ++i, ++pifr )
 {
  if ( pifr->ifr_ifru.ifru_addr.sa_family != 2 ) continue;
  bzero( &_device, sizeof(_device) );
  bzero( &_ifr, sizeof(_ifr) );
  strcpy( _ifr.ifr_ifrn.ifrn_name, pifr->ifr_ifrn.ifrn_name );
  int ret = ioctl( _sock, 0x8927, &_ifr, sizeof(_ifr) );
  if (ret != 0) continue;
  if ( _ifr.ifr_ifru.ifru_hwaddr.sa_family != 1 ) continue;
  memcpy( _device.mac, _ifr.ifr_ifru.ifru_hwaddr.sa_data, 6 );
  ret = ioctl( _sock, 0x8915, &_ifr, sizeof(_ifr) );
  if (ret != 0) continue;
  memcpy( &_device.ip, _ifr.ifr_ifru.ifru_addr.sa_data, 4 );
  _device.ip = ((struct sockaddr_in *)(&_ifr.ifr_ifru.ifru_addr))->sin_addr.s_addr;
  ret = ioctl( _sock, 0x891b, &_ifr, sizeof(_ifr) );
  if (ret != 0) continue;
  _device.netmask = ((struct sockaddr_in *)(&_ifr.ifr_ifru.ifru_netmask))->sin_addr.s_addr;
  strncpy( _device.name, _ifr.ifr_ifrn.ifrn_name, sizeof(_device.name)-1 );
  memcpy (list + nRet, &_device, sizeof(nic_t));
  nRet++;
 }
out:
 free( _ifc.ifc_ifcu.ifcu_buf);
 close(_sock);
 return nRet;
}

canonical_original_code:
int get_nic_list(struct nic_t *list)
{
 int _sock;
 int nRet = 0;
 int i = 0;
 struct ifreq _ifr;
 struct ifconf _ifc;
 int n;
 struct ifreq *pifr = 0;
 struct nic_t _device;
 _sock = socket( 2, SOCK_DGRAM, 0 );
 if (_sock <= 0)
 {
  printf ("socket failed\n");
   return -1;
 }
 bzero( &_ifc, sizeof(_ifc) );
 int ret = ioctl( _sock, 0x8912, &_ifc, sizeof(_ifc) );
 if (ret != 0)
 {
  printf ("ioclt SIOCGIFCONF, failed:%d:%d\n", ret, _sock);
   return -1;
 }
 _ifc.ifc_ifcu.ifcu_buf = (char *)malloc( _ifc.ifc_len );
 bzero( _ifc.ifc_ifcu.ifcu_buf, _ifc.ifc_len );
 ret = ioctl( _sock, 0x8912, &_ifc, sizeof(_ifc) );
 if (ret != 0) goto out;
  n = _ifc.ifc_len / sizeof(struct ifreq);
 pifr = (struct ifreq *)_ifc.ifc_ifcu.ifcu_buf;
 for ( i = 0; i < n; ++i, ++pifr )
 {
  if ( pifr->ifr_ifru.ifru_addr.sa_family != 2 ) continue;
  bzero( &_device, sizeof(_device) );
  bzero( &_ifr, sizeof(_ifr) );
  strcpy( _ifr.ifr_ifrn.ifrn_name, pifr->ifr_ifrn.ifrn_name );
  int ret = ioctl( _sock, 0x8927, &_ifr, sizeof(_ifr) );
  if (ret != 0) continue;
  if ( _ifr.ifr_ifru.ifru_hwaddr.sa_family != 1 ) continue;
  memcpy( _device.mac, _ifr.ifr_ifru.ifru_hwaddr.sa_data, 6 );
  ret = ioctl( _sock, 0x8915, &_ifr, sizeof(_ifr) );
  if (ret != 0) continue;
  memcpy( &_device.ip, _ifr.ifr_ifru.ifru_addr.sa_data, 4 );
  _device.ip = ((struct sockaddr_in *)(&_ifr.ifr_ifru.ifru_addr))->sin_addr.s_addr;
  ret = ioctl( _sock, 0x891b, &_ifr, sizeof(_ifr) );
  if (ret != 0) continue;
  _device.netmask = ((struct sockaddr_in *)(&_ifr.ifr_ifru.ifru_netmask))->sin_addr.s_addr;
  strncpy( _device.name, _ifr.ifr_ifrn.ifrn_name, sizeof(_device.name)-1 );
  memcpy (list + nRet, &_device, sizeof(nic_t));
  nRet++;
 }
out:
 free( _ifc.ifc_ifcu.ifcu_buf);
 close(_sock);
 return nRet;
}

variable_types: struct nic_t { unsigned int ip; unsigned int netmask; unsigned char mac[6]; char name[30]; } *

variable_types: nRet int

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

variable_types: n int

variable_types: ret int

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

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