usage

decompiled_code:
int usage()
{
puts("Sintaxis, descripcion de parametros: ");
puts("verific [-t <num_segundos>][-d <directorio>][-a <archivo>] \n");
puts(
"-t <num_segundos> : numero de segundos que deben transcurrir entre dos revisiones consecutivas de los directorios monitorizados. ");
puts(
"-d <directorio> : a direccion absoluta de un directorio que se desea monitorizar, para ver si en el ha ocurrido algu"
"n cambio desde la ultima vez que se efectuo la revision. ");
return puts(
"-a <archivo> : archivo en formato de texto plano en el cual cada linea contendra un URL que correspondera a u"
"n directorio cuya informacion se desea verificar. ");
}

canonical_decompiled_code:
int func1()
{
puts("Sintaxis, descripcion de parametros: ");
puts("verific [-t <num_segundos>][-d <directorio>][-a <archivo>] \n");
puts(
"-t <num_segundos> : numero de segundos que deben transcurrir entre dos revisiones consecutivas de los directorios monitorizados. ");
puts(
"-d <directorio> : a direccion absoluta de un directorio que se desea monitorizar, para ver si en el ha ocurrido algu"
"n cambio desde la ultima vez que se efectuo la revision. ");
return puts(
"-a <archivo> : archivo en formato de texto plano en el cual cada linea contendra un URL que correspondera a u"
"n directorio cuya informacion se desea verificar. ");
}

original_code:
void usage(){
        printf("Sintaxis, descripcion de parametros: \n");
        printf("verific [-t <num_segundos>][-d <directorio>][-a <archivo>] \n\n");
        printf("-t <num_segundos> : numero de segundos que deben transcurrir entre dos revisiones consecutivas de los directorios monitorizados. \n");
        printf("-d <directorio> : a direccion absoluta de un directorio que se desea monitorizar, para ver si en el ha ocurrido algun cambio desde la ultima vez que se efectuo la revision. \n");
        printf("-a <archivo> : archivo en formato de texto plano en el cual cada linea contendra un URL que correspondera a un directorio cuya informacion se desea verificar. \n");
}


IsaNumber

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

result = 1LL;
if ( !a1 )
{
puts("Error en linea de argumentos ");
usage();
result = 0LL;
}
return result;
}

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

result = 1LL;
if ( !a1 )
{
puts("Error en linea de argumentos ");
func1();
result = 0LL;
}
return result;
}

original_code:
int IsaNumber(int num){
    if (!num) {
        printf("Error en linea de argumentos \n");
        usage();
        return (0);
    }
    return (1);
}

variable_types: num int

return_type: int


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

result = socket(2, 1, 6);
if ( result < 0 )
{
perror("No se pudo crear el socket TCP");
exit(1);
}
return result;
}

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

result = socket(2, 1, 6);
if ( result < 0 )
{
perror("No se pudo crear el socket TCP");
exit(1);
}
return result;
}

original_code:
int create_tcp_socket(){
    int sock;
    if((sock = socket(2, SOCK_STREAM, IPPROTO_TCP)) < 0){
        perror("No se pudo crear el socket TCP");
        exit(1);
    }
    return sock;
}

variable_types: sock int


decompiled_code:
char *__fastcall get_ip(char *name)
{
char *v1; // rax
char *v2; // rbx
struct hostent *v3; // rax

v1 = (char *)malloc(0x10uLL);
if ( !v1 )
{
perror("No Hay Memoria Disponible para el ip");
exit(1);
}
v2 = v1;
*(_QWORD *)v1 = 0LL;
*((_QWORD *)v1 + 1) = 0LL;
v3 = gethostbyname(name);
if ( !v3 )
{
herror("No se Consigue IP");
exit(1);
}
if ( !inet_ntop(2, *(const void **)v3->h_addr_list, v2, 0xFu) )
{
perror("No se puede Identificar el host");
exit(1);
}
return v2;
}

canonical_decompiled_code:
char *__fastcall func5(char *name)
{
char *v1; // rax
char *v2; // rbx
struct hostent *v3; // rax

v1 = (char *)malloc(0x10uLL);
if ( !v1 )
{
perror("No Hay Memoria Disponible para el ip");
exit(1);
}
v2 = v1;
*(_QWORD *)v1 = 0LL;
*((_QWORD *)v1 + 1) = 0LL;
v3 = gethostbyname(name);
if ( !v3 )
{
herror("No se Consigue IP");
exit(1);
}
if ( !inet_ntop(2, *(const void **)v3->h_addr_list, v2, 0xFu) )
{
perror("No se puede Identificar el host");
exit(1);
}
return v2;
}

original_code:
char *get_ip(char *host){
    struct hostent *hent;
    int iplen = 15;
    char *ip = (char *)malloc(iplen+1);
    if(ip==((void *)0))
    {
        perror("No Hay Memoria Disponible para el ip");
        exit(1);
    }
    memset(ip, 0, iplen+1);
    if((hent = gethostbyname(host)) == ((void *)0))
    {
        herror("No se Consigue IP");
        exit(1);
    }
    if(inet_ntop(2, (void *)hent->h_addr_list[0], ip, iplen) == ((void *)0))
    {
        perror("No se puede Identificar el host");
        exit(1);
    }
    return ip;
}

variable_types:
host
char *

variable_types: struct hostent { char *h_name; char **h_aliases; int h_addrtype; int h_length; char **h_addr_list; } *

variable_types: iplen int

variable_types:
ip
char *

return_type: char *


decompiled_code:
char *__fastcall build_get_query(char *s, char *a2)
{
char *v2; // rbx
size_t v3; // rbp
size_t v4; // rax
char *v5; // rax
char *v6; // rbp

v2 = a2;
if ( *a2 == 47 )
{
fprintf(stderr, "Elimine el \"/\", Convierta %s en %s\n", a2, a2 + 1);
v2 = a2 + 1;
}
v3 = strlen(s);
v4 = strlen(v2);
v5 = (char *)malloc(v3 + v4 + 52);
v6 = v5;
if ( !v5 )
{
perror("No Hay Espacio Disponible para la asignacion del query");
exit(1);
}
sprintf(v5, "GET /%s HTTP/1.1\r\nHost: %s\r\nUser-Agent: %s\r\n\r\n", v2, s, "HTMLGET 1.1");
return v6;
}

canonical_decompiled_code:
char *__fastcall func6(char *s, char *a2)
{
char *v2; // rbx
size_t v3; // rbp
size_t v4; // rax
char *v5; // rax
char *v6; // rbp

v2 = a2;
if ( *a2 == 47 )
{
fprintf(stderr, "Elimine el \"/\", Convierta %s en %s\n", a2, a2 + 1);
v2 = a2 + 1;
}
v3 = strlen(s);
v4 = strlen(v2);
v5 = (char *)malloc(v3 + v4 + 52);
v6 = v5;
if ( !v5 )
{
perror("No Hay Espacio Disponible para la asignacion del query");
exit(1);
}
sprintf(v5, "GET /%s HTTP/1.1\r\nHost: %s\r\nUser-Agent: %s\r\n\r\n", v2, s, "HTMLGET 1.1");
return v6;
}

original_code:
char *build_get_query(char *host, char *page)
{
    char *query;
    char *getpage = page;
    char *tpl = "GET /%s HTTP/1.1\r\nHost: %s\r\nUser-Agent: %s\r\n\r\n";
    if(getpage[0] == '/'){
        getpage = getpage + 1;
        fprintf(stderr,"Elimine el \"/\", Convierta %s en %s\n", page, getpage);
    }
    query = (char *)malloc(strlen(host)+strlen(getpage)+strlen("HTMLGET 1.1")+strlen(tpl)-5);
    if(query==((void *)0))
    {
        perror("No Hay Espacio Disponible para la asignacion del query");
        exit(1);
    }
    sprintf(query, tpl, getpage, host, "HTMLGET 1.1");
    return query;
}

variable_types:
page
char *

variable_types:
query
char *

variable_types:
getpage
char *

variable_types:
tpl
char *


decompiled_code:
char *__fastcall Verific_URL(char *s, char *a2)
{
char *v2; // r13
int v3; // er12
struct sockaddr *v4; // rax
struct sockaddr *v5; // r14
int v6; // eax
char *v7; // rbp
int i; // er15
size_t v9; // rax
int v10; // eax
int v11; // er15
const char *v12; // rsi
int v13; // eax
int v14; // ebx
char *v15; // rax
char *cp; // [rsp+8h] [rbp-2050h]
char sa[8264]; // [rsp+10h] [rbp-2048h] BYREF

v2 = (char *)malloc(0x1000uLL);
*v2 = 0;
v3 = create_tcp_socket();
cp = get_ip(s);
v4 = (struct sockaddr *)malloc(8uLL);
if ( !v4 )
{
perror("No Hay Espacio Disponible para el sockaddr_in");
exit(1);
}
v5 = v4;
v4->sa_family = 2;
v6 = inet_pton(2, cp, &v4->sa_data[2]);
if ( v6 < 0 )
{
perror("La direccion especifica no es soportada.");
exit(1);
}
if ( !v6 )
{
fprintf(stderr, "%s No es una Direccion IP Valida\n", cp);
exit(1);
}
*(_WORD *)v5->sa_data = _bswap_16(80);
if ( connect(v3, v5, 0x10u) < 0 )
{
perror("No se puede establecer Conexion");
exit(1);
}
v7 = build_get_query(s, a2);
for ( i = 0; ; i += v10 )
{
v9 = strlen(v7);
if ( i >= v9 )
break;
v10 = send(v3, &v7[i], v9 - i, 0);
if ( v10 == -1 )
{
perror("Error al enviar el query de GET");
exit(1);
}
}
memset(sa, 0, 0x2001uLL);
v11 = 0;
while ( 1 )
{
v13 = recv(v3, sa, 0x2000uLL, 0);
v14 = v13;
if ( v13 <= 0 )
break;
if ( v11 )
{
v12 = sa;
LABEL_16:
strcat(v2, v12);
v11 = 1;
goto LABEL_17;
}
v15 = strstr(sa, "\r\n\r\n");
v12 = v15 + 4;
if ( v15 )
goto LABEL_16;
LABEL_17:
memset(sa, 0, v14);
}
if ( v13 < 0 )
{
perror("Error al recibir la Respuesta del Servidor");
exit(1);
}
free(v7);
free(v5);
free(cp);
close(v3);
return v2;
}

canonical_decompiled_code:
char *__fastcall func7(char *s, char *a2)
{
char *v2; // r13
int v3; // er12
struct sockaddr *v4; // rax
struct sockaddr *v5; // r14
int v6; // eax
char *v7; // rbp
int i; // er15
size_t v9; // rax
int v10; // eax
int v11; // er15
const char *v12; // rsi
int v13; // eax
int v14; // ebx
char *v15; // rax
char *cp; // [rsp+8h] [rbp-2050h]
char sa[8264]; // [rsp+10h] [rbp-2048h] BYREF

v2 = (char *)malloc(0x1000uLL);
*v2 = 0;
v3 = func4();
cp = func5(s);
v4 = (struct sockaddr *)malloc(8uLL);
if ( !v4 )
{
perror("No Hay Espacio Disponible para el sockaddr_in");
exit(1);
}
v5 = v4;
v4->sa_family = 2;
v6 = inet_pton(2, cp, &v4->sa_data[2]);
if ( v6 < 0 )
{
perror("La direccion especifica no es soportada.");
exit(1);
}
if ( !v6 )
{
fprintf(stderr, "%s No es una Direccion IP Valida\n", cp);
exit(1);
}
*(_WORD *)v5->sa_data = func0(80);
if ( connect(v3, v5, 0x10u) < 0 )
{
perror("No se puede establecer Conexion");
exit(1);
}
v7 = func6(s, a2);
for ( i = 0; ; i += v10 )
{
v9 = strlen(v7);
if ( i >= v9 )
break;
v10 = send(v3, &v7[i], v9 - i, 0);
if ( v10 == -1 )
{
perror("Error al enviar el query de GET");
exit(1);
}
}
memset(sa, 0, 0x2001uLL);
v11 = 0;
while ( 1 )
{
v13 = recv(v3, sa, 0x2000uLL, 0);
v14 = v13;
if ( v13 <= 0 )
break;
if ( v11 )
{
v12 = sa;
LABEL_16:
strcat(v2, v12);
v11 = 1;
goto LABEL_17;
}
v15 = strstr(sa, "\r\n\r\n");
v12 = v15 + 4;
if ( v15 )
goto LABEL_16;
LABEL_17:
memset(sa, 0, v14);
}
if ( v13 < 0 )
{
perror("Error al recibir la Respuesta del Servidor");
exit(1);
}
free(v7);
free(v5);
free(cp);
close(v3);
return v2;
}

original_code:
char* Verific_URL(char * host, char * page)
{
    struct sockaddr_in *remote;
    int sock;
    int tmpres;
    char *ip;
    char *get;
    char buf[8192 +1];
    char *Res =(char *) malloc (sizeof(char)*1024*4) ;
    strcpy (Res,"");
    sock = create_tcp_socket();
    ip = get_ip(host);
    remote = (struct sockaddr_in *)malloc(sizeof(struct sockaddr_in *));
    if(remote==((void *)0)){
        perror("No Hay Espacio Disponible para el sockaddr_in");
        exit(1);
    }
    remote->sin_family = 2;
    tmpres = inet_pton(2, ip, (void *)(&(remote->sin_addr.s_addr)));
    if( tmpres < 0)
    {
        perror("La direccion especifica no es soportada.");
        exit(1);
    }else if(tmpres == 0)
    {
        fprintf(stderr, "%s No es una Direccion IP Valida\n", ip);
        exit(1);
    }
    remote->sin_port = htons(80);
    if(connect(sock, (struct sockaddr *)remote, sizeof(struct sockaddr)) < 0){
        perror("No se puede establecer Conexion");
        exit(1);
    }
    get = build_get_query(host, page);
    int sent = 0;
    while(sent < strlen(get))
    {
        tmpres = send(sock, get+sent, strlen(get)-sent, 0);
        if(tmpres == -1){
            perror("Error al enviar el query de GET");
            exit(1);
        }
        sent += tmpres;
    }
    memset(buf, 0, sizeof(buf));
    int htmlstart = 0;
    char * htmlcontent;
    while((tmpres = recv(sock, buf, 8192, 0)) > 0){
        if(htmlstart == 0)
        {
            htmlcontent = strstr(buf, "\r\n\r\n");
            if(htmlcontent != ((void *)0)){
                htmlstart = 1;
                htmlcontent += 4;
            }
        }else{
            htmlcontent = buf;
        }
        if(htmlstart){
      strcat (Res,htmlcontent);
        }
        memset(buf, 0, tmpres);
    }
    if(tmpres < 0)
    {
        perror("Error al recibir la Respuesta del Servidor");
  exit(1);
    }
    free(get);
    free(remote);
    free(ip);
    close(sock);
    return Res;
}

canonical_original_code:
char *Verific_URL(char *host, char *page)
{
    struct sockaddr_in *remote;
    int sock;
    int tmpres;
    char *ip;
    char *get;
    char buf[-1];
    char *Res = (char *) malloc (sizeof(char)*1024*4);
    strcpy (Res,"");
    sock = create_tcp_socket();
    ip = get_ip(host);
    remote = (struct sockaddr_in *)malloc(sizeof(struct sockaddr_in *));
    if(remote==((void *)0)){
        perror("No Hay Espacio Disponible para el sockaddr_in");
        exit(1);
    }
    remote->sin_family = 2;
    tmpres = inet_pton(2, ip, (void *)(&(remote->sin_addr.s_addr)));
    if( tmpres < 0)
    {
        perror("La direccion especifica no es soportada.");
        exit(1);
    }else if(tmpres == 0)
    {
        fprintf(stderr, "%s No es una Direccion IP Valida\n", ip);
        exit(1);
    }
    remote->sin_port = htons(80);
    if(connect(sock, (struct sockaddr *)remote, sizeof(struct sockaddr)) < 0){
        perror("No se puede establecer Conexion");
        exit(1);
    }
    get = build_get_query(host, page);
    int sent = 0;
    while(sent < strlen(get))
    {
        tmpres = send(sock, get+sent, strlen(get)-sent, 0);
        if(tmpres == -1){
            perror("Error al enviar el query de GET");
            exit(1);
        }
        sent += tmpres;
    }
    memset(buf, 0, sizeof(buf));
    int htmlstart = 0;
    char *htmlcontent;
    while((tmpres = recv(sock, buf, 8192, 0)) > 0){
        if(htmlstart == 0)
        {
            htmlcontent = strstr(buf, "\r\n\r\n");
            if(htmlcontent != ((void *)0)){
                htmlstart = 1;
                htmlcontent += 4;
            }
        }else{
            htmlcontent = buf;
        }
        if(htmlstart){
      strcat (Res,htmlcontent);
        }
        memset(buf, 0, tmpres);
    }
    if(tmpres < 0)
    {
        perror("Error al recibir la Respuesta del Servidor");
  exit(1);
    }
    free(get);
    free(remote);
    free(ip);
    close(sock);
    return Res;
}

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]; } *

variable_types: tmpres int

variable_types:
get
char *

variable_types:
buf
char [-1]

variable_types:
Res
char *

variable_types: sent int

variable_types: htmlstart int

variable_types:
htmlcontent
char *

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

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


espera

decompiled_code:
clock_t __fastcall espera(int a1)
{
clock_t v1; // rbx
clock_t result; // rax

v1 = clock() + 1000000LL * a1;
do
result = clock();
while ( result < v1 );
return result;
}

canonical_decompiled_code:
clock_t __fastcall func0(int a1)
{
clock_t v1; // rbx
clock_t result; // rax

v1 = clock() + 1000000LL * a1;
do
result = clock();
while ( result < v1 );
return result;
}

original_code:
void espera (int Seconds){
  clock_t endwait;
  endwait = clock () + Seconds * ((__clock_t) 1000000) ;
  while(clock() < endwait){
  }
}

canonical_original_code:
void espera(int Seconds){
  long endwait;
  endwait = clock () + Seconds * ((long) 1000000) ;
  while(clock() < endwait){
  }
}

variable_types: Seconds int

variable_types: endwait long

return_type: void


decompiled_code:
__int64 __fastcall Procesar_Respuesta(char *a1, __int64 a2)
{
char *v3; // rax
char *v4; // rbp
size_t v5; // rax
char *v6; // rbp
size_t v7; // rax
char *v8; // rbp
size_t v9; // rax
char *v11; // [rsp+0h] [rbp-438h] BYREF
char v12[6]; // [rsp+Eh] [rbp-42Ah] BYREF
char v13[12]; // [rsp+14h] [rbp-424h] BYREF
char dest[1048]; // [rsp+20h] [rbp-418h] BYREF

strtok_r(a1, "<>", &v11);
while ( 1 )
{
v3 = strtok_r(0LL, "<>", &v11);
if ( !v3 )
break;
if ( *v3 == 97 )
{
if ( strcmp(v3, "address") )
{
v4 = strtok_r(0LL, "><", &v11);
v5 = strlen(v4);
memcpy(dest, v4, v5 + 1);
if ( strcmp(v4, "Name") )
{
if ( strcmp(v4, "Last modified") && strcmp(v4, "Size") && strcmp(v4, "Description") )
{
if ( strcmp(v4, "Parent Directory") )
{
strtok_r(0LL, ">", &v11);
v6 = strtok_r(0LL, " ", &v11);
v7 = strlen(v6);
memcpy(v13, v6, v7 + 1);
v8 = strtok_r(0LL, " ", &v11);
v9 = strlen(v8);
memcpy(v12, v8, v9 + 1);
a2 = agregar(a2, dest, v13, v12);
}
}
}
}
}
}
return a2;
}

canonical_decompiled_code:
__int64 __fastcall func1(char *a1, __int64 a2)
{
char *v3; // rax
char *v4; // rbp
size_t v5; // rax
char *v6; // rbp
size_t v7; // rax
char *v8; // rbp
size_t v9; // rax
char *v11; // [rsp+0h] [rbp-438h] BYREF
char v12[6]; // [rsp+Eh] [rbp-42Ah] BYREF
char v13[12]; // [rsp+14h] [rbp-424h] BYREF
char dest[1048]; // [rsp+20h] [rbp-418h] BYREF

strtok_r(a1, "<>", &v11);
while ( 1 )
{
v3 = strtok_r(0LL, "<>", &v11);
if ( !v3 )
break;
if ( *v3 == 97 )
{
if ( strcmp(v3, "address") )
{
v4 = strtok_r(0LL, "><", &v11);
v5 = strlen(v4);
memcpy(dest, v4, v5 + 1);
if ( strcmp(v4, "Name") )
{
if ( strcmp(v4, "Last modified") && strcmp(v4, "Size") && strcmp(v4, "Description") )
{
if ( strcmp(v4, "Parent Directory") )
{
strtok_r(0LL, ">", &v11);
v6 = strtok_r(0LL, " ", &v11);
v7 = strlen(v6);
memcpy(v13, v6, v7 + 1);
v8 = strtok_r(0LL, " ", &v11);
v9 = strlen(v8);
memcpy(v12, v8, v9 + 1);
a2 = agregar(a2, dest, v13, v12);
}
}
}
}
}
}
return a2;
}

original_code:
Lista* Procesar_Respuesta(char *Pagina, Lista *Res)
{
    char tmp1[1024];
    char tmp2[12];
    char tmp3[6];
    char * ptr2;
    char * ptr = strtok_r (Pagina,"<>",&ptr2);
    while( (ptr = strtok_r( ((void *)0),"<>",&ptr2)) != ((void *)0) ){
        if(ptr[0]=='a' && strcmp(ptr,"address")!=0){
            ptr = strtok_r( ((void *)0),"><",&ptr2);
            memcpy(tmp1,ptr,strlen(ptr)+1);
             if(strcmp(ptr,"Name")!=0 && strcmp(ptr,"Last modified")!=0 && strcmp(ptr,"Size")!=0 && strcmp(ptr,"Description")!=0 && strcmp(ptr,"Parent Directory")!=0)
             {
                ptr = strtok_r( ((void *)0),">",&ptr2);
                ptr = strtok_r( ((void *)0)," ",&ptr2);
                memcpy(tmp2,ptr,strlen(ptr)+1);
                ptr = strtok_r( ((void *)0)," ",&ptr2);
                memcpy(tmp3,ptr,strlen(ptr)+1);
                Res = agregar(Res,tmp1,tmp2,tmp3);
             }
        }
    }
    return Res;
}

canonical_original_code:
struct NodoL *Procesar_Respuesta(char *Pagina, struct NodoL *Res)
{
    char tmp1[1024];
    char tmp2[12];
    char tmp3[6];
    char *ptr2;
    char *ptr = strtok_r (Pagina,"<>",&ptr2);
    while( (ptr = strtok_r( ((void *)0),"<>",&ptr2)) != ((void *)0) ){
        if(ptr[0]=='a' && strcmp(ptr,"address")!=0){
            ptr = strtok_r( ((void *)0),"><",&ptr2);
            memcpy(tmp1,ptr,strlen(ptr)+1);
             if(strcmp(ptr,"Name")!=0 && strcmp(ptr,"Last modified")!=0 && strcmp(ptr,"Size")!=0 && strcmp(ptr,"Description")!=0 && strcmp(ptr,"Parent Directory")!=0)
             {
                ptr = strtok_r( ((void *)0),">",&ptr2);
                ptr = strtok_r( ((void *)0)," ",&ptr2);
                memcpy(tmp2,ptr,strlen(ptr)+1);
                ptr = strtok_r( ((void *)0)," ",&ptr2);
                memcpy(tmp3,ptr,strlen(ptr)+1);
                Res = agregar(Res,tmp1,tmp2,tmp3);
             }
        }
    }
    return Res;
}

variable_types:
Pagina
char *

variable_types:
Res
struct NodoL *

variable_types:
ptr
char *

return_type: struct NodoL { char *Archivo; int Tiempo; struct NodoL *Siguiente; } *


RevisarDir

decompiled_code:
void __fastcall RevisarDir(__int64 a1)
{
__int64 v1; // rbx
const char *v2; // r15
void *v3; // rsp
size_t v4; // rax
char *v5; // rax
__int64 v6; // r15
char *v7; // rax
char v8; // [rsp-48h] [rbp-48h] BYREF
char *v9; // [rsp-40h] [rbp-40h]

if ( tam_arrD > 0 )
{
v1 = 0LL;
do
{
puts(*(const char **)(arrD + 8 * v1));
v2 = *(const char **)(arrD + 8 * v1);
v3 = alloca(16 * ((strlen(v2) + 16) / 0x10));
v4 = strlen(v2);
memcpy(&v8, v2, v4 + 1);
strtok(&v8, "://");
v9 = strtok(0LL, "//");
v5 = strtok(0LL, &byte_6F2);
v6 = *(_QWORD *)(a1 + 8 * v1);
v7 = (char *)Verific_URL(v9, v5);
*(_QWORD *)(a1 + 8 * v1++) = Procesar_Respuesta(v7, v6);
}
while ( tam_arrD > (int)v1 );
}
}

canonical_decompiled_code:
void __fastcall func3(__int64 a1)
{
__int64 v1; // rbx
const char *v2; // r15
void *v3; // rsp
size_t v4; // rax
char *v5; // rax
__int64 v6; // r15
char *v7; // rax
char v8; // [rsp-48h] [rbp-48h] BYREF
char *v9; // [rsp-40h] [rbp-40h]

if ( tam_arrD > 0 )
{
v1 = 0LL;
do
{
puts(*(const char **)(arrD + 8 * v1));
v2 = *(const char **)(arrD + 8 * v1);
v3 = alloca(16 * ((strlen(v2) + 16) / 0x10));
v4 = strlen(v2);
memcpy(&v8, v2, v4 + 1);
strtok(&v8, "://");
v9 = strtok(0LL, "//");
v5 = strtok(0LL, &byte_6F2);
v6 = *(_QWORD *)(a1 + 8 * v1);
v7 = (char *)Verific_URL(v9, v5);
*(_QWORD *)(a1 + 8 * v1++) = func1(v7, v6);
}
while ( tam_arrD > (int)v1 );
}
}

original_code:
void RevisarDir(Lista *Res[]){
    char *url;
    char *t1;
    char *path;
    char *protocolo;
    int i;
    for(i=0;i<tam_arrD;i++)
    {
  printf("%s\n",arrD[i]);
        char aux[strlen(arrD[i])+1];
        memcpy(aux,arrD[i],strlen(arrD[i])+1);
        url = aux;
        t1 = strtok(url,"://");
        protocolo = t1;
        t1 = strtok(((void *)0), "//");
        url = t1;
        t1 = strtok(((void *)0), "");
        path = t1;
        Res[i] = Procesar_Respuesta(Verific_URL(url,path),Res[i]);
    }
}

canonical_original_code:
void RevisarDir(struct NodoL *Res[]){
    char *url;
    char *t1;
    char *path;
    char *protocolo;
    int i;
    for(i=0;i<tam_arrD;i++)
    {
  printf("%s\n",arrD[i]);
        char aux[-1];
        memcpy(aux,arrD[i],strlen(arrD[i])+1);
        url = aux;
        t1 = strtok(url,"://");
        protocolo = t1;
        t1 = strtok(((void *)0), "//");
        url = t1;
        t1 = strtok(((void *)0), "");
        path = t1;
        Res[i] = Procesar_Respuesta(Verific_URL(url,path),Res[i]);
    }
}

variable_types: struct NodoL { char *Archivo; int Tiempo; struct NodoL *Siguiente; } *[]

variable_types:
url
char *

variable_types:
path
char *

variable_types:
protocolo
char *

variable_types: i int

variable_types:
aux
char [-1]


main

canonical_name: main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
void *v3; // rsp
_QWORD *v4; // rax
_QWORD *v5; // rdx
__pid_t v6; // er12
int v7; // eax
int v8; // ebx
char v9; // al
_QWORD v10[4]; // [rsp+0h] [rbp-20h] BYREF

if ( (unsigned int)VerificarEntrada(argc, (__int64)argv) != 1 )
{
v3 = alloca(8LL * tam_arrD);
if ( tam_arrD > 0 )
{
v4 = v10;
v5 = &v10[tam_arrD];
do
*v4++ = 0LL;
while ( v4 != v5 );
}
v6 = fork();
if ( v6 == -1 )
{
puts("error en creacion de proceso hijo");
exit(1);
}
while ( 1 )
{
do
{
while ( v6 )
{
v9 = getchar();
switch ( v9 )
{
case 's':
puts("Salida");
exit(0);
case 'c':
puts("Continua");
kill(v6, 18);
break;
case 'p':
puts("Pausado");
kill(v6, 19);
break;
}
}
v7 = t;
v8 = 0;
}
while ( t <= 0 );
do
{
if ( v7 - 1 == v8 )
{
RevisarDir((__int64)v10);
putchar(10);
}
espera(1);
++v8;
v7 = t;
}
while ( t > v8 );
}
}
perror("Error en la Sintaxys");
exit(1);
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
void *v3; // rsp
_QWORD *v4; // rax
_QWORD *v5; // rdx
__pid_t v6; // er12
int v7; // eax
int v8; // ebx
char v9; // al
_QWORD v10[4]; // [rsp+0h] [rbp-20h] BYREF

if ( (unsigned int)func2(argc, (__int64)argv) != 1 )
{
v3 = alloca(8LL * tam_arrD);
if ( tam_arrD > 0 )
{
v4 = v10;
v5 = &v10[tam_arrD];
do
*v4++ = 0LL;
while ( v4 != v5 );
}
v6 = fork();
if ( v6 == -1 )
{
puts("error en creacion de proceso hijo");
exit(1);
}
while ( 1 )
{
do
{
while ( v6 )
{
v9 = getchar();
switch ( v9 )
{
case 's':
puts("Salida");
exit(0);
case 'c':
puts("Continua");
kill(v6, 18);
break;
case 'p':
puts("Pausado");
kill(v6, 19);
break;
}
}
v7 = t;
v8 = 0;
}
while ( t <= 0 );
do
{
if ( v7 - 1 == v8 )
{
func3((__int64)v10);
putchar(10);
}
func0(1);
++v8;
v7 = t;
}
while ( t > v8 );
}
}
perror("Error en la Sintaxys");
exit(1);
}

original_code:
int main(int argc, char** argv) {
    int h = 0;
    int cic = 0;
    int u = 0;
 int k = 0;
 int pid;
 char cara = 'j';
 int pc = 0;
    if(VerificarEntrada(argc,argv)==1){
        perror("Error en la Sintaxys");
        exit(1);
    }
    Lista *Res[tam_arrD];
    for(k=0;k<tam_arrD;k++){
        Res[k]=((void *)0);
    }
 if ((pid=fork()) == -1) {
  printf ("error en creacion de proceso hijo\n");
  exit(1);
 }
 else {
  while(1){
   if(pid != 0){
    cara = getchar();
    if(cara=='s'){
    printf("Salida\n");
     exit(0);
    }
    if(cara=='c'){
    printf("Continua\n");
    kill(pid,18);
    }
    if(cara=='p'){
    printf("Pausado\n");
    kill(pid,19);
    }
   }
   else{
    for (h=0;h<t;h++){
     cic++;
     if(h==t-1){
      cic=0;
      RevisarDir(Res);
      printf("\n");
     }
     espera(1);
    }
   }
  }
 }
  return u;
}

canonical_original_code:
int main(int argc, char **argv) {
    int h = 0;
    int cic = 0;
    int u = 0;
 int k = 0;
 int pid;
 char cara = 'j';
 int pc = 0;
    if(VerificarEntrada(argc,argv)==1){
        perror("Error en la Sintaxys");
        exit(1);
    }
    struct NodoL *Res[-1];
    for(k=0;k<tam_arrD;k++){
        Res[k]=((void *)0);
    }
 if ((pid=fork()) == -1) {
  printf ("error en creacion de proceso hijo\n");
  exit(1);
 }
 else {
  while(1){
   if(pid != 0){
    cara = getchar();
    if(cara=='s'){
    printf("Salida\n");
     exit(0);
    }
    if(cara=='c'){
    printf("Continua\n");
    kill(pid,18);
    }
    if(cara=='p'){
    printf("Pausado\n");
    kill(pid,19);
    }
   }
   else{
    for (h=0;h<t;h++){
     cic++;
     if(h==t-1){
      cic=0;
      RevisarDir(Res);
      printf("\n");
     }
     espera(1);
    }
   }
  }
 }
  return u;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: h int

variable_types: cic int

variable_types: u int

variable_types: k int

variable_types: pid int

variable_types: cara char

variable_types: pc int

variable_types: struct NodoL { char *Archivo; int Tiempo; struct NodoL *Siguiente; } *[-1]


Convert

decompiled_code:
__int64 __fastcall Convert(void *src, void *a2)
{
void *v2; // rsp
size_t v3; // rax
void *v4; // rsp
size_t v5; // rax
char *v6; // rax
int v7; // er14
char *v8; // rax
bool v9; // zf
int v10; // ebx
char *v11; // rax
int v12; // er12
char *v13; // rax
int v14; // er13
char *v15; // rax
char v17[32]; // [rsp+0h] [rbp-20h] BYREF

v2 = alloca(16 * ((strlen((const char *)src) + 16) / 0x10));
v3 = strlen((const char *)src);
memcpy(v17, src, v3 + 1);
v4 = alloca(16 * ((strlen((const char *)a2) + 16) / 0x10));
v5 = strlen((const char *)a2);
memcpy(v17, a2, v5 + 1);
v6 = strtok(v17, " -");
v7 = 100 * atoi(v6);
v8 = strtok(0LL, " -");
v9 = strcmp(v8, "Ene") == 0;
v10 = 2;
if ( strcmp(v8, "Feb") )
{
v9 = v9;
v10 = v9;
}
if ( !strcmp(v8, "Mar") )
v10 = 3;
if ( !strcmp(v8, "Abr") )
v10 = 4;
if ( !strcmp(v8, "May") )
v10 = 5;
if ( !strcmp(v8, "Jun") )
v10 = 6;
if ( !strcmp(v8, "Jul") )
v10 = 7;
if ( !strcmp(v8, "Ago") )
v10 = 8;
if ( !strcmp(v8, "Sep") )
v10 = 9;
if ( !strcmp(v8, "Oct") )
v10 = 10;
if ( !strcmp(v8, "Nov") )
v10 = 11;
if ( !strcmp(v8, "Dic") )
v10 = 12;
v11 = strtok(0LL, " -");
v12 = atoi(v11);
v13 = strtok(v17, ":");
v14 = atoi(v13);
v15 = strtok(0LL, ":");
return (unsigned int)(10000 * v12 + v7 + 1000 * v10 + 10 * v14 + atoi(v15));
}

canonical_decompiled_code:
__int64 __fastcall func0(void *src, void *a2)
{
void *v2; // rsp
size_t v3; // rax
void *v4; // rsp
size_t v5; // rax
char *v6; // rax
int v7; // er14
char *v8; // rax
bool v9; // zf
int v10; // ebx
char *v11; // rax
int v12; // er12
char *v13; // rax
int v14; // er13
char *v15; // rax
char v17[32]; // [rsp+0h] [rbp-20h] BYREF

v2 = alloca(16 * ((strlen((const char *)src) + 16) / 0x10));
v3 = strlen((const char *)src);
memcpy(v17, src, v3 + 1);
v4 = alloca(16 * ((strlen((const char *)a2) + 16) / 0x10));
v5 = strlen((const char *)a2);
memcpy(v17, a2, v5 + 1);
v6 = strtok(v17, " -");
v7 = 100 * atoi(v6);
v8 = strtok(0LL, " -");
v9 = strcmp(v8, "Ene") == 0;
v10 = 2;
if ( strcmp(v8, "Feb") )
{
v9 = v9;
v10 = v9;
}
if ( !strcmp(v8, "Mar") )
v10 = 3;
if ( !strcmp(v8, "Abr") )
v10 = 4;
if ( !strcmp(v8, "May") )
v10 = 5;
if ( !strcmp(v8, "Jun") )
v10 = 6;
if ( !strcmp(v8, "Jul") )
v10 = 7;
if ( !strcmp(v8, "Ago") )
v10 = 8;
if ( !strcmp(v8, "Sep") )
v10 = 9;
if ( !strcmp(v8, "Oct") )
v10 = 10;
if ( !strcmp(v8, "Nov") )
v10 = 11;
if ( !strcmp(v8, "Dic") )
v10 = 12;
v11 = strtok(0LL, " -");
v12 = atoi(v11);
v13 = strtok(v17, ":");
v14 = atoi(v13);
v15 = strtok(0LL, ":");
return (unsigned int)(10000 * v12 + v7 + 1000 * v10 + 10 * v14 + atoi(v15));
}

original_code:
int Convert(char * Date, char *Hour)
{
    char Str[strlen(Date)+1];
    memcpy(Str,Date,strlen(Date)+1);
    char Str2[strlen(Hour)+1];
    memcpy(Str2,Hour,strlen(Hour)+1);
     int Aux[5];
     Aux[0]= atoi(strtok (Str," -")) * 100;
     char *Mes = strtok (((void *)0)," -");
     int Ms = 0;
     if(strcmp(Mes,"Ene")==0)
         Ms = 1;
     if(strcmp(Mes,"Feb")==0)
         Ms = 2;
     if(strcmp(Mes,"Mar")==0)
         Ms = 3;
     if(strcmp(Mes,"Abr")==0)
         Ms = 4;
     if(strcmp(Mes,"May")==0)
         Ms = 5;
     if(strcmp(Mes,"Jun")==0)
         Ms = 6;
     if(strcmp(Mes,"Jul")==0)
         Ms = 7;
     if(strcmp(Mes,"Ago")==0)
         Ms = 8;
     if(strcmp(Mes,"Sep")==0)
         Ms = 9;
     if(strcmp(Mes,"Oct")==0)
         Ms = 10;
     if(strcmp(Mes,"Nov")==0)
         Ms = 11;
     if(strcmp(Mes,"Dic")==0)
         Ms = 12;
     Aux[1]= Ms * 1000;
     Aux[2]= atoi(strtok (((void *)0)," -")) * 10000;
     Aux[3]= atoi(strtok (Str2,":")) * 10;
     Aux[4]= atoi(strtok (((void *)0),":")) * 1;
     int i;
     int Sum=0;
     for(i=0;i<5;i++)
     {
          Sum += Aux[i];
     }
     return Sum;
}

canonical_original_code:
int Convert(char *Date, char *Hour)
{
    char Str[-1];
    memcpy(Str,Date,strlen(Date)+1);
    char Str2[-1];
    memcpy(Str2,Hour,strlen(Hour)+1);
     int Aux[5];
     Aux[0]= atoi(strtok (Str," -")) * 100;
     char *Mes = strtok (((void *)0)," -");
     int Ms = 0;
     if(strcmp(Mes,"Ene")==0)
         Ms = 1;
     if(strcmp(Mes,"Feb")==0)
         Ms = 2;
     if(strcmp(Mes,"Mar")==0)
         Ms = 3;
     if(strcmp(Mes,"Abr")==0)
         Ms = 4;
     if(strcmp(Mes,"May")==0)
         Ms = 5;
     if(strcmp(Mes,"Jun")==0)
         Ms = 6;
     if(strcmp(Mes,"Jul")==0)
         Ms = 7;
     if(strcmp(Mes,"Ago")==0)
         Ms = 8;
     if(strcmp(Mes,"Sep")==0)
         Ms = 9;
     if(strcmp(Mes,"Oct")==0)
         Ms = 10;
     if(strcmp(Mes,"Nov")==0)
         Ms = 11;
     if(strcmp(Mes,"Dic")==0)
         Ms = 12;
     Aux[1]= Ms * 1000;
     Aux[2]= atoi(strtok (((void *)0)," -")) * 10000;
     Aux[3]= atoi(strtok (Str2,":")) * 10;
     Aux[4]= atoi(strtok (((void *)0),":")) * 1;
     int i;
     int Sum = 0;
     for(i=0;i<5;i++)
     {
          Sum += Aux[i];
     }
     return Sum;
}

variable_types:
Date
char *

variable_types:
Hour
char *

variable_types:
Str
char [-1]

variable_types:
Aux
int [5]

variable_types:
Mes
char *

variable_types: Ms int

variable_types: Sum int


agregar

decompiled_code:
const char **__fastcall agregar(const char **a1, const char *a2, void *a3, void *a4)
{
const char *v4; // r12
const char **v7; // rbx
const char **v8; // r15
char *v9; // rdi
int v11; // eax
int v12; // edx

v4 = (const char *)a1;
if ( a1 )
{
v7 = a1;
while ( strcmp(*v7, a2) )
{
v7 = (const char **)v7[2];
if ( !v7 )
goto LABEL_5;
}
v11 = Convert(a3, a4);
v12 = *((_DWORD *)v7 + 2);
if ( v12 == v11 )
{
puts(a2);
v8 = a1;
}
else
{
v8 = a1;
if ( v12 < v11 )
{
*((_DWORD *)v7 + 2) = v11;
printf("**Actualizado** %s\n", a2);
}
}
}
else
{
LABEL_5:
v8 = (const char **)malloc(0x18uLL);
if ( !v8 )
{
perror("No Hay Espacio Disponible para la Lista");
exit(1);
}
v9 = (char *)malloc(8uLL);
*v8 = v9;
if ( !v9 )
{
perror("No Hay Espacio Disponible para la Lista");
exit(1);
}
strcpy(v9, a2);
*((_DWORD *)v8 + 2) = Convert(a3, a4);
v8[2] = v4;
printf("**NUEVO** %s\n", *v8);
}
return v8;
}

canonical_decompiled_code:
const char **__fastcall func1(const char **a1, const char *a2, void *a3, void *a4)
{
const char *v4; // r12
const char **v7; // rbx
const char **v8; // r15
char *v9; // rdi
int v11; // eax
int v12; // edx

v4 = (const char *)a1;
if ( a1 )
{
v7 = a1;
while ( strcmp(*v7, a2) )
{
v7 = (const char **)v7[2];
if ( !v7 )
goto LABEL_5;
}
v11 = func0(a3, a4);
v12 = *((_DWORD *)v7 + 2);
if ( v12 == v11 )
{
puts(a2);
v8 = a1;
}
else
{
v8 = a1;
if ( v12 < v11 )
{
*((_DWORD *)v7 + 2) = v11;
printf("**Actualizado** %s\n", a2);
}
}
}
else
{
LABEL_5:
v8 = (const char **)malloc(0x18uLL);
if ( !v8 )
{
perror("No Hay Espacio Disponible para la Lista");
exit(1);
}
v9 = (char *)malloc(8uLL);
*v8 = v9;
if ( !v9 )
{
perror("No Hay Espacio Disponible para la Lista");
exit(1);
}
strcpy(v9, a2);
*((_DWORD *)v8 + 2) = func0(a3, a4);
v8[2] = v4;
printf("**NUEVO** %s\n", *v8);
}
return v8;
}

original_code:
Lista* agregar(Lista *Li,char *Nombre,char *Date, char *Hour)
{
    Lista *Aux = Li;
    while(Aux != ((void *)0))
    {
        if(strcmp(Aux->Archivo,Nombre)==0)
        {
            int tmp = Convert(Date,Hour);
            if(Aux->Tiempo==tmp)
                printf("%s\n",Nombre);
            else if(Aux->Tiempo<tmp)
            {
                Aux->Tiempo=tmp;
                printf("**Actualizado** %s\n",Nombre);
            }
            return Li;
        }
        Aux = Aux->Siguiente;
    }
    Archivo *nuevo = (Archivo *)malloc(sizeof(Archivo));
    if(nuevo==((void *)0)){
        perror("No Hay Espacio Disponible para la Lista");
        exit(1);
    }
    nuevo->Archivo = (char *)malloc (sizeof(Nombre));
    if(nuevo->Archivo==((void *)0)){
        perror("No Hay Espacio Disponible para la Lista");
        exit(1);
    }
    strcpy(nuevo->Archivo, Nombre);
    nuevo->Tiempo = Convert(Date,Hour);
    nuevo->Siguiente = Li;
    printf("**NUEVO** %s\n",nuevo->Archivo);
    return nuevo;
}

canonical_original_code:
struct NodoL *agregar(struct NodoL *Li, char *Nombre, char *Date, char *Hour)
{
    struct NodoL *Aux = Li;
    while(Aux != ((void *)0))
    {
        if(strcmp(Aux->Archivo,Nombre)==0)
        {
            int tmp = Convert(Date,Hour);
            if(Aux->Tiempo==tmp)
                printf("%s\n",Nombre);
            else if(Aux->Tiempo<tmp)
            {
                Aux->Tiempo=tmp;
                printf("**Actualizado** %s\n",Nombre);
            }
            return Li;
        }
        Aux = Aux->Siguiente;
    }
    struct NodoL *nuevo = (Archivo *)malloc(sizeof(Archivo));
    if(nuevo==((void *)0)){
        perror("No Hay Espacio Disponible para la Lista");
        exit(1);
    }
    nuevo->Archivo = (char *)malloc (sizeof(Nombre));
    if(nuevo->Archivo==((void *)0)){
        perror("No Hay Espacio Disponible para la Lista");
        exit(1);
    }
    strcpy(nuevo->Archivo, Nombre);
    nuevo->Tiempo = Convert(Date,Hour);
    nuevo->Siguiente = Li;
    printf("**NUEVO** %s\n",nuevo->Archivo);
    return nuevo;
}

variable_types:
Li
struct NodoL *

variable_types:
Nombre
char *

variable_types: struct NodoL { char *Archivo; int Tiempo; struct NodoL *Siguiente; } *

variable_types: tmp int


Imprimir

decompiled_code:
int __fastcall Imprimir(__int64 a1)
{
__int64 i; // rbx
int result; // eax

for ( i = a1; i; i = *(_QWORD *)(i + 16) )
result = printf("%s\n%d\n", *(const char **)i, *(unsigned int *)(i + 8));
return result;
}

canonical_decompiled_code:
int __fastcall func2(__int64 a1)
{
__int64 i; // rbx
int result; // eax

for ( i = a1; i; i = *(_QWORD *)(i + 16) )
result = printf("%s\n%d\n", *(const char **)i, *(unsigned int *)(i + 8));
return result;
}

original_code:
void Imprimir(Lista *Li)
{
    Lista *Aux = Li;
    while(Aux != ((void *)0))
    {
        printf("%s\n%d\n",Aux->Archivo,Aux->Tiempo);
        Aux = Aux->Siguiente;
    }
}

canonical_original_code:
void Imprimir(struct NodoL *Li)
{
    struct NodoL *Aux = Li;
    while(Aux != ((void *)0))
    {
        printf("%s\n%d\n",Aux->Archivo,Aux->Tiempo);
        Aux = Aux->Siguiente;
    }
}

user_defined_types: struct NodoL { char *Archivo; int Tiempo; struct NodoL *Siguiente; }


czas

repo: jmudry/zjp

decompiled_code:
__syscall_slong_t czas()
{
struct timespec v1; // [rsp+0h] [rbp-18h] BYREF

clock_gettime(1, &v1);
return v1.tv_nsec + 1000000000 * v1.tv_sec;
}

canonical_decompiled_code:
__syscall_slong_t func7()
{
struct timespec v1; // [rsp+0h] [rbp-18h] BYREF

clock_gettime(1, &v1);
return v1.tv_nsec + 1000000000 * v1.tv_sec;
}

original_code:
long int czas() {
 struct timespec t;
 clock_gettime(1, &t);
 return ((t.tv_sec * 1000000000) + t.tv_nsec);
}

canonical_original_code:
long czas() {
 struct timespec t;
 clock_gettime(1, &t);
 return ((t.tv_sec * 1000000000) + t.tv_nsec);
}

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

return_type: long


f

decompiled_code:
double __fastcall f(double a1)
{
return pow(2.718281828459045, a1 * -a1);
}

canonical_decompiled_code:
double __fastcall func8(double a1)
{
return pow(2.718281828459045, a1 * -a1);
}

variable_types: x double

return_type: double


liczCalke

decompiled_code:
double __fastcall liczCalke(int a1, double a2, double a3)
{
double v3; // r14
double v4; // rbx
int i; // ebx
double v7; // [rsp+0h] [rbp-38h]
double v8; // [rsp+8h] [rbp-30h]

v3 = a2;
v8 = (a3 - a2) / (double)a1;
v4 = f(a2);
v7 = 0.0 - (v4 + f(a3)) * 0.5;
if ( a1 >= 0 )
{
for ( i = 0; i <= a1; ++i )
{
v3 = v3 + v8;
v7 = f(v3) + v7;
}
}
return v8 * v7;
}

canonical_decompiled_code:
double __fastcall func9(int a1, double a2, double a3)
{
double v3; // r14
double v4; // rbx
int i; // ebx
double v7; // [rsp+0h] [rbp-38h]
double v8; // [rsp+8h] [rbp-30h]

v3 = a2;
v8 = (a3 - a2) / (double)a1;
v4 = func8(a2);
v7 = 0.0 - (v4 + func8(a3)) * 0.5;
if ( a1 >= 0 )
{
for ( i = 0; i <= a1; ++i )
{
v3 = v3 + v8;
v7 = func8(v3) + v7;
}
}
return v8 * v7;
}

original_code:
double liczCalke(double a, double b, int n){
 double suma =0;
 double h = (b-a)/n;
 int i;
 double x = a;
 suma -= (f(a) + f(b))/2;
 for (i=0 ; i<= n ; i++){
  x += h;
  suma += f(x);
 }
 return suma*h;
}

canonical_original_code:
double liczCalke(double a, double b, int n){
 double suma = 0;
 double h = (b-a)/n;
 int i;
 double x = a;
 suma -= (f(a) + f(b))/2;
 for (i=0 ; i<= n ; i++){
  x += h;
  suma += f(x);
 }
 return suma*h;
}

variable_types: a double

variable_types: b double

variable_types: n int

variable_types: suma double

variable_types: h double

variable_types: i int


MaxValue

repo: jmuldoon/Euler

decompiled_code:
__int64 __fastcall MaxValue(unsigned int *a1)
{
__int64 result; // rax
_QWORD *i; // rbx

result = *a1;
for ( i = (_QWORD *)*((_QWORD *)a1 + 1); i; i = (_QWORD *)i[1] )
result = (unsigned int)(int)fmax((double)(int)result, (double)(int)*i);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int *a1)
{
__int64 result; // rax
_QWORD *i; // rbx

result = *a1;
for ( i = (_QWORD *)*((_QWORD *)a1 + 1); i; i = (_QWORD *)i[1] )
result = (unsigned int)(int)fmax((double)(int)result, (double)(int)*i);
return result;
}

original_code:
int MaxValue(SLL *head){
    SLL *tmp;
    int max;
    for (tmp = head, max = tmp->data; tmp->next!=((void *)0); tmp=tmp->next)
        max = fmax(max, tmp->next->data);
    return max;
}

canonical_original_code:
int MaxValue(struct node *head){
    struct node *tmp;
    int max;
    for (tmp = head, max = tmp->data; tmp->next!=((void *)0); tmp=tmp->next)
        max = fmax(max, tmp->next->data);
    return max;
}

variable_types: struct node { long long data; struct node *next; } *

variable_types: max int


Display

decompiled_code:
int __fastcall Display(_QWORD *a1)
{
_QWORD *i; // rbx

for ( i = a1; i; i = (_QWORD *)i[1] )
printf("%d ", *i);
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func1(_QWORD *a1)
{
_QWORD *i; // rbx

for ( i = a1; i; i = (_QWORD *)i[1] )
printf("%d ", *i);
return putchar(10);
}

original_code:
void Display(SLL *head){
    SLL *tmp = head;
    for(;tmp!=((void *)0); tmp=tmp->next)
        printf("%d ",tmp->data);
    printf("\n");
}

canonical_original_code:
void Display(struct node *head){
    struct node *tmp = head;
    for(;tmp!=((void *)0); tmp=tmp->next)
        printf("%d ",tmp->data);
    printf("\n");
}

user_defined_types: struct node { long long data; struct node *next; }


Count

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

if ( !a1 )
return 0LL;
LODWORD(result) = 0;
do
{
a1 = *(_QWORD *)(a1 + 8);
result = (unsigned int)(result + 1);
}
while ( a1 );
return result;
}

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

if ( !a1 )
return 0LL;
LODWORD(result) = 0;
do
{
a1 = *(_QWORD *)(a1 + 8);
result = (unsigned int)(result + 1);
}
while ( a1 );
return result;
}

original_code:
int Count(SLL *head){
    SLL *tmp=head;
    int c;
    for(c=0, tmp=head;tmp!=((void *)0);tmp=tmp->next, c++);
    return c;
}

canonical_original_code:
int Count(struct node *head){
    struct node *tmp = head;
    int c;
    for(c=0, tmp=head;tmp!=((void *)0);tmp=tmp->next, c++);
    return c;
}

variable_types: c int


IsPrime

decompiled_code:
__int64 __fastcall IsPrime(__int64 a1)
{
__int64 v1; // rbx
double v2; // xmm0_8
double x; // [rsp+8h] [rbp-20h]

v1 = 2LL;
x = (double)(int)a1;
while ( 1 )
{
v2 = x < 0.0 ? sqrt(x) : sqrt(x);
if ( (unsigned int)(int)v2 < v1 )
break;
if ( !(a1 % v1) )
return 0LL;
++v1;
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
__int64 v1; // rbx
double v2; // xmm0_8
double x; // [rsp+8h] [rbp-20h]

v1 = 2LL;
x = (double)(int)a1;
while ( 1 )
{
v2 = x < 0.0 ? sqrt(x) : sqrt(x);
if ( (unsigned int)(int)v2 < v1 )
break;
if ( !(a1 % v1) )
return 0LL;
++v1;
}
return 1LL;
}

original_code:
int IsPrime(long long int v){
 long long int ch;
 for (ch = 2; ch <= (long long int)sqrt(v); ch++)
  if(v%ch == 0) return 0;
 return 1;
}

canonical_original_code:
int IsPrime(long long v){
 long long ch;
 for (ch = 2; ch <= (long long)sqrt(v); ch++)
  if(v%ch == 0) return 0;
 return 1;
}

variable_types:
v
long long

variable_types:
ch
long long


DestroyAllWindows

repo: jmullan/xfewer

decompiled_code:
__int64 DestroyAllWindows()
{
__int64 i; // rdi
__int64 result; // rax

for ( i = windowlist; windowlist; i = windowlist )
result = DestroyWindowInfo(i);
return result;
}

canonical_decompiled_code:
__int64 func4()
{
__int64 i; // rdi
__int64 result; // rax

for ( i = windowlist; windowlist; i = windowlist )
result = func3(i);
return result;
}

original_code:
void
DestroyAllWindows()
{
    while (windowlist)
        DestroyWindowInfo(windowlist);
}


CheckFonts

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

buttonFont = resources[6];
if ( !buttonFont )
buttonFont = resources[3];
labelFont = resources[5];
if ( !labelFont )
labelFont = resources[3];
textFont = resources[4];
if ( !textFont )
textFont = resources[3];
result = resources[8];
dialogcur = result;
stdcur = result;
if ( !buttonFont || !labelFont || !textFont )
{
fprintf(stderr, "%s: unable to open any of the specified fonts\n", progname);
exit(1);
}
return result;
}

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

buttonFont = resources[6];
if ( !buttonFont )
buttonFont = resources[3];
labelFont = resources[5];
if ( !labelFont )
labelFont = resources[3];
textFont = resources[4];
if ( !textFont )
textFont = resources[3];
result = resources[8];
dialogcur = result;
stdcur = result;
if ( !buttonFont || !labelFont || !textFont )
{
fprintf(stderr, "%s: unable to open any of the specified fonts\n", progname);
exit(1);
}
return result;
}

original_code:
void
CheckFonts()
{
    if (!(buttonFont = resources.fonts.button))
        buttonFont = resources.fonts.standard;
    if (!(labelFont = resources.fonts.label))
        labelFont = resources.fonts.standard;
    if (!(textFont = resources.fonts.text))
        textFont = resources.fonts.standard;
    dialogcur = resources.cursors.dialog;
    stdcur = resources.cursors.dialog;
    if (!buttonFont || !labelFont || !textFont) {
        fprintf(stderr, "%s: unable to open any of the specified fonts\n",
                progname);
        exit(1);
    }
}


cleanup

decompiled_code:
__int64 cleanup()
{
XtDestroyWidget(toplevel);
return XtDestroyApplicationContext(context);
}

canonical_decompiled_code:
__int64 func2()
{
XtDestroyWidget(toplevel);
return XtDestroyApplicationContext(context);
}

original_code:
static void
cleanup()
{
    XtDestroyWidget(toplevel);
    XtDestroyApplicationContext(context);
}


QuitFunction

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

if ( windowcount == 1 || (result = QuitAllPrompt(), (_DWORD)result) )
{
DestroyAllWindows();
exit(0);
}
return result;
}

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

if ( windowcount == 1 || (result = func0(), (_DWORD)result) )
{
DestroyAllWindows();
exit(0);
}
return result;
}

original_code:
void
QuitFunction()
{
    if ((windowcount == 1) || QuitAllPrompt()) {
        DestroyAllWindows();
        exit(0);
    }
}


printResultList

repo: jnoll/peos

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

v1 = a1;
if ( a1 )
{
do
{
puts(*(const char **)v1);
v1 = *(_QWORD *)(v1 + 8);
}
while ( v1 );
}
else
{
puts("result list is empty!");
}
return putchar(10);
}

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

v1 = a1;
if ( a1 )
{
do
{
puts(*(const char **)v1);
v1 = *(_QWORD *)(v1 + 8);
}
while ( v1 );
}
else
{
puts("result list is empty!");
}
return putchar(10);
}

original_code:
void printResultList( resultList *listpointer )
{
 if ( listpointer == ((void *)0) )
  printf ( "result list is empty!\n" ) ;
 else
 {
  resultList *temp = listpointer;
      while ( temp != ((void *)0) )
  {
   printf ( "%s\n", temp -> oneResult ) ;
   temp = ( resultList* ) temp -> link ;
  }
 }
 printf( "\n" );
}

canonical_original_code:
void printResultList(struct resultList *listpointer)
{
 if ( listpointer == ((void *)0) )
  printf ( "result list is empty!\n" ) ;
 else
 {
  struct resultList *temp = listpointer;
      while ( temp != ((void *)0) )
  {
   printf ( "%s\n", temp -> oneResult ) ;
   temp = ( struct resultList * ) temp -> link ;
  }
 }
 printf( "\n" );
}

variable_types: struct resultList { char *oneResult; struct resultList *link; } *


removeResultItem

decompiled_code:
__int64 __fastcall removeResultItem(_QWORD *a1)
{
__int64 v1; // rbx

v1 = a1[1];
free(a1);
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func1(_QWORD *a1)
{
__int64 v1; // rbx

v1 = a1[1];
free(a1);
return v1;
}

original_code:
resultList* removeResultItem( resultList *listpointer )
{
 resultList *temp ;
 temp = ( resultList* ) listpointer -> link ;
 free( listpointer ) ;
 return temp ;
}

canonical_original_code:
struct resultList *removeResultItem(struct resultList *listpointer)
{
 struct resultList *temp;
 temp = ( struct resultList * ) listpointer -> link ;
 free( listpointer ) ;
 return temp ;
}

variable_types:
listpointer
struct resultList *

return_type: struct resultList { char *oneResult; struct resultList *link; } *


clearResultList

decompiled_code:
void __fastcall clearResultList(_QWORD *a1)
{
for ( ; a1; a1 = (_QWORD *)removeResultItem(a1) )
;
}

canonical_decompiled_code:
void __fastcall func2(_QWORD *a1)
{
for ( ; a1; a1 = (_QWORD *)func1(a1) )
;
}

original_code:
void clearResultList( resultList *listpointer )
{
 while ( listpointer != ((void *)0) )
  listpointer = ( resultList* ) removeResultItem( listpointer ) ;
}

canonical_original_code:
void clearResultList(struct resultList *listpointer)
{
 while ( listpointer != ((void *)0) )
  listpointer = ( struct resultList * ) removeResultItem( listpointer ) ;
}

user_defined_types: struct resultList { char *oneResult; struct resultList *link; }


getFile

decompiled_code:
__int64 __fastcall getFile(const char *filename, const struct stat *status, int flag)
{
char *v4; // rbp
char v5[984]; // [rsp+10h] [rbp-7E8h] BYREF
__int64 v6; // [rsp+3F0h] [rbp-408h]
__int64 v7; // [rsp+3F8h] [rbp-400h]
char v8[984]; // [rsp+400h] [rbp-3F8h] BYREF

v6 = 0LL;
v7 = 0LL;
memset(v8, 0, sizeof(v8));
memset(v5, 0, sizeof(v5));
if ( !flag )
{
v4 = strrchr(filename, 47);
assert("FSseeker.c", 225LL, v4);
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *filename, const struct stat *status, int flag)
{
char *v4; // rbp
char v5[984]; // [rsp+10h] [rbp-7E8h] BYREF
__int64 v6; // [rsp+3F0h] [rbp-408h]
__int64 v7; // [rsp+3F8h] [rbp-400h]
char v8[984]; // [rsp+400h] [rbp-3F8h] BYREF

v6 = 0LL;
v7 = 0LL;
memset(v8, 0, sizeof(v8));
memset(v5, 0, sizeof(v5));
if ( !flag )
{
v4 = strrchr(filename, 47);
assert("FSseeker.c", 225LL, v4);
}
return 0LL;
}

original_code:
int getFile( const char *filename, const struct stat *statptr, int flag )
{
 char *position ;
 char target[1000] = { '\0' } ;
 char theFileName[1000] = { '\0' } ;
 int index = 0 ;
 switch ( flag )
 {
  case FTW_F : position = strrchr(filename, '/' ) ;
           _assert( "FSseeker.c", 225, position ) ;
    index = filename - position;
    if( index < 0 )
     index *= -1;
        strcpy( target, filename + index + 1 ) ;
        strcat( theFileName, "file://" ) ;
        if( strcmp( operatorType, "~" ) == 0 )
        {
         if( strstr( target, queryName ) != ((void *)0) )
     {
      strcat( theFileName, filename ) ;
      nameResults = addResultItem ( nameResults, theFileName );
     }
    }
    else if( strcmp( operatorType, "EQ" ) == 0 )
    {
     if( strcmp( target, queryName ) == 0 )
     {
      strcat( theFileName, filename ) ;
      nameResults = addResultItem ( nameResults, theFileName );
     }
    }
    break ;
 }
 return 0 ;
}

canonical_original_code:
int getFile(char *filename, struct stat *statptr, int flag)
{
 char *position;
 char target[1000] = { '\0' };
 char theFileName[1000] = { '\0' };
 int index = 0;
 switch ( flag )
 {
  case FTW_F : position = strrchr(filename, '/' ) ;
           _assert( "FSseeker.c", 225, position ) ;
    index = filename - position;
    if( index < 0 )
     index *= -1;
        strcpy( target, filename + index + 1 ) ;
        strcat( theFileName, "file://" ) ;
        if( strcmp( operatorType, "~" ) == 0 )
        {
         if( strstr( target, queryName ) != ((void *)0) )
     {
      strcat( theFileName, filename ) ;
      nameResults = addResultItem ( nameResults, theFileName );
     }
    }
    else if( strcmp( operatorType, "EQ" ) == 0 )
    {
     if( strcmp( target, queryName ) == 0 )
     {
      strcat( theFileName, filename ) ;
      nameResults = addResultItem ( nameResults, theFileName );
     }
    }
    break ;
 }
 return 0 ;
}

variable_types:
filename
char *

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: flag int

variable_types:
position
char *

variable_types:
target
char [1000]

variable_types:
theFileName
char [1000]

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


convertMonth

original_code:
char* convertMonth( char *theMonth )
{
 if( strcmp( theMonth, "Jan" ) == 0 )
  return "01" ;
 else if( strcmp( theMonth, "Feb" ) == 0 )
  return "02" ;
 else if( strcmp( theMonth, "Mar" ) == 0 )
  return "03" ;
 else if( strcmp( theMonth, "Apr" ) == 0 )
  return "04" ;
 else if( strcmp( theMonth, "May" ) == 0 )
  return "05" ;
 else if( strcmp( theMonth, "Jun" ) == 0 )
  return "06" ;
 else if( strcmp( theMonth, "Jul" ) == 0 )
  return "07" ;
 else if( strcmp( theMonth, "Aug" ) == 0 )
  return "08" ;
 else if( strcmp( theMonth, "Sep" ) == 0 )
  return "09" ;
 else if( strcmp( theMonth, "Oct" ) == 0 )
  return "10" ;
 else if( strcmp( theMonth, "Nov" ) == 0 )
  return "11" ;
 else if( strcmp( theMonth, "Dec" ) == 0 )
  return "12" ;
 else
  return ((void *)0) ;
}

canonical_original_code:
char *convertMonth(char *theMonth)
{
 if( strcmp( theMonth, "Jan" ) == 0 )
  return "01" ;
 else if( strcmp( theMonth, "Feb" ) == 0 )
  return "02" ;
 else if( strcmp( theMonth, "Mar" ) == 0 )
  return "03" ;
 else if( strcmp( theMonth, "Apr" ) == 0 )
  return "04" ;
 else if( strcmp( theMonth, "May" ) == 0 )
  return "05" ;
 else if( strcmp( theMonth, "Jun" ) == 0 )
  return "06" ;
 else if( strcmp( theMonth, "Jul" ) == 0 )
  return "07" ;
 else if( strcmp( theMonth, "Aug" ) == 0 )
  return "08" ;
 else if( strcmp( theMonth, "Sep" ) == 0 )
  return "09" ;
 else if( strcmp( theMonth, "Oct" ) == 0 )
  return "10" ;
 else if( strcmp( theMonth, "Nov" ) == 0 )
  return "11" ;
 else if( strcmp( theMonth, "Dec" ) == 0 )
  return "12" ;
 else
  return ((void *)0) ;
}

variable_types:
theMonth
char *


getFileTimeStamp

decompiled_code:
void __fastcall getFileTimeStamp(char *s, char *a2)
{
char *v2; // rbp
char *v3; // r12
char *v4; // r13
char *v5; // r14
char *v7; // rax
int v8; // ebx
const char *v9; // rax
char *v10; // rdi

v7 = strtok(a2, "\n");
if ( v7 && strtok(v7, " ") )
{
v8 = 0;
while ( 1 )
{
++v8;
v10 = strtok(0LL, " ");
if ( !v10 )
break;
if ( v8 == 3 )
{
v4 = strdup(v10);
}
else if ( v8 > 3 )
{
if ( v8 == 4 )
v3 = strdup(v10);
}
else if ( v8 == 1 )
{
v9 = convertMonth(v10);
v5 = strdup(v9);
}
else if ( v8 == 2 )
{
v2 = strdup(v10);
}
}
}
if ( strlen(v2) == 1 )
sprintf(s, "%s/%s/0%s %s", v3, v5, v2, v4);
else
sprintf(s, "%s/%s/%s %s", v3, v5, v2, v4);
free(v5);
free(v2);
free(v4);
free(v3);
}

canonical_decompiled_code:
void __fastcall func4(char *s, char *a2)
{
char *v2; // rbp
char *v3; // r12
char *v4; // r13
char *v5; // r14
char *v7; // rax
int v8; // ebx
const char *v9; // rax
char *v10; // rdi

v7 = strtok(a2, "\n");
if ( v7 && strtok(v7, " ") )
{
v8 = 0;
while ( 1 )
{
++v8;
v10 = strtok(0LL, " ");
if ( !v10 )
break;
if ( v8 == 3 )
{
v4 = strdup(v10);
}
else if ( v8 > 3 )
{
if ( v8 == 4 )
v3 = strdup(v10);
}
else if ( v8 == 1 )
{
v9 = func3(v10);
v5 = strdup(v9);
}
else if ( v8 == 2 )
{
v2 = strdup(v10);
}
}
}
if ( strlen(v2) == 1 )
sprintf(s, "%s/%s/0%s %s", v3, v5, v2, v4);
else
sprintf(s, "%s/%s/%s %s", v3, v5, v2, v4);
free(v5);
free(v2);
free(v4);
free(v3);
}

original_code:
void getFileTimeStamp( char *newFileTime, char *oldFileTime )
{
 char* convertMonth( char * ) ;
 char *word, *toParse, *year, *month, *day, *time ;
 int numParses ;
 numParses = 0 ;
 word = toParse = ((void *)0) ;
 toParse = strtok( oldFileTime, "\n" ) ;
 if( toParse != ((void *)0) )
  word = strtok( toParse, " " ) ;
 while( word != ((void *)0) )
 {
  switch( numParses )
  {
   case 1 : month = strdup( convertMonth ( word ) ) ;
     break ;
   case 2 : day = strdup( word ) ;
     break ;
   case 3 : time = strdup( word ) ;
     break ;
   case 4 : year = strdup( word ) ;
     break ;
  }
  numParses++ ;
  word = strtok( ((void *)0), " " ) ;
 }
 if( strlen( day ) == 1 )
  sprintf( newFileTime,"%s/%s/0%s %s", year, month, day, time ) ;
 else
  sprintf( newFileTime,"%s/%s/%s %s", year, month, day, time ) ;
 free( month ) ;
 free( day ) ;
 free( time ) ;
 free( year ) ;
}

canonical_original_code:
void getFileTimeStamp(char *newFileTime, char *oldFileTime)
{
 char *convertMonth(char *);
 char *word; char *toParse; char *year; char *month; char *day; char *time;
 int numParses;
 numParses = 0 ;
 word = toParse = ((void *)0) ;
 toParse = strtok( oldFileTime, "\n" ) ;
 if( toParse != ((void *)0) )
  word = strtok( toParse, " " ) ;
 while( word != ((void *)0) )
 {
  switch( numParses )
  {
   case 1 : month = strdup( convertMonth ( word ) ) ;
     break ;
   case 2 : day = strdup( word ) ;
     break ;
   case 3 : time = strdup( word ) ;
     break ;
   case 4 : year = strdup( word ) ;
     break ;
  }
  numParses++ ;
  word = strtok( ((void *)0), " " ) ;
 }
 if( strlen( day ) == 1 )
  sprintf( newFileTime,"%s/%s/0%s %s", year, month, day, time ) ;
 else
  sprintf( newFileTime,"%s/%s/%s %s", year, month, day, time ) ;
 free( month ) ;
 free( day ) ;
 free( time ) ;
 free( year ) ;
}

variable_types:
newFileTime
char *

variable_types:
oldFileTime
char *

variable_types:
convertMonth
char *(char *)

variable_types:
word
char *

variable_types:
toParse
char *

variable_types:
year
char *

variable_types:
month
char *

variable_types:
day
char *

variable_types:
time
char *

variable_types: numParses int


getDate

decompiled_code:
__int64 __fastcall getDate(const char *filename, const struct stat *status, int flag)
{
char *v4; // rax
time_t v5; // rbp
double v6; // xmm0_8
double v7; // xmm0_8
__int64 v8[2]; // [rsp+0h] [rbp-428h] BYREF
int v9; // [rsp+10h] [rbp-418h]
char s[8]; // [rsp+20h] [rbp-408h] BYREF
__int64 v11; // [rsp+28h] [rbp-400h]
char v12[984]; // [rsp+30h] [rbp-3F8h] BYREF

*(_QWORD *)s = 0LL;
v11 = 0LL;
memset(v12, 0, sizeof(v12));
v8[0] = 0LL;
v8[1] = 0LL;
v9 = 0;
if ( !flag )
{
v4 = ctime(&status->st_mtim.tv_sec);
getFileTimeStamp((char *)v8, v4);
v5 = (int)parsedate(v8, 0LL);
*(_QWORD *)&s[strlen(s)] = 0x2F2F3A656C6966LL;
if ( !strcmp(operatorType, "EQ") )
{
if ( difftime(v5, fileQueryTime) != 0.0 )
return 0LL;
}
else if ( !strcmp(operatorType, "LT") )
{
if ( difftime(v5, fileQueryTime) >= 0.0 )
return 0LL;
}
else if ( !strcmp(operatorType, "LE") )
{
v6 = difftime(v5, fileQueryTime);
if ( v6 != 0.0 && v6 >= 0.0 )
return 0LL;
}
else if ( !strcmp(operatorType, "GT") )
{
if ( difftime(v5, fileQueryTime) <= 0.0 )
return 0LL;
}
else
{
if ( strcmp(operatorType, "GE") )
return 0LL;
v7 = difftime(v5, fileQueryTime);
if ( v7 != 0.0 && v7 <= 0.0 )
return 0LL;
}
strcat(s, filename);
dateResults = addResultItem(dateResults, s);
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(const char *filename, const struct stat *status, int flag)
{
char *v4; // rax
time_t v5; // rbp
double v6; // xmm0_8
double v7; // xmm0_8
__int64 v8[2]; // [rsp+0h] [rbp-428h] BYREF
int v9; // [rsp+10h] [rbp-418h]
char s[8]; // [rsp+20h] [rbp-408h] BYREF
__int64 v11; // [rsp+28h] [rbp-400h]
char v12[984]; // [rsp+30h] [rbp-3F8h] BYREF

*(_QWORD *)s = 0LL;
v11 = 0LL;
memset(v12, 0, sizeof(v12));
v8[0] = 0LL;
v8[1] = 0LL;
v9 = 0;
if ( !flag )
{
v4 = ctime(&status->st_mtim.tv_sec);
func4((char *)v8, v4);
v5 = (int)parsedate(v8, 0LL);
*(_QWORD *)&s[strlen(s)] = 0x2F2F3A656C6966LL;
if ( !strcmp(operatorType, "EQ") )
{
if ( difftime(v5, fileQueryTime) != 0.0 )
return 0LL;
}
else if ( !strcmp(operatorType, "LT") )
{
if ( difftime(v5, fileQueryTime) >= 0.0 )
return 0LL;
}
else if ( !strcmp(operatorType, "LE") )
{
v6 = difftime(v5, fileQueryTime);
if ( v6 != 0.0 && v6 >= 0.0 )
return 0LL;
}
else if ( !strcmp(operatorType, "GT") )
{
if ( difftime(v5, fileQueryTime) <= 0.0 )
return 0LL;
}
else
{
if ( strcmp(operatorType, "GE") )
return 0LL;
v7 = difftime(v5, fileQueryTime);
if ( v7 != 0.0 && v7 <= 0.0 )
return 0LL;
}
strcat(s, filename);
dateResults = addResultItem(dateResults, s);
}
return 0LL;
}

original_code:
int getDate( const char *filename, const struct stat *statptr, int flag )
{
 void getFileTimeStamp( char * , char * ) ;
 char theFileName[1000] = { '\0' } ;
 char fileDate[20] = { '\0' } ;
 time_t fileDateTime ;
 switch ( flag )
 {
  case FTW_F : getFileTimeStamp( fileDate, ctime( &statptr -> st_mtim.tv_sec ) ) ;
    fileDateTime = parsedate( fileDate, ((void *)0) ) ;
    strcat( theFileName, "file://" ) ;
    if( strcmp( operatorType, "EQ" ) == 0 )
        {
     if( difftime( fileDateTime, fileQueryTime ) == 0 )
     {
      strcat( theFileName, filename ) ;
      dateResults = addResultItem( dateResults, theFileName ) ;
     }
    }
    else if( strcmp( operatorType, "LT" ) == 0 )
    {
     if( difftime( fileDateTime, fileQueryTime ) < 0 )
     {
      strcat( theFileName, filename ) ;
      dateResults = addResultItem( dateResults, theFileName ) ;
     }
    }
    else if( strcmp( operatorType, "LE" ) == 0 )
    {
     if( ( difftime( fileDateTime, fileQueryTime ) == 0 ) ||
         ( difftime( fileDateTime, fileQueryTime ) < 0 ) )
     {
      strcat( theFileName, filename ) ;
      dateResults = addResultItem( dateResults, theFileName ) ;
     }
    }
    else if( strcmp( operatorType, "GT" ) == 0 )
    {
     if( difftime( fileDateTime, fileQueryTime ) > 0 )
     {
      strcat( theFileName, filename ) ;
      dateResults = addResultItem( dateResults, theFileName ) ;
     }
    }
    else if( strcmp( operatorType, "GE" ) == 0 )
    {
     if( ( difftime( fileDateTime, fileQueryTime ) == 0 ) ||
         ( difftime( fileDateTime, fileQueryTime ) > 0 ) )
     {
      strcat( theFileName, filename ) ;
      dateResults = addResultItem( dateResults, theFileName ) ;
     }
    }
    break ;
 }
 return 0 ;
}

canonical_original_code:
int getDate(char *filename, struct stat *statptr, int flag)
{
 void getFileTimeStamp(char *, char *);
 char theFileName[1000] = { '\0' };
 char fileDate[20] = { '\0' };
 long fileDateTime;
 switch ( flag )
 {
  case FTW_F : getFileTimeStamp( fileDate, ctime( &statptr -> st_mtim.tv_sec ) ) ;
    fileDateTime = parsedate( fileDate, ((void *)0) ) ;
    strcat( theFileName, "file://" ) ;
    if( strcmp( operatorType, "EQ" ) == 0 )
        {
     if( difftime( fileDateTime, fileQueryTime ) == 0 )
     {
      strcat( theFileName, filename ) ;
      dateResults = addResultItem( dateResults, theFileName ) ;
     }
    }
    else if( strcmp( operatorType, "LT" ) == 0 )
    {
     if( difftime( fileDateTime, fileQueryTime ) < 0 )
     {
      strcat( theFileName, filename ) ;
      dateResults = addResultItem( dateResults, theFileName ) ;
     }
    }
    else if( strcmp( operatorType, "LE" ) == 0 )
    {
     if( ( difftime( fileDateTime, fileQueryTime ) == 0 ) ||
         ( difftime( fileDateTime, fileQueryTime ) < 0 ) )
     {
      strcat( theFileName, filename ) ;
      dateResults = addResultItem( dateResults, theFileName ) ;
     }
    }
    else if( strcmp( operatorType, "GT" ) == 0 )
    {
     if( difftime( fileDateTime, fileQueryTime ) > 0 )
     {
      strcat( theFileName, filename ) ;
      dateResults = addResultItem( dateResults, theFileName ) ;
     }
    }
    else if( strcmp( operatorType, "GE" ) == 0 )
    {
     if( ( difftime( fileDateTime, fileQueryTime ) == 0 ) ||
         ( difftime( fileDateTime, fileQueryTime ) > 0 ) )
     {
      strcat( theFileName, filename ) ;
      dateResults = addResultItem( dateResults, theFileName ) ;
     }
    }
    break ;
 }
 return 0 ;
}

variable_types:
filename
char *

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:
getFileTimeStamp
void (char *, char *)

variable_types:
fileDate
char [20]

variable_types: fileDateTime long


isFileQuery

decompiled_code:
void __fastcall __noreturn isFileQuery(char *src)
{
char *v1; // rax

strcpy(searchFile, src);
v1 = strtok(searchFile, ":");
assert("FSseeker.c", 428LL, v1);
}

canonical_decompiled_code:
void __fastcall __noreturn func6(char *src)
{
char *v1; // rax

strcpy(searchFile, src);
v1 = strtok(searchFile, ":");
assert("FSseeker.c", 428LL, v1);
}

original_code:
int isFileQuery( char *value )
{
 char *repository ;
 strcpy( searchFile, value ) ;
 repository = strtok( searchFile , ":" ) ;
 _assert( "FSseeker.c", 428, repository ) ;
 if( ( strcmp( "file", repository ) == 0 ) )
  return 1 ;
 else
  return 0 ;
}

canonical_original_code:
int isFileQuery(char *value)
{
 char *repository;
 strcpy( searchFile, value ) ;
 repository = strtok( searchFile , ":" ) ;
 _assert( "FSseeker.c", 428, repository ) ;
 if( ( strcmp( "file", repository ) == 0 ) )
  return 1 ;
 else
  return 0 ;
}

variable_types:
value
char *

variable_types:
repository
char *


FSqueryValidator

decompiled_code:
__int64 __fastcall FSqueryValidator(__int64 a1)
{
__int64 v1; // rax
unsigned int v2; // ecx
char v3; // dl
char v5; // [rsp+1h] [rbp-3F9h]
__int64 v6[2]; // [rsp+2h] [rbp-3F8h] BYREF
char v7[984]; // [rsp+12h] [rbp-3E8h] BYREF

v6[0] = 0LL;
v6[1] = 0LL;
memset(v7, 0, sizeof(v7));
strcpy((char *)v6, (const char *)(a1 + 5));
if ( BYTE1(v6[0]) != 47 )
return 0;
v1 = 2LL;
do
{
v2 = v1++;
v3 = *(&v5 + v1);
}
while ( v3 == 47 );
if ( v2 == 2 )
{
if ( !v3 )
v2 = 0;
}
else if ( v2 == 3 )
{
if ( !v3 )
v2 = 0;
}
else
{
v2 = 0;
}
return v2;
}

original_code:
int FSqueryValidator( char *value )
{
 char testValue[1000] = {'\0'} ;
 int numslash = 1 ;
 int slashResult = 0 ;
 strcpy( testValue, value + 5 ) ;
 while( strncmp( testValue + numslash, "/", 1 ) == 0 )
  numslash++ ;
 switch( numslash )
 {
  case 2: if( strlen( testValue + numslash ) )
     slashResult = 2 ;
    else
     slashResult = 0 ;
    break ;
  case 3: if( strlen( testValue + numslash ) )
     slashResult = 3 ;
    else
     slashResult = 0 ;
    break ;
  default: slashResult = 0 ;
    break ;
 }
 return slashResult ;
}

canonical_original_code:
int FSqueryValidator(char *value)
{
 char testValue[1000] = {'\0'};
 int numslash = 1;
 int slashResult = 0;
 strcpy( testValue, value + 5 ) ;
 while( strncmp( testValue + numslash, "/", 1 ) == 0 )
  numslash++ ;
 switch( numslash )
 {
  case 2: if( strlen( testValue + numslash ) )
     slashResult = 2 ;
    else
     slashResult = 0 ;
    break ;
  case 3: if( strlen( testValue + numslash ) )
     slashResult = 3 ;
    else
     slashResult = 0 ;
    break ;
  default: slashResult = 0 ;
    break ;
 }
 return slashResult ;
}

variable_types:
testValue
char [1000]

variable_types: numslash int

variable_types: slashResult int


attributeID

decompiled_code:
void __fastcall __noreturn attributeID(__int64 a1, int a2)
{
isFileQuery(*(char **)(a1 + 32LL * a2 + 40));
}

canonical_decompiled_code:
void __fastcall __noreturn func8(__int64 a1, int a2)
{
func6(*(char **)(a1 + 32LL * a2 + 40));
}

original_code:
resultList* attributeID( query *oneQuery, int numClauses )
{
 int isFileQuery( char * ) ;
 struct stat statBuffer ;
 resultList *resultID = ((void *)0) ;
 if( isFileQuery( oneQuery -> myClauses[numClauses].value ) )
 {
  char tempPath[1000] = {'\0'} ;
  char resultPath[1000] = {'\0'} ;
  int numslash = 0 ;
  numslash = FSqueryValidator( oneQuery -> myClauses[numClauses].value ) ;
  strcpy( searchFile, ( oneQuery -> myClauses[numClauses].value ) + 5 ) ;
  switch( numslash )
  {
   case 2: strcpy( tempPath, directoryPath ) ;
     strcat( tempPath, searchFile + 1 ) ;
     if( strlen( tempPath ) > ( strlen( directoryPath ) + 1 ) )
      if( stat( tempPath, &statBuffer ) == 0 )
      {
       sprintf( resultPath, "file://%s", tempPath ) ;
       resultID = addResultItem( resultID, resultPath ) ;
      }
     break ;
     case 3: if( strlen( searchFile ) > 3 )
      if( stat( searchFile + 2, &statBuffer ) == 0 )
       resultID = addResultItem( resultID, oneQuery -> myClauses[numClauses].value ) ;
     break ;
   default: oneQuery -> removeTag = 1 ;
  }
 }
 return resultID ;
}

canonical_original_code:
struct resultList *attributeID(struct query *oneQuery, int numClauses)
{
 int isFileQuery(char *);
 struct stat statBuffer;
 struct resultList *resultID = ((void *)0);
 if( isFileQuery( oneQuery -> myClauses[numClauses].value ) )
 {
  char tempPath[1000] = {'\0'};
  char resultPath[1000] = {'\0'};
  int numslash = 0;
  numslash = FSqueryValidator( oneQuery -> myClauses[numClauses].value ) ;
  strcpy( searchFile, ( oneQuery -> myClauses[numClauses].value ) + 5 ) ;
  switch( numslash )
  {
   case 2: strcpy( tempPath, directoryPath ) ;
     strcat( tempPath, searchFile + 1 ) ;
     if( strlen( tempPath ) > ( strlen( directoryPath ) + 1 ) )
      if( stat( tempPath, &statBuffer ) == 0 )
      {
       sprintf( resultPath, "file://%s", tempPath ) ;
       resultID = addResultItem( resultID, resultPath ) ;
      }
     break ;
     case 3: if( strlen( searchFile ) > 3 )
      if( stat( searchFile + 2, &statBuffer ) == 0 )
       resultID = addResultItem( resultID, oneQuery -> myClauses[numClauses].value ) ;
     break ;
   default: oneQuery -> removeTag = 1 ;
  }
 }
 return resultID ;
}

variable_types: struct query { int removeTag; int numClauses; int *data; int numFound; struct clause { char *attribute; char *operator; char *value; char *conjecture; } myClauses[10]; struct resultList *results; void (*callback)(int, struct resultList *, void *data); } *

variable_types: numClauses int

variable_types:
isFileQuery
int (char *)

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: struct resultList { char *oneResult; struct resultList *link; } *

variable_types:
tempPath
char [1000]

variable_types:
resultPath
char [1000]

user_defined_types: struct query { int removeTag; int numClauses; int *data; int numFound; struct clause myClauses[10]; struct resultList *results; void (*callback)(int, struct resultList *, void *data); }


getDirectoryPath

decompiled_code:
void getDirectoryPath()
{
if ( !doneDirectoryPath )
{
if ( !getcwd(directoryPath, 0x3E8uLL) )
{
debug("FSseeker.c", 487LL, 0LL, "error getting directory path");
exit(0);
}
doneDirectoryPath = 1;
}
}

canonical_decompiled_code:
void func9()
{
if ( !doneDirectoryPath )
{
if ( !getcwd(directoryPath, 0x3E8uLL) )
{
debug("FSseeker.c", 487LL, 0LL, "error getting directory path");
exit(0);
}
doneDirectoryPath = 1;
}
}

original_code:
void getDirectoryPath( )
{
   if( !doneDirectoryPath )
   {
    if ( getcwd( directoryPath, 1000 ) == ((void *)0) )
  {
   _debug( "FSseeker.c", 487, 0, "error getting directory path" ) ;
   exit( 0 ) ;
  }
  else
   doneDirectoryPath = 1 ;
   }
}

canonical_original_code:
void getDirectoryPath()
{
   if( !doneDirectoryPath )
   {
    if ( getcwd( directoryPath, 1000 ) == ((void *)0) )
  {
   _debug( "FSseeker.c", 487, 0, "error getting directory path" ) ;
   exit( 0 ) ;
  }
  else
   doneDirectoryPath = 1 ;
   }
}


printQueryList

decompiled_code:
int __fastcall printQueryList(_QWORD *a1)
{
_QWORD *v1; // r12
int v3; // ebp
__int64 v4; // rdx
__int64 v5; // rbx
const char *v6; // rsi

v1 = a1;
if ( a1 )
{
do
{
printf("\nquery is");
v4 = *v1;
if ( *(int *)(*v1 + 4LL) >= 0 )
{
v3 = 0;
do
{
v5 = 32 * (v3 + 1LL);
printf(
" %s %s %s",
*(const char **)(v4 + 32LL * v3 + 24),
*(const char **)(v4 + 32LL * v3 + 32),
*(const char **)(v4 + v5 + 8));
v6 = *(const char **)(*v1 + v5 + 16);
if ( v6 )
printf(" %s", v6);
++v3;
v4 = *v1;
}
while ( *(_DWORD *)(*v1 + 4LL) >= v3 );
}
v1 = (_QWORD *)v1[1];
}
while ( v1 );
}
else
{
puts("\nqueue list is empty!");
}
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func0(_QWORD *a1)
{
_QWORD *v1; // r12
int v3; // ebp
__int64 v4; // rdx
__int64 v5; // rbx
const char *v6; // rsi

v1 = a1;
if ( a1 )
{
do
{
printf("\nquery is");
v4 = *v1;
if ( *(int *)(*v1 + 4LL) >= 0 )
{
v3 = 0;
do
{
v5 = 32 * (v3 + 1LL);
printf(
" %s %s %s",
*(const char **)(v4 + 32LL * v3 + 24),
*(const char **)(v4 + 32LL * v3 + 32),
*(const char **)(v4 + v5 + 8));
v6 = *(const char **)(*v1 + v5 + 16);
if ( v6 )
printf(" %s", v6);
++v3;
v4 = *v1;
}
while ( *(_DWORD *)(*v1 + 4LL) >= v3 );
}
v1 = (_QWORD *)v1[1];
}
while ( v1 );
}
else
{
puts("\nqueue list is empty!");
}
return putchar(10);
}

original_code:
void printQueryList( queryList *listpointer )
{
 if ( listpointer == ((void *)0) )
  printf ( "\nqueue list is empty!\n" ) ;
 else
 {
      while ( listpointer != ((void *)0) )
  {
   int i ;
   printf( "\nquery is" );
   for( i = 0; i <= listpointer -> oneQuery -> numClauses; i++ )
   {
    printf( " %s %s %s", listpointer -> oneQuery -> myClauses[i].attribute ,
           listpointer -> oneQuery -> myClauses[i].operator,
           listpointer -> oneQuery -> myClauses[i].value ) ;
    if( listpointer -> oneQuery -> myClauses[i].conjecture != ((void *)0) )
     printf( " %s", listpointer -> oneQuery -> myClauses[i].conjecture ) ;
   }
   listpointer = ( queryList* ) listpointer -> link ;
  }
 }
 printf ( "\n" ) ;
}

canonical_original_code:
void printQueryList(struct queryList *listpointer)
{
 if ( listpointer == ((void *)0) )
  printf ( "\nqueue list is empty!\n" ) ;
 else
 {
      while ( listpointer != ((void *)0) )
  {
   int i;
   printf( "\nquery is" );
   for( i = 0; i <= listpointer -> oneQuery -> numClauses; i++ )
   {
    printf( " %s %s %s", listpointer -> oneQuery -> myClauses[i].attribute ,
           listpointer -> oneQuery -> myClauses[i].operator,
           listpointer -> oneQuery -> myClauses[i].value ) ;
    if( listpointer -> oneQuery -> myClauses[i].conjecture != ((void *)0) )
     printf( " %s", listpointer -> oneQuery -> myClauses[i].conjecture ) ;
   }
   listpointer = ( struct queryList * ) listpointer -> link ;
  }
 }
 printf ( "\n" ) ;
}

variable_types: struct queryList { struct query { int removeTag; int numClauses; int *data; int numFound; struct clause { char *attribute; char *operator; char *value; char *conjecture; } myClauses[10]; struct resultList { char *oneResult; struct resultList *link; } *results; void (*callback)(int, struct resultList *, void *data); } *oneQuery; struct queryList *link; } *

variable_types: i int

user_defined_types: struct queryList { struct query *oneQuery; struct queryList *link; }


filterQueryList

original_code:
queryList *filterQueryList( queryList *listpointer )
{
 queryList *previous, *current, *temp ;
 previous = current = listpointer ;
 while( current != ((void *)0) )
 {
  if( current -> oneQuery -> removeTag )
   if( current == listpointer )
   {
    int numClauses ;
    listpointer = ( queryList * ) listpointer -> link ;
    for( numClauses = 0 ; numClauses <= current -> oneQuery -> numClauses ; numClauses++ )
    {
     free( current -> oneQuery -> myClauses[numClauses].attribute ) ;
     free( current -> oneQuery -> myClauses[numClauses].operator ) ;
     free( current -> oneQuery -> myClauses[numClauses].value ) ;
    }
    clearResultList( current -> oneQuery -> results ) ;
    free( current -> oneQuery ) ;
    free( current ) ;
    previous = current = listpointer ;
   }
   else
   {
    int numClauses ;
    previous -> link = current -> link ;
    for( numClauses = 0 ; numClauses <= current -> oneQuery -> numClauses ; numClauses++ )
    {
     free( current -> oneQuery -> myClauses[numClauses].attribute ) ;
     free( current -> oneQuery -> myClauses[numClauses].operator ) ;
     free( current -> oneQuery -> myClauses[numClauses].value ) ;
    }
    clearResultList( current -> oneQuery -> results ) ;
    free( current -> oneQuery ) ;
    free( current ) ;
    current = ( queryList * ) previous -> link ;
   }
  else
  {
   previous = current ;
   current = ( queryList * ) current -> link ;
  }
 }
 return listpointer ;
}

canonical_original_code:
struct queryList *filterQueryList(struct queryList *listpointer)
{
 struct queryList *previous; struct queryList *current; struct queryList *temp;
 previous = current = listpointer ;
 while( current != ((void *)0) )
 {
  if( current -> oneQuery -> removeTag )
   if( current == listpointer )
   {
    int numClauses;
    listpointer = ( struct queryList * ) listpointer -> link ;
    for( numClauses = 0 ; numClauses <= current -> oneQuery -> numClauses ; numClauses++ )
    {
     free( current -> oneQuery -> myClauses[numClauses].attribute ) ;
     free( current -> oneQuery -> myClauses[numClauses].operator ) ;
     free( current -> oneQuery -> myClauses[numClauses].value ) ;
    }
    clearResultList( current -> oneQuery -> results ) ;
    free( current -> oneQuery ) ;
    free( current ) ;
    previous = current = listpointer ;
   }
   else
   {
    int numClauses;
    previous -> link = current -> link ;
    for( numClauses = 0 ; numClauses <= current -> oneQuery -> numClauses ; numClauses++ )
    {
     free( current -> oneQuery -> myClauses[numClauses].attribute ) ;
     free( current -> oneQuery -> myClauses[numClauses].operator ) ;
     free( current -> oneQuery -> myClauses[numClauses].value ) ;
    }
    clearResultList( current -> oneQuery -> results ) ;
    free( current -> oneQuery ) ;
    free( current ) ;
    current = ( struct queryList * ) previous -> link ;
   }
  else
  {
   previous = current ;
   current = ( struct queryList * ) current -> link ;
  }
 }
 return listpointer ;
}

variable_types:
listpointer
struct queryList *

return_type: struct queryList { struct query { int removeTag; int numClauses; int *data; int numFound; struct clause { char *attribute; char *operator; char *value; char *conjecture; } myClauses[10]; struct resultList { char *oneResult; struct resultList *link; } *results; void (*callback)(int, struct resultList *, void *data); } *oneQuery; struct queryList *link; } *


decompiled_code:
__int64 repository_init()
{
rep_list = 0LL;
rep_listnext = 0LL;
nr_repositories = 0;
UnixfsInit();
pmlstate_init();
return 0LL;
}

canonical_decompiled_code:
__int64 func0()
{
rep_list = 0LL;
rep_listnext = 0LL;
nr_repositories = 0;
UnixfsInit();
pmlstate_init();
return 0LL;
}

original_code:
int repository_init()
{
  rep_list = ((void *)0);
  rep_listnext = ((void *)0);
  nr_repositories = 0;
  UnixfsInit();
  pmlstate_init();
  return (int)0;
}


decompiled_code:
_DWORD *repository_openquery()
{
_DWORD *result; // rax

result = malloc(0x20uLL);
if ( result )
{
result[6] = 0;
*(_QWORD *)result = 0LL;
*((_QWORD *)result + 1) = 0LL;
*((_QWORD *)result + 2) = 0LL;
}
return result;
}

canonical_decompiled_code:
_DWORD *func15()
{
_DWORD *result; // rax

result = malloc(0x20uLL);
if ( result )
{
result[6] = 0;
*(_QWORD *)result = 0LL;
*((_QWORD *)result + 1) = 0LL;
*((_QWORD *)result + 2) = 0LL;
}
return result;
}

original_code:
repository_queryresult* repository_openquery()
{
  repository_queryresult *result;
  result = (repository_queryresult *) malloc(sizeof(repository_queryresult));
  if (result == ((void *)0))
    return ((void *)0);
  result->entries = 0;
  result->start = ((void *)0);
  result->end = ((void *)0);
  result->pos = ((void *)0);
  return (repository_queryresult *)result;
}

canonical_original_code:
struct repository_queryresult *repository_openquery()
{
  struct repository_queryresult *result;
  result = (struct repository_queryresult *) malloc(sizeof(repository_queryresult));
  if (result == ((void *)0))
    return ((void *)0);
  result->entries = 0;
  result->start = ((void *)0);
  result->end = ((void *)0);
  result->pos = ((void *)0);
  return (struct repository_queryresult *)result;
}

variable_types: struct repository_queryresult { struct repository_querynode { struct repository_object { int type; char *id; void *object; } *entry; struct repository_querynode *next; } *start; struct repository_querynode *end; struct repository_querynode *pos; int entries; } *

user_defined_types: struct repository_queryresult { struct repository_querynode *start; struct repository_querynode *end; struct repository_querynode *pos; int entries; }

user_defined_types: struct repository_querynode { struct repository_object *entry; struct repository_querynode *next; }


decompiled_code:
__int64 pml_close_repository()
{
return pmlstate_close_repository();
}

canonical_decompiled_code:
__int64 func3()
{
return pmlstate_close_repository();
}

original_code:
int pml_close_repository(void)
{
  return (int)pmlstate_close_repository();
}

canonical_original_code:
int pml_close_repository()
{
  return (int)pmlstate_close_repository();
}


decompiled_code:
__int64 pml_create_object()
{
return pmlstate_create_object();
}

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

original_code:
pml_obj_t pml_create_object(void)
{
  return (pml_obj_t)pmlstate_create_object();
}

canonical_original_code:
struct pml_rec_t *pml_create_object()
{
  return (struct pml_rec_t *)pmlstate_create_object();
}

return_type: struct pml_rec_t { int deleted; unsigned int natr; long aofs[1024]; unsigned long alen[1024]; unsigned int nval; long vofs[1024]; unsigned long vlen[1024]; } *


decompiled_code:
__int64 pml_delete_object()
{
return pmlstate_delete_object();
}

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

original_code:
int pml_delete_object(pml_obj_t objp)
{
  return (int)pmlstate_delete_object(objp);
}

canonical_original_code:
int pml_delete_object(struct pml_rec_t *objp)
{
  return (int)pmlstate_delete_object(objp);
}

variable_types: struct pml_rec_t { int deleted; unsigned int natr; long aofs[1024]; unsigned long alen[1024]; unsigned int nval; long vofs[1024]; unsigned long vlen[1024]; } *


decompiled_code:
__int64 pml_pack_objects()
{
return pmlstate_pack_objects();
}

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

original_code:
int pml_pack_objects(void)
{
  return (int)pmlstate_pack_objects();
}

canonical_original_code:
int pml_pack_objects()
{
  return (int)pmlstate_pack_objects();
}


decompiled_code:
__int64 __fastcall pml_read_attribute(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
__int64 result; // rax

if ( a5 | a3 )
result = pmlstate_read_attribute();
else
result = UnixfsRead(a1, a2, 0LL, a4, 0LL);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
__int64 result; // rax

if ( a5 | a3 )
result = pmlstate_read_attribute();
else
result = UnixfsRead(a1, a2, 0LL, a4, 0LL);
return result;
}

original_code:
int pml_read_attribute(void* objptr, void* atrp, size_t alen, void* valp, size_t vlen)
{
 if ((alen == 0) && (vlen == 0))
      return (int)UnixfsRead(objptr, atrp, alen, valp, vlen);
        else
      return (int)pmlstate_read_attribute(objptr, atrp, alen,
valp, vlen);
}

canonical_original_code:
int pml_read_attribute(void *objptr, void *atrp, unsigned long alen, void *valp, unsigned long vlen)
{
 if ((alen == 0) && (vlen == 0))
      return (int)UnixfsRead(objptr, atrp, alen, valp, vlen);
        else
      return (int)pmlstate_read_attribute(objptr, atrp, alen,
valp, vlen);
}

variable_types:
objptr
void *

variable_types:
atrp
void *

variable_types:
alen
unsigned long

variable_types:
valp
void *

variable_types:
vlen
unsigned long


decompiled_code:
__int64 pml_write_attribute()
{
return pmlstate_write_attribute();
}

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

original_code:
int pml_write_attribute(pml_obj_t objp, void* atrp, size_t alen, void* valp, size_t vlen)
{
 return (int)pmlstate_write_attribute(objp, atrp, alen, valp,
vlen);
}

canonical_original_code:
int pml_write_attribute(struct pml_rec_t *objp, void *atrp, unsigned long alen, void *valp, unsigned long vlen)
{
 return (int)pmlstate_write_attribute(objp, atrp, alen, valp,
vlen);
}

user_defined_types: struct pml_rec_t { int deleted; unsigned int natr; long aofs[1024]; unsigned long alen[1024]; unsigned int nval; long vofs[1024]; unsigned long vlen[1024]; }


decompiled_code:
__int64 __fastcall pml_query_open(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6)
{
__int64 result; // rax

if ( a6 | a3 )
result = pmlstate_query_open();
else
result = UnixfsQueryOpen(a1, a2, 0LL, a4, a5, 0LL);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6)
{
__int64 result; // rax

if ( a6 | a3 )
result = pmlstate_query_open();
else
result = UnixfsQueryOpen(a1, a2, 0LL, a4, a5, 0LL);
return result;
}

original_code:
int pml_query_open(void* ** objptr, void* atrp, size_t alen, int op, void* valp, size_t vlen)
{
 if ((alen == 0) && (vlen == 0))
         return (int)UnixfsQueryOpen(objptr, atrp, alen,
op, valp, vlen);
        else
                return (int)pmlstate_query_open(objptr, atrp, alen,
op, valp, vlen);
}

canonical_original_code:
int pml_query_open(void ***objptr, void *atrp, unsigned long alen, int op, void *valp, unsigned long vlen)
{
 if ((alen == 0) && (vlen == 0))
         return (int)UnixfsQueryOpen(objptr, atrp, alen,
op, valp, vlen);
        else
                return (int)pmlstate_query_open(objptr, atrp, alen,
op, valp, vlen);
}

variable_types:
objptr
void ***

variable_types: op int


decompiled_code:
__int64 pml_query_close()
{
return pmlstate_query_close();
}

canonical_decompiled_code:
__int64 func13()
{
return pmlstate_query_close();
}

original_code:
int pml_query_close(void* ** objptr)
{
  return (int)pmlstate_query_close(objptr);
}

canonical_original_code:
int pml_query_close(void ***objptr)
{
  return (int)pmlstate_query_close(objptr);
}


insertSortResultItem

decompiled_code:
__int64 __fastcall insertSortResultItem(const char **a1, const char *a2)
{
const char **v2; // rbx
__int64 v3; // rbp
__int64 v4; // rdi
__int64 v5; // rax

if ( !a1 )
return addResultItem(0LL);
v2 = a1;
v3 = 0LL;
if ( strcmp(a2, *a1) > 0 )
{
while ( strcmp(a2, *v2) >= 0 )
{
v5 = addResultItem(v3);
v3 = v5;
v2 = (const char **)v2[1];
if ( !v2 )
return addResultItem(v5);
}
v4 = addResultItem(v3);
do
{
v4 = addResultItem(v4);
v2 = (const char **)v2[1];
}
while ( v2 );
}
else
{
v4 = addResultItem(0LL);
do
{
v4 = addResultItem(v4);
v2 = (const char **)v2[1];
}
while ( v2 );
}
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char **a1, const char *a2)
{
const char **v2; // rbx
__int64 v3; // rbp
__int64 v4; // rdi
__int64 v5; // rax

if ( !a1 )
return addResultItem(0LL);
v2 = a1;
v3 = 0LL;
if ( strcmp(a2, *a1) > 0 )
{
while ( strcmp(a2, *v2) >= 0 )
{
v5 = addResultItem(v3);
v3 = v5;
v2 = (const char **)v2[1];
if ( !v2 )
return addResultItem(v5);
}
v4 = addResultItem(v3);
do
{
v4 = addResultItem(v4);
v2 = (const char **)v2[1];
}
while ( v2 );
}
else
{
v4 = addResultItem(0LL);
do
{
v4 = addResultItem(v4);
v2 = (const char **)v2[1];
}
while ( v2 );
}
return v4;
}

original_code:
resultList* insertSortResultItem( resultList* unSortedResults, char *data )
{
 resultList *unInsertedResults = ((void *)0) ;
 resultList *insertedResults = ((void *)0) ;
 int placed = 0 ;
 unInsertedResults = unSortedResults ;
 if( unInsertedResults == ((void *)0) )
  insertedResults = addResultItem( insertedResults, data ) ;
 else
 {
  if( strcmp( data, unInsertedResults -> oneResult ) <= 0 )
  {
   insertedResults = addResultItem( insertedResults, data ) ;
   while ( unInsertedResults != ((void *)0) )
   {
    insertedResults = addResultItem( insertedResults, unInsertedResults -> oneResult ) ;
    unInsertedResults = ( resultList* ) unInsertedResults -> link ;
   }
   placed = 1 ;
  }
  while ( unInsertedResults != ((void *)0) && !placed )
  {
   if( strcmp( data, unInsertedResults -> oneResult ) >= 0 )
   {
    insertedResults = addResultItem( insertedResults, unInsertedResults -> oneResult ) ;
    unInsertedResults = ( resultList* ) unInsertedResults -> link ;
   }
   else
   {
    insertedResults = addResultItem( insertedResults, data ) ;
    while ( unInsertedResults != ((void *)0) )
    {
     insertedResults = addResultItem( insertedResults, unInsertedResults -> oneResult ) ;
     unInsertedResults = ( resultList* ) unInsertedResults -> link ;
    }
    placed = 1 ;
   }
  }
  if( !placed )
   insertedResults = addResultItem( insertedResults, data ) ;
 }
 return insertedResults ;
}

canonical_original_code:
struct resultList *insertSortResultItem(struct resultList *unSortedResults, char *data)
{
 struct resultList *unInsertedResults = ((void *)0);
 struct resultList *insertedResults = ((void *)0);
 int placed = 0;
 unInsertedResults = unSortedResults ;
 if( unInsertedResults == ((void *)0) )
  insertedResults = addResultItem( insertedResults, data ) ;
 else
 {
  if( strcmp( data, unInsertedResults -> oneResult ) <= 0 )
  {
   insertedResults = addResultItem( insertedResults, data ) ;
   while ( unInsertedResults != ((void *)0) )
   {
    insertedResults = addResultItem( insertedResults, unInsertedResults -> oneResult ) ;
    unInsertedResults = ( struct resultList * ) unInsertedResults -> link ;
   }
   placed = 1 ;
  }
  while ( unInsertedResults != ((void *)0) && !placed )
  {
   if( strcmp( data, unInsertedResults -> oneResult ) >= 0 )
   {
    insertedResults = addResultItem( insertedResults, unInsertedResults -> oneResult ) ;
    unInsertedResults = ( struct resultList * ) unInsertedResults -> link ;
   }
   else
   {
    insertedResults = addResultItem( insertedResults, data ) ;
    while ( unInsertedResults != ((void *)0) )
    {
     insertedResults = addResultItem( insertedResults, unInsertedResults -> oneResult ) ;
     unInsertedResults = ( struct resultList * ) unInsertedResults -> link ;
    }
    placed = 1 ;
   }
  }
  if( !placed )
   insertedResults = addResultItem( insertedResults, data ) ;
 }
 return insertedResults ;
}

variable_types:
unSortedResults
struct resultList *

variable_types:
data
char *

variable_types: placed int


sortResult

decompiled_code:
const char **__fastcall sortResult(const char **a1)
{
const char **v1; // rbx

v1 = a1;
if ( a1 )
{
a1 = 0LL;
do
{
a1 = (const char **)insertSortResultItem(a1, *v1);
v1 = (const char **)v1[1];
}
while ( v1 );
}
return a1;
}

canonical_decompiled_code:
const char **__fastcall func1(const char **a1)
{
const char **v1; // rbx

v1 = a1;
if ( a1 )
{
a1 = 0LL;
do
{
a1 = (const char **)func0(a1, *v1);
v1 = (const char **)v1[1];
}
while ( v1 );
}
return a1;
}

original_code:
resultList* sortResult( resultList* theResults )
{
 resultList* insertSortResultItem( resultList*, char * ) ;
 resultList *unSortedResults = ((void *)0) ;
 resultList *sortedResults = ((void *)0) ;
 unSortedResults = theResults ;
 if( unSortedResults == ((void *)0) )
  return unSortedResults ;
 else
 {
  while ( unSortedResults != ((void *)0) )
  {
   sortedResults = insertSortResultItem( sortedResults, unSortedResults -> oneResult ) ;
   unSortedResults = ( resultList* ) unSortedResults -> link ;
  }
 }
 return sortedResults ;
}

canonical_original_code:
struct resultList *sortResult(struct resultList *theResults)
{
 struct resultList *insertSortResultItem(struct resultList *, char *);
 struct resultList *unSortedResults = ((void *)0);
 struct resultList *sortedResults = ((void *)0);
 unSortedResults = theResults ;
 if( unSortedResults == ((void *)0) )
  return unSortedResults ;
 else
 {
  while ( unSortedResults != ((void *)0) )
  {
   sortedResults = insertSortResultItem( sortedResults, unSortedResults -> oneResult ) ;
   unSortedResults = ( struct resultList * ) unSortedResults -> link ;
  }
 }
 return sortedResults ;
}

variable_types:
theResults
struct resultList *

variable_types: struct resultList { char *oneResult; struct resultList *link; } *(struct resultList *, char *)


andResult

decompiled_code:
__int64 __fastcall andResult(__int64 a1, __int64 a2)
{
__int64 v2; // r12
__int64 v3; // r13
__int64 i; // rbx

v2 = a2;
v3 = 0LL;
if ( !a2 )
return 0LL;
do
{
for ( i = a1; i; i = *(_QWORD *)(i + 8) )
{
if ( !strcmp(*(const char **)i, *(const char **)v2) )
v3 = addResultItem(v3);
}
v2 = *(_QWORD *)(v2 + 8);
}
while ( v2 );
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
__int64 v2; // r12
__int64 v3; // r13
__int64 i; // rbx

v2 = a2;
v3 = 0LL;
if ( !a2 )
return 0LL;
do
{
for ( i = a1; i; i = *(_QWORD *)(i + 8) )
{
if ( !strcmp(*(const char **)i, *(const char **)v2) )
v3 = addResultItem(v3);
}
v2 = *(_QWORD *)(v2 + 8);
}
while ( v2 );
return v3;
}

original_code:
resultList* andResult( resultList* tempResults, resultList* newResults )
{
 resultList *andResultList = ((void *)0) ;
 resultList *tempOftempResults = ((void *)0) ;
 while ( newResults != ((void *)0) )
 {
  tempOftempResults = tempResults ;
  while ( tempOftempResults != ((void *)0) )
  {
   if( strcmp( tempOftempResults -> oneResult, newResults -> oneResult ) == 0 )
    andResultList = addResultItem( andResultList, tempOftempResults -> oneResult ) ;
   tempOftempResults = ( resultList* ) tempOftempResults -> link ;
  }
  newResults = ( resultList* ) newResults -> link ;
 }
 return andResultList ;
}

canonical_original_code:
struct resultList *andResult(struct resultList *tempResults, struct resultList *newResults)
{
 struct resultList *andResultList = ((void *)0);
 struct resultList *tempOftempResults = ((void *)0);
 while ( newResults != ((void *)0) )
 {
  tempOftempResults = tempResults ;
  while ( tempOftempResults != ((void *)0) )
  {
   if( strcmp( tempOftempResults -> oneResult, newResults -> oneResult ) == 0 )
    andResultList = addResultItem( andResultList, tempOftempResults -> oneResult ) ;
   tempOftempResults = ( struct resultList * ) tempOftempResults -> link ;
  }
  newResults = ( struct resultList * ) newResults -> link ;
 }
 return andResultList ;
}

variable_types:
tempResults
struct resultList *

variable_types:
newResults
struct resultList *

variable_types: struct resultList { char *oneResult; struct resultList *link; } *


orResult

decompiled_code:
__int64 __fastcall orResult(__int64 a1, __int64 a2)
{
__int64 v2; // r12
__int64 i; // r14
__int64 v5; // rbx
const char *v6; // rbp

v2 = a2;
for ( i = a1; v2; v2 = *(_QWORD *)(v2 + 8) )
{
if ( a1 )
{
v6 = *(const char **)v2;
v5 = a1;
while ( strcmp(*(const char **)v5, v6) )
{
v5 = *(_QWORD *)(v5 + 8);
if ( !v5 )
goto LABEL_8;
}
}
else
{
LABEL_8:
i = addResultItem(i);
}
}
return i;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2)
{
__int64 v2; // r12
__int64 i; // r14
__int64 v5; // rbx
const char *v6; // rbp

v2 = a2;
for ( i = a1; v2; v2 = *(_QWORD *)(v2 + 8) )
{
if ( a1 )
{
v6 = *(const char **)v2;
v5 = a1;
while ( strcmp(*(const char **)v5, v6) )
{
v5 = *(_QWORD *)(v5 + 8);
if ( !v5 )
goto LABEL_8;
}
}
else
{
LABEL_8:
i = addResultItem(i);
}
}
return i;
}

original_code:
resultList* orResult( resultList* tempResults, resultList* newResults )
{
 int found ;
 resultList *orResultList, *listpointer ;
 orResultList = listpointer = tempResults ;
 while ( newResults != ((void *)0) )
 {
  found = 0 ;
  tempResults = listpointer ;
  while ( tempResults != ((void *)0) && !found )
  {
   if( strcmp( tempResults -> oneResult, newResults -> oneResult ) == 0 )
    found = 1 ;
   tempResults = ( resultList* ) tempResults -> link ;
  }
  if( !found )
   orResultList = addResultItem( orResultList, newResults -> oneResult ) ;
  newResults = ( resultList* ) newResults -> link ;
 }
 return orResultList ;
}

canonical_original_code:
struct resultList *orResult(struct resultList *tempResults, struct resultList *newResults)
{
 int found;
 struct resultList *orResultList; struct resultList *listpointer;
 orResultList = listpointer = tempResults ;
 while ( newResults != ((void *)0) )
 {
  found = 0 ;
  tempResults = listpointer ;
  while ( tempResults != ((void *)0) && !found )
  {
   if( strcmp( tempResults -> oneResult, newResults -> oneResult ) == 0 )
    found = 1 ;
   tempResults = ( struct resultList * ) tempResults -> link ;
  }
  if( !found )
   orResultList = addResultItem( orResultList, newResults -> oneResult ) ;
  newResults = ( struct resultList * ) newResults -> link ;
 }
 return orResultList ;
}

variable_types: found int


formatTime

decompiled_code:
void __fastcall formatTime(char *s, char *a2)
{
char *v2; // r14
char *v3; // rax
int v4; // ebx
char *v5; // rbp
char *v6; // r12
char *v7; // r13

v2 = strdup(a2);
v3 = strtok(v2, ":");
if ( v3 )
{
v4 = 0;
v5 = 0LL;
v6 = 0LL;
v7 = 0LL;
do
{
switch ( v4 )
{
case 1:
v6 = strdup(v3);
break;
case 2:
v5 = strdup(v3);
break;
case 0:
v7 = strdup(v3);
break;
}
++v4;
v3 = strtok(0LL, ":");
}
while ( v3 );
}
else
{
v5 = 0LL;
v6 = 0LL;
v7 = 0LL;
}
sprintf(s, "%s:%s:%s", v7, v6, v5);
free(v7);
free(v6);
free(v5);
free(v2);
}

canonical_decompiled_code:
void __fastcall func4(char *s, char *a2)
{
char *v2; // r14
char *v3; // rax
int v4; // ebx
char *v5; // rbp
char *v6; // r12
char *v7; // r13

v2 = strdup(a2);
v3 = strtok(v2, ":");
if ( v3 )
{
v4 = 0;
v5 = 0LL;
v6 = 0LL;
v7 = 0LL;
do
{
switch ( v4 )
{
case 1:
v6 = strdup(v3);
break;
case 2:
v5 = strdup(v3);
break;
case 0:
v7 = strdup(v3);
break;
}
++v4;
v3 = strtok(0LL, ":");
}
while ( v3 );
}
else
{
v5 = 0LL;
v6 = 0LL;
v7 = 0LL;
}
sprintf(s, "%s:%s:%s", v7, v6, v5);
free(v7);
free(v6);
free(v5);
free(v2);
}

original_code:
void formatTime( char *newTime, char *oldTime )
{
 char *word, *toParse, *hours, *minutes, *seconds ;
 int numParses ;
 numParses = 0 ;
 word = toParse = hours = minutes = seconds = ((void *)0) ;
 toParse = strdup( oldTime ) ;
 word = strtok( toParse, ":" ) ;
 while( word != ((void *)0) )
 {
  switch( numParses )
  {
   case 0 : hours = strdup( word ) ;
     break ;
   case 1 : minutes = strdup( word ) ;
     break ;
   case 2 : seconds = strdup( word ) ;
     break ;
  }
  numParses++ ;
  word = strtok( ((void *)0), ":" ) ;
 }
 sprintf( newTime,"%s:%s:%s", hours, minutes, seconds ) ;
 free( hours ) ;
 free( minutes ) ;
 free( seconds ) ;
 free( toParse ) ;
}

canonical_original_code:
void formatTime(char *newTime, char *oldTime)
{
 char *word; char *toParse; char *hours; char *minutes; char *seconds;
 int numParses;
 numParses = 0 ;
 word = toParse = hours = minutes = seconds = ((void *)0) ;
 toParse = strdup( oldTime ) ;
 word = strtok( toParse, ":" ) ;
 while( word != ((void *)0) )
 {
  switch( numParses )
  {
   case 0 : hours = strdup( word ) ;
     break ;
   case 1 : minutes = strdup( word ) ;
     break ;
   case 2 : seconds = strdup( word ) ;
     break ;
  }
  numParses++ ;
  word = strtok( ((void *)0), ":" ) ;
 }
 sprintf( newTime,"%s:%s:%s", hours, minutes, seconds ) ;
 free( hours ) ;
 free( minutes ) ;
 free( seconds ) ;
 free( toParse ) ;
}

variable_types:
newTime
char *

variable_types:
oldTime
char *

variable_types:
word
char *

variable_types:
toParse
char *

variable_types:
hours
char *

variable_types:
minutes
char *

variable_types:
seconds
char *

variable_types: numParses int