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

v1 = a1;
do
printf("%5d", *v1++);
while ( v1 != a1 + 10 );
return puts("\n");
}

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

v1 = a1;
do
printf("%5d", *v1++);
while ( v1 != a1 + 10 );
return puts("\n");
}

original_code:
void visualiza_vector(int vector[]) {
    int indice = 0;
    for (indice = 0; indice < 10; indice++) {
        printf("%5d", vector[indice]);
    }
    printf("\n\n");
}


main

canonical_name: main

repo: jrbarrio/FundamentosProgramacionI

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v4[12]; // [rsp+0h] [rbp-98h] BYREF
unsigned int v5[12]; // [rsp+30h] [rbp-68h] BYREF
unsigned int v6[14]; // [rsp+60h] [rbp-38h] BYREF

lee_vectores((__int64)v6, (__int64)v5);
compara_vectores((__int64)v6, (__int64)v5, (__int64)v4);
return visualiza_vectores(v6, v5, v4);
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v4[12]; // [rsp+0h] [rbp-98h] BYREF
unsigned int v5[12]; // [rsp+30h] [rbp-68h] BYREF
unsigned int v6[14]; // [rsp+60h] [rbp-38h] BYREF

func8((__int64)v6, (__int64)v5);
func9((__int64)v6, (__int64)v5, (__int64)v4);
return func12(v6, v5, v4);
}

original_code:
void main() {
    int vector_x[10], vector_y[10], vector_z[10];
    lee_vectores(vector_x, vector_y);
    compara_vectores(vector_x, vector_y, vector_z);
    visualiza_vectores(vector_x, vector_y, vector_z);
}

canonical_original_code:
void main() {
    int vector_x[10]; int vector_y[10]; int vector_z[10];
    lee_vectores(vector_x, vector_y);
    compara_vectores(vector_x, vector_y, vector_z);
    visualiza_vectores(vector_x, vector_y, vector_z);
}

return_type: void


calcula

decompiled_code:
void __fastcall calcula(float *a1, int a2, float a3)
{
float v4; // xmm0_4

if ( a2 > 0 )
{
v4 = *a1;
do
{
v4 = v4 * a3;
--a2;
}
while ( a2 );
*a1 = v4;
}
}

canonical_decompiled_code:
void __fastcall func7(float *a1, int a2, float a3)
{
float v4; // xmm0_4

if ( a2 > 0 )
{
v4 = *a1;
do
{
v4 = v4 * a3;
--a2;
}
while ( a2 );
*a1 = v4;
}
}

original_code:
void calcula (float *altura, float factor,int orden)
{
for (; orden>0; orden --)
 *altura= *altura * factor;
}

canonical_original_code:
void calcula(float *altura, float factor, int orden)
{
for (; orden>0; orden --)
 *altura= *altura * factor;
}

variable_types:
altura
float *

variable_types: factor float

variable_types: orden int


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // ebx
float v5; // [rsp+4h] [rbp-14h]
float v6; // [rsp+8h] [rbp-10h]
float v7[3]; // [rsp+Ch] [rbp-Ch] BYREF

printf("INTRODUCE LA ALTURA INICIAL --->");
__isoc99_scanf();
printf("INTRODUCE EL FACTOR DE REBOTE --->");
__isoc99_scanf();
printf("INTRODUCE LA NUEVA ALTURA --->");
__isoc99_scanf();
v3 = 1;
do
calcula(v7, v3++, v6);
while ( v7[0] > v5 );
printf("LA PRIMERA ALTURA INFERIOR A LA DADA ES --->%f\n", v7[0]);
return printf("EL NUMERO DE ORDEN DEL REBOTE ES --->%d\n", v3);
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // ebx
float v5; // [rsp+4h] [rbp-14h]
float v6; // [rsp+8h] [rbp-10h]
float v7[3]; // [rsp+Ch] [rbp-Ch] BYREF

printf("INTRODUCE LA ALTURA INICIAL --->");
__isoc99_scanf();
printf("INTRODUCE EL FACTOR DE REBOTE --->");
__isoc99_scanf();
printf("INTRODUCE LA NUEVA ALTURA --->");
__isoc99_scanf();
v3 = 1;
do
func7(v7, v3++, v6);
while ( v7[0] > v5 );
printf("LA PRIMERA ALTURA INFERIOR A LA DADA ES --->%f\n", v7[0]);
return printf("EL NUMERO DE ORDEN DEL REBOTE ES --->%d\n", v3);
}

original_code:
void main (void)
{
int orden=1 ;
float altura,factor,nueva;
printf ("INTRODUCE LA ALTURA INICIAL --->");
scanf ("%f",&altura);
printf ("INTRODUCE EL FACTOR DE REBOTE --->");
scanf ("%f",&factor);
printf ("INTRODUCE LA NUEVA ALTURA --->");
scanf ("%f",&nueva);
do
 {
 calcula (&altura,factor,orden);
 orden ++ ;
 }
while (altura>nueva);
printf ("LA PRIMERA ALTURA INFERIOR A LA DADA ES --->%f\n",altura);
printf ("EL NUMERO DE ORDEN DEL REBOTE ES --->%d\n",orden);
}

canonical_original_code:
void main()
{
int orden = 1;
float altura; float factor; float nueva;
printf ("INTRODUCE LA ALTURA INICIAL --->");
scanf ("%f",&altura);
printf ("INTRODUCE EL FACTOR DE REBOTE --->");
scanf ("%f",&factor);
printf ("INTRODUCE LA NUEVA ALTURA --->");
scanf ("%f",&nueva);
do
 {
 calcula (&altura,factor,orden);
 orden ++ ;
 }
while (altura>nueva);
printf ("LA PRIMERA ALTURA INFERIOR A LA DADA ES --->%f\n",altura);
printf ("EL NUMERO DE ORDEN DEL REBOTE ES --->%d\n",orden);
}

variable_types: altura float

variable_types: nueva float


decompiled_code:
int __fastcall introduce_puntuaciones(_QWORD *a1, _QWORD *a2, _QWORD *a3)
{
int result; // eax
char v5; // [rsp+Fh] [rbp-39h] BYREF
__int64 v6; // [rsp+10h] [rbp-38h] BYREF
__int64 v7; // [rsp+18h] [rbp-30h] BYREF
__int64 v8; // [rsp+20h] [rbp-28h] BYREF
__int64 v9; // [rsp+28h] [rbp-20h] BYREF

*a3 = 0LL;
*a2 = 0LL;
*a1 = 0LL;
do
{
pide_datos((void **)&v9, &v5);
switch ( v5 )
{
case 'Y':
inserta_nodo(a2, &v7, v9);
break;
case 'Z':
inserta_nodo(a3, &v6, v9);
break;
case 'X':
inserta_nodo(a1, &v8, v9);
break;
}
result = pregunta();
}
while ( (_BYTE)result != 78 );
return result;
}

canonical_decompiled_code:
int __fastcall func12(_QWORD *a1, _QWORD *a2, _QWORD *a3)
{
int result; // eax
char v5; // [rsp+Fh] [rbp-39h] BYREF
__int64 v6; // [rsp+10h] [rbp-38h] BYREF
__int64 v7; // [rsp+18h] [rbp-30h] BYREF
__int64 v8; // [rsp+20h] [rbp-28h] BYREF
__int64 v9; // [rsp+28h] [rbp-20h] BYREF

*a3 = 0LL;
*a2 = 0LL;
*a1 = 0LL;
do
{
func9((void **)&v9, &v5);
switch ( v5 )
{
case 'Y':
func10(a2, &v7, v9);
break;
case 'Z':
func10(a3, &v6, v9);
break;
case 'X':
func10(a1, &v8, v9);
break;
}
result = func11();
}
while ( (_BYTE)result != 78 );
return result;
}

original_code:
void introduce_puntuaciones(PUNT_NODO_PUNTUACIONES *p_juez_1,
        PUNT_NODO_PUNTUACIONES *p_juez_2, PUNT_NODO_PUNTUACIONES *p_juez_3) {
    PUNT_NODO_PUNTUACIONES nuevo, ultimo_1, ultimo_2, ultimo_3;
    char juez;
    char respuesta;
    *p_juez_1 = *p_juez_2 = *p_juez_3 = (PUNT_NODO_PUNTUACIONES) ((void *)0);
    do {
        pide_datos(&nuevo, &juez);
        switch (juez) {
            case 'X':
                inserta_nodo(p_juez_1, &ultimo_1, nuevo);
                break;
            case 'Y':
                inserta_nodo(p_juez_2, &ultimo_2, nuevo);
                break;
            case 'Z':
                inserta_nodo(p_juez_3, &ultimo_3, nuevo);
                break;
        }
        respuesta = pregunta();
    } while (respuesta != 'N');
}

canonical_original_code:
void introduce_puntuaciones(struct nodo_puntuaciones **p_juez_1, struct nodo_puntuaciones **p_juez_2, struct nodo_puntuaciones **p_juez_3) {
    struct nodo_puntuaciones *nuevo; struct nodo_puntuaciones *ultimo_1; struct nodo_puntuaciones *ultimo_2; struct nodo_puntuaciones *ultimo_3;
    char juez;
    char respuesta;
    *p_juez_1 = *p_juez_2 = *p_juez_3 = (PUNT_NODO_PUNTUACIONES) ((void *)0);
    do {
        pide_datos(&nuevo, &juez);
        switch (juez) {
            case 'X':
                inserta_nodo(p_juez_1, &ultimo_1, nuevo);
                break;
            case 'Y':
                inserta_nodo(p_juez_2, &ultimo_2, nuevo);
                break;
            case 'Z':
                inserta_nodo(p_juez_3, &ultimo_3, nuevo);
                break;
        }
        respuesta = pregunta();
    } while (respuesta != 'N');
}

variable_types: struct nodo_puntuaciones { struct ficha_puntuaciones { int numero; short sabor; } info; struct nodo_puntuaciones *enlace; } **

variable_types: juez char

variable_types: respuesta char

user_defined_types: struct nodo_puntuaciones { struct ficha_puntuaciones info; struct nodo_puntuaciones *enlace; }


decompiled_code:
__int64 __fastcall busca_nodo(__int64 a1, _DWORD *a2)
{
__int64 result; // rax

for ( result = a1; result; result = *(_QWORD *)(result + 16) )
{
if ( *(_DWORD *)result == *a2 )
break;
}
return result;
}

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

for ( result = a1; result; result = *(_QWORD *)(result + 16) )
{
if ( *(_DWORD *)result == *a2 )
break;
}
return result;
}

original_code:
PUNT_NODO_PUNTUACIONES busca_nodo(PUNT_NODO_PUNTUACIONES cabeza,
        PUNT_NODO_PUNTUACIONES viejo_1) {
    PUNT_NODO_PUNTUACIONES recorre;
    recorre = cabeza;
    while (recorre != (PUNT_NODO_PUNTUACIONES) ((void *)0)
            && recorre->info.numero != viejo_1->info.numero) {
        recorre = recorre->enlace;
    }
    return (recorre);
}

canonical_original_code:
struct nodo_puntuaciones *busca_nodo(struct nodo_puntuaciones *cabeza, struct nodo_puntuaciones *viejo_1) {
    struct nodo_puntuaciones *recorre;
    recorre = cabeza;
    while (recorre != (PUNT_NODO_PUNTUACIONES) ((void *)0)
            && recorre->info.numero != viejo_1->info.numero) {
        recorre = recorre->enlace;
    }
    return (recorre);
}

variable_types:
cabeza
struct nodo_puntuaciones *

variable_types: struct nodo_puntuaciones { struct ficha_puntuaciones { int numero; short sabor; } info; struct nodo_puntuaciones *enlace; } *


decompiled_code:
__int64 __fastcall elimina_nodo(__int64 *a1, __int64 *a2, _DWORD *a3)
{
__int64 result; // rax

*a2 = busca_nodo(*a1, a3);
result = elimina(*a1, (__int64)a2);
*a1 = result;
return result;
}

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

*a2 = func13(*a1, a3);
result = func14(*a1, (__int64)a2);
*a1 = result;
return result;
}

original_code:
void elimina_nodo(PUNT_NODO_PUNTUACIONES *p_cabeza,
        PUNT_NODO_PUNTUACIONES *p_viejo,
        PUNT_NODO_PUNTUACIONES viejo_1) {
    *p_viejo = busca_nodo(*p_cabeza, viejo_1);
    *p_cabeza = elimina(*p_cabeza, p_viejo);
}

canonical_original_code:
void elimina_nodo(struct nodo_puntuaciones **p_cabeza, struct nodo_puntuaciones **p_viejo, struct nodo_puntuaciones *viejo_1) {
    *p_viejo = busca_nodo(*p_cabeza, viejo_1);
    *p_cabeza = elimina(*p_cabeza, p_viejo);
}

user_defined_types: struct ficha_puntuaciones { int numero; short sabor; }


decompiled_code:
__int64 __fastcall busca_posicion(__int64 a1, __int64 a2)
{
__int64 result; // rax
int v4; // edx
int v5; // esi
int v6; // ecx

result = a1;
v4 = 0;
while ( result && !v4 )
{
v5 = *(_DWORD *)(result + 48);
v6 = *(_DWORD *)(a2 + 48);
v4 = 1;
if ( v5 >= v6 && (v5 != v6 || *(_DWORD *)(result + 44) <= *(_DWORD *)(a2 + 44)) )
{
result = *(_QWORD *)(result + 56);
v4 = 0;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func17(__int64 a1, __int64 a2)
{
__int64 result; // rax
int v4; // edx
int v5; // esi
int v6; // ecx

result = a1;
v4 = 0;
while ( result && !v4 )
{
v5 = *(_DWORD *)(result + 48);
v6 = *(_DWORD *)(a2 + 48);
v4 = 1;
if ( v5 >= v6 && (v5 != v6 || *(_DWORD *)(result + 44) <= *(_DWORD *)(a2 + 44)) )
{
result = *(_QWORD *)(result + 56);
v4 = 0;
}
}
return result;
}

original_code:
PUNT_NODO_CLASIFICACION busca_posicion(PUNT_NODO_CLASIFICACION cabeza,
        PUNT_NODO_CLASIFICACION nuevo) {
    PUNT_NODO_CLASIFICACION recorre;
    int encontrado = 0;
    recorre = cabeza;
    while (recorre != (PUNT_NODO_CLASIFICACION) ((void *)0) && !encontrado) {
        if (recorre->info.puntuacion < nuevo->info.puntuacion) {
            encontrado = 1;
        } else {
            if (recorre->info.puntuacion == nuevo->info.puntuacion
                    && recorre->info.numero > nuevo->info.numero) {
                encontrado = 1;
            } else {
                recorre = recorre->enlace;
            }
        }
    }
    return (recorre);
}

canonical_original_code:
struct nodo_clasificacion *busca_posicion(struct nodo_clasificacion *cabeza, struct nodo_clasificacion *nuevo) {
    struct nodo_clasificacion *recorre;
    int encontrado = 0;
    recorre = cabeza;
    while (recorre != (PUNT_NODO_CLASIFICACION) ((void *)0) && !encontrado) {
        if (recorre->info.puntuacion < nuevo->info.puntuacion) {
            encontrado = 1;
        } else {
            if (recorre->info.puntuacion == nuevo->info.puntuacion
                    && recorre->info.numero > nuevo->info.numero) {
                encontrado = 1;
            } else {
                recorre = recorre->enlace;
            }
        }
    }
    return (recorre);
}

variable_types:
cabeza
struct nodo_clasificacion *

variable_types:
nuevo
struct nodo_clasificacion *

variable_types: struct nodo_clasificacion { struct ficha_clasificacion { char nombre[21]; char poblacion[21]; int numero; int puntuacion; } info; struct nodo_clasificacion *enlace; } *

variable_types: encontrado int

user_defined_types: struct nodo_clasificacion { struct ficha_clasificacion info; struct nodo_clasificacion *enlace; }


original_code:
PUNT_NODO_CLASIFICACION inserta_en_orden(PUNT_NODO_CLASIFICACION cabeza,
        PUNT_NODO_CLASIFICACION nuevo, PUNT_NODO_CLASIFICACION posicion) {
    PUNT_NODO_CLASIFICACION anterior;
    if (posicion == cabeza) {
        nuevo->enlace = cabeza;
        cabeza = nuevo;
    } else {
        anterior = cabeza;
        while(anterior->enlace != posicion) {
            anterior = anterior->enlace;
        }
        nuevo->enlace = posicion;
        anterior->enlace = nuevo;
    }
    return (cabeza);
}

canonical_original_code:
struct nodo_clasificacion *inserta_en_orden(struct nodo_clasificacion *cabeza, struct nodo_clasificacion *nuevo, struct nodo_clasificacion *posicion) {
    struct nodo_clasificacion *anterior;
    if (posicion == cabeza) {
        nuevo->enlace = cabeza;
        cabeza = nuevo;
    } else {
        anterior = cabeza;
        while(anterior->enlace != posicion) {
            anterior = anterior->enlace;
        }
        nuevo->enlace = posicion;
        anterior->enlace = nuevo;
    }
    return (cabeza);
}

variable_types:
posicion
struct nodo_clasificacion *

return_type: struct nodo_clasificacion { struct ficha_clasificacion { char nombre[21]; char poblacion[21]; int numero; int puntuacion; } info; struct nodo_clasificacion *enlace; } *


decompiled_code:
__int64 __fastcall crea_clasificacion(void *ptr, __int64 a2, __int64 a3, __int64 a4)
{
_DWORD *v4; // r12
__int64 v6; // rbx
_DWORD *v7; // rbp
char *v8; // rbp
__int64 v9; // rax
__int64 v11; // [rsp+0h] [rbp-48h] BYREF
__int64 v12; // [rsp+8h] [rbp-40h] BYREF
void *v13; // [rsp+10h] [rbp-38h] BYREF
void *v14; // [rsp+18h] [rbp-30h] BYREF

v4 = ptr;
v12 = a2;
v11 = a3;
if ( !ptr )
return 0LL;
v6 = 0LL;
do
{
v7 = v4;
v4 = (_DWORD *)*((_QWORD *)v4 + 2);
elimina_nodo(&v12, (__int64 *)&v14, v7);
elimina_nodo(&v11, (__int64 *)&v13, v7);
v8 = crea_nodo(v7, v14, v13, a4);
v9 = busca_posicion(v6, (__int64)v8);
v6 = inserta_en_orden(v6, (__int64)v8, v9);
}
while ( v4 );
return v6;
}

original_code:
PUNT_NODO_CLASIFICACION crea_clasificacion(PUNT_NODO_PUNTUACIONES juez_1,
        PUNT_NODO_PUNTUACIONES juez_2, PUNT_NODO_PUNTUACIONES juez_3,
        FICHA_INSCRIPCION vector_inscripciones[]) {
    PUNT_NODO_CLASIFICACION nuevo, posicion;
    PUNT_NODO_CLASIFICACION ganador = (PUNT_NODO_CLASIFICACION) ((void *)0);
    PUNT_NODO_PUNTUACIONES viejo_1, viejo_2, viejo_3;
    while (juez_1 != (PUNT_NODO_PUNTUACIONES) ((void *)0)) {
        viejo_1 = juez_1;
        juez_1 = juez_1->enlace;
        elimina_nodo(&juez_2, &viejo_2, viejo_1);
        elimina_nodo(&juez_3, &viejo_3, viejo_1);
        nuevo = crea_nodo(viejo_1, viejo_2, viejo_3, vector_inscripciones);
        posicion = busca_posicion(ganador, nuevo);
        ganador = inserta_en_orden(ganador, nuevo, posicion);
    }
    return (ganador);
}

canonical_original_code:
struct nodo_clasificacion *crea_clasificacion(struct nodo_puntuaciones *juez_1, struct nodo_puntuaciones *juez_2, struct nodo_puntuaciones *juez_3, struct ficha_inscripcion vector_inscripciones[]) {
    struct nodo_clasificacion *nuevo; struct nodo_clasificacion *posicion;
    struct nodo_clasificacion *ganador = (PUNT_NODO_CLASIFICACION) ((void *)0);
    struct nodo_puntuaciones *viejo_1; struct nodo_puntuaciones *viejo_2; struct nodo_puntuaciones *viejo_3;
    while (juez_1 != (PUNT_NODO_PUNTUACIONES) ((void *)0)) {
        viejo_1 = juez_1;
        juez_1 = juez_1->enlace;
        elimina_nodo(&juez_2, &viejo_2, viejo_1);
        elimina_nodo(&juez_3, &viejo_3, viejo_1);
        nuevo = crea_nodo(viejo_1, viejo_2, viejo_3, vector_inscripciones);
        posicion = busca_posicion(ganador, nuevo);
        ganador = inserta_en_orden(ganador, nuevo, posicion);
    }
    return (ganador);
}

variable_types: struct ficha_inscripcion { char nombre[21]; char poblacion[21]; int numero; } []

user_defined_types: struct ficha_clasificacion { char nombre[21]; char poblacion[21]; int numero; int puntuacion; }


decompiled_code:
void *__fastcall pide_datos(void **a1, _BYTE *a2)
{
void *result; // rax

printf("\n\nIDENTIFICADOR DE JUEZ --->");
*a2 = getchar();
*a1 = malloc(0x18uLL);
printf("\nNUMERO --->");
__isoc99_scanf();
printf("\nSABOR --->");
__isoc99_scanf();
printf("\nPUNTO --->");
__isoc99_scanf();
printf("\nPRESENTACION --->");
__isoc99_scanf();
result = *a1;
*((_QWORD *)*a1 + 2) = 0LL;
return result;
}

canonical_decompiled_code:
void *__fastcall func9(void **a1, _BYTE *a2)
{
void *result; // rax

printf("\n\nIDENTIFICADOR DE JUEZ --->");
*a2 = getchar();
*a1 = malloc(0x18uLL);
printf("\nNUMERO --->");
__isoc99_scanf();
printf("\nSABOR --->");
__isoc99_scanf();
printf("\nPUNTO --->");
__isoc99_scanf();
printf("\nPRESENTACION --->");
__isoc99_scanf();
result = *a1;
*((_QWORD *)*a1 + 2) = 0LL;
return result;
}

original_code:
void pide_datos(PUNT_NODO_PUNTUACIONES *p_nuevo, char *juez) {
    printf("\n\nIDENTIFICADOR DE JUEZ --->");
    *juez = getchar();
    *p_nuevo = (PUNT_NODO_PUNTUACIONES) malloc(sizeof (NODO_PUNTUACIONES));
    printf("\nNUMERO --->");
    scanf("%d", &(*p_nuevo)->info.numero);
    printf("\nSABOR --->");
    scanf("%d", &(*p_nuevo)->info.sabor);
    printf("\nPUNTO --->");
    scanf("%d", &(*p_nuevo)->info.punto);
    printf("\nPRESENTACION --->");
    scanf("%d", &(*p_nuevo)->info.presentacion);
    (*p_nuevo)->enlace = (PUNT_NODO_PUNTUACIONES) ((void *)0);
}

canonical_original_code:
void pide_datos(struct nodo_puntuaciones **p_nuevo, char *juez) {
    printf("\n\nIDENTIFICADOR DE JUEZ --->");
    *juez = getchar();
    *p_nuevo = (struct nodo_puntuaciones *) malloc(sizeof (NODO_PUNTUACIONES));
    printf("\nNUMERO --->");
    scanf("%d", &(*p_nuevo)->info.numero);
    printf("\nSABOR --->");
    scanf("%d", &(*p_nuevo)->info.sabor);
    printf("\nPUNTO --->");
    scanf("%d", &(*p_nuevo)->info.punto);
    printf("\nPRESENTACION --->");
    scanf("%d", &(*p_nuevo)->info.presentacion);
    (*p_nuevo)->enlace = (PUNT_NODO_PUNTUACIONES) ((void *)0);
}

variable_types:
juez
char *


decompiled_code:
__int64 __fastcall inserta_nodo(_QWORD *a1, __int64 *a2, __int64 a3)
{
__int64 result; // rax

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

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

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

original_code:
void inserta_nodo(PUNT_NODO_PUNTUACIONES *p_cabeza,
        PUNT_NODO_PUNTUACIONES *p_ultimo,
        PUNT_NODO_PUNTUACIONES nuevo) {
    if (*p_cabeza == (PUNT_NODO_PUNTUACIONES) ((void *)0)) {
        *p_cabeza = nuevo;
    } else {
        (*p_ultimo)->enlace = nuevo;
    }
    *p_ultimo = nuevo;
}

canonical_original_code:
void inserta_nodo(struct nodo_puntuaciones **p_cabeza, struct nodo_puntuaciones **p_ultimo, struct nodo_puntuaciones *nuevo) {
    if (*p_cabeza == (PUNT_NODO_PUNTUACIONES) ((void *)0)) {
        *p_cabeza = nuevo;
    } else {
        (*p_ultimo)->enlace = nuevo;
    }
    *p_ultimo = nuevo;
}

variable_types:
nuevo
struct nodo_puntuaciones *


elimina

original_code:
PUNT_NODO_PUNTUACIONES elimina(PUNT_NODO_PUNTUACIONES cabeza,
        PUNT_NODO_PUNTUACIONES viejo) {
    PUNT_NODO_PUNTUACIONES anterior;
    if (viejo == cabeza) {
        cabeza = cabeza->enlace;
    } else {
        anterior = cabeza;
        while (anterior->enlace != viejo) {
            anterior = anterior->enlace;
        }
        anterior->enlace = viejo->enlace;
    }
    viejo->enlace = (PUNT_NODO_PUNTUACIONES) ((void *)0);
    return (cabeza);
}

canonical_original_code:
struct nodo_puntuaciones *elimina(struct nodo_puntuaciones *cabeza, struct nodo_puntuaciones *viejo) {
    struct nodo_puntuaciones *anterior;
    if (viejo == cabeza) {
        cabeza = cabeza->enlace;
    } else {
        anterior = cabeza;
        while (anterior->enlace != viejo) {
            anterior = anterior->enlace;
        }
        anterior->enlace = viejo->enlace;
    }
    viejo->enlace = (PUNT_NODO_PUNTUACIONES) ((void *)0);
    return (cabeza);
}

variable_types:
viejo
struct nodo_puntuaciones *

return_type: struct nodo_puntuaciones { struct ficha_puntuaciones { int numero; short sabor; } info; struct nodo_puntuaciones *enlace; } *


original_code:
PUNT_NODO_CLASIFICACION crea_nodo(PUNT_NODO_PUNTUACIONES viejo_1,
        PUNT_NODO_PUNTUACIONES viejo_2, PUNT_NODO_PUNTUACIONES viejo_3,
        FICHA_INSCRIPCION vector_inscripciones[]) {
    PUNT_NODO_CLASIFICACION nuevo;
    nuevo = (PUNT_NODO_CLASIFICACION) malloc(sizeof (NODO_CLASIFICACION));
    strcpy(nuevo->info.nombre, vector_inscripciones[viejo_1->info.numero - 1].nombre);
    strcpy(nuevo->info.nombre, vector_inscripciones[viejo_1->info.numero - 1].poblacion);
    nuevo->info.numero = viejo_1->info.numero;
    nuevo->info.puntuacion = viejo_1->info.sabor + viejo_1->info.punto + viejo_1->info.presentacion
            + viejo_2->info.sabor + viejo_2->info.punto + viejo_2->info.presentacion
            + viejo_3->info.sabor + viejo_3->info.punto + viejo_3->info.presentacion;
    nuevo->enlace = (PUNT_NODO_CLASIFICACION) ((void *)0);
    free (viejo_1);
    free (viejo_2);
    free (viejo_3);
    return (nuevo);
}

canonical_original_code:
struct nodo_clasificacion *crea_nodo(struct nodo_puntuaciones *viejo_1, struct nodo_puntuaciones *viejo_2, struct nodo_puntuaciones *viejo_3, struct ficha_inscripcion vector_inscripciones[]) {
    struct nodo_clasificacion *nuevo;
    nuevo = (struct nodo_clasificacion *) malloc(sizeof (NODO_CLASIFICACION));
    strcpy(nuevo->info.nombre, vector_inscripciones[viejo_1->info.numero - 1].nombre);
    strcpy(nuevo->info.nombre, vector_inscripciones[viejo_1->info.numero - 1].poblacion);
    nuevo->info.numero = viejo_1->info.numero;
    nuevo->info.puntuacion = viejo_1->info.sabor + viejo_1->info.punto + viejo_1->info.presentacion
            + viejo_2->info.sabor + viejo_2->info.punto + viejo_2->info.presentacion
            + viejo_3->info.sabor + viejo_3->info.punto + viejo_3->info.presentacion;
    nuevo->enlace = (PUNT_NODO_CLASIFICACION) ((void *)0);
    free (viejo_1);
    free (viejo_2);
    free (viejo_3);
    return (nuevo);
}

user_defined_types: struct ficha_inscripcion { char nombre[21]; char poblacion[21]; int numero; }


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int result; // eax
void *v4; // rax
int v5; // [rsp+4h] [rbp-3874h] BYREF
__int64 v6; // [rsp+8h] [rbp-3870h] BYREF
__int64 v7; // [rsp+10h] [rbp-3868h] BYREF
void *ptr; // [rsp+18h] [rbp-3860h] BYREF
__m128i v9[900]; // [rsp+20h] [rbp-3858h] BYREF
char filename[8]; // [rsp+3860h] [rbp-18h] BYREF
__int64 v11; // [rsp+3868h] [rbp-10h] BYREF

v11 = 0x50495243534E49LL;
strcpy(filename, "GANADOR");
vuelca_fichero_inscripciones_a_vector((const char *)&v11, v9, &v5);
if ( v5 )
{
printf("ERROR AL INTENTAR ABRIR EL FICHERO PARA LEER");
result = getchar();
}
else
{
introduce_puntuaciones(&ptr, &v7, &v6);
v4 = (void *)crea_clasificacion(ptr, v7, v6, (__int64)v9);
result = vuelca_lista_a_fichero_clasificacion(v4, filename);
}
return result;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int result; // eax
void *v4; // rax
int v5; // [rsp+4h] [rbp-3874h] BYREF
__int64 v6; // [rsp+8h] [rbp-3870h] BYREF
__int64 v7; // [rsp+10h] [rbp-3868h] BYREF
void *ptr; // [rsp+18h] [rbp-3860h] BYREF
__m128i v9[900]; // [rsp+20h] [rbp-3858h] BYREF
char filename[8]; // [rsp+3860h] [rbp-18h] BYREF
__int64 v11; // [rsp+3868h] [rbp-10h] BYREF

v11 = 0x50495243534E49LL;
strcpy(filename, "GANADOR");
func7((const char *)&v11, v9, &v5);
if ( v5 )
{
printf("ERROR AL INTENTAR ABRIR EL FICHERO PARA LEER");
result = getchar();
}
else
{
func12(&ptr, &v7, &v6);
v4 = (void *)func19(ptr, v7, v6, (__int64)v9);
result = func8(v4, filename);
}
return result;
}

original_code:
void main (void) {
    char nomf_inscripciones[] = "INSCRIP";
    char nomf_clasificacion[] = "GANADOR";
    FICHA_INSCRIPCION vector_inscripciones[300];
    PUNT_NODO_PUNTUACIONES juez_1, juez_2, juez_3;
    PUNT_NODO_CLASIFICACION ganador;
    int error;
    vuelca_fichero_inscripciones_a_vector(nomf_inscripciones,
            vector_inscripciones, &error);
    if (error) {
        printf("ERROR AL INTENTAR ABRIR EL FICHERO PARA LEER");
        getchar();
    } else {
        introduce_puntuaciones(&juez_1, &juez_2, &juez_3);
        ganador = crea_clasificacion(juez_1, juez_2, juez_3,
                vector_inscripciones);
        vuelca_lista_a_fichero_clasificacion(ganador, nomf_clasificacion);
    }
}

canonical_original_code:
void main() {
    char nomf_inscripciones[] = "INSCRIP";
    char nomf_clasificacion[] = "GANADOR";
    struct ficha_inscripcion vector_inscripciones[300];
    struct nodo_puntuaciones *juez_1; struct nodo_puntuaciones *juez_2; struct nodo_puntuaciones *juez_3;
    struct nodo_clasificacion *ganador;
    int error;
    vuelca_fichero_inscripciones_a_vector(nomf_inscripciones,
            vector_inscripciones, &error);
    if (error) {
        printf("ERROR AL INTENTAR ABRIR EL FICHERO PARA LEER");
        getchar();
    } else {
        introduce_puntuaciones(&juez_1, &juez_2, &juez_3);
        ganador = crea_clasificacion(juez_1, juez_2, juez_3,
                vector_inscripciones);
        vuelca_lista_a_fichero_clasificacion(ganador, nomf_clasificacion);
    }
}

variable_types: struct ficha_inscripcion { char nombre[21]; char poblacion[21]; int numero; } [300]

variable_types: error int


inferiores

decompiled_code:
__int64 __fastcall inferiores(int a1)
{
int v1; // edi
__int64 result; // rax

v1 = a1 - 1;
if ( !v1 )
return 0LL;
LODWORD(result) = v1;
do
result = (unsigned int)(--v1 + result);
while ( v1 );
return result;
}

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

v1 = a1 - 1;
if ( !v1 )
return 0LL;
LODWORD(result) = v1;
do
result = (unsigned int)(--v1 + result);
while ( v1 );
return result;
}

original_code:
int inferiores (int centro )
{
int inferiores;
centro --;
for (inferiores = centro; centro != 0;)
 {
 centro --;
 inferiores = inferiores + centro;
 }
return (inferiores) ;
}

canonical_original_code:
int inferiores(int centro)
{
int inferiores;
centro --;
for (inferiores = centro; centro != 0;)
 {
 centro --;
 inferiores = inferiores + centro;
 }
return (inferiores) ;
}

variable_types: centro int

variable_types: inferiores int

return_type: int


comprueba

decompiled_code:
int __fastcall comprueba(unsigned int a1)
{
unsigned int v1; // ebx
int v2; // edx
int result; // eax

v1 = a1 + 1;
v2 = inferiores(a1);
result = a1 + 1;
do
result += ++v1;
while ( v2 > result );
if ( v2 == result )
result = printf("EL NUMERO %d ES UN CENTRO NUMERICO \n", a1);
return result;
}

canonical_decompiled_code:
int __fastcall func8(unsigned int a1)
{
unsigned int v1; // ebx
int v2; // edx
int result; // eax

v1 = a1 + 1;
v2 = func7(a1);
result = a1 + 1;
do
result += ++v1;
while ( v2 > result );
if ( v2 == result )
result = printf("EL NUMERO %d ES UN CENTRO NUMERICO \n", a1);
return result;
}

original_code:
void comprueba (int numero )
{
int centro = numero ;
int superiores = ++numero ;
do
 {
 numero++ ;
 superiores = superiores + numero ;
 }
while (superiores < inferiores (centro)) ;
if ( superiores ==inferiores (centro) )
 printf ("EL NUMERO %d ES UN CENTRO NUMERICO \n",centro);
}

canonical_original_code:
void comprueba(int numero)
{
int centro = numero;
int superiores = ++numero;
do
 {
 numero++ ;
 superiores = superiores + numero ;
 }
while (superiores < inferiores (centro)) ;
if ( superiores ==inferiores (centro) )
 printf ("EL NUMERO %d ES UN CENTRO NUMERICO \n",centro);
}

variable_types: numero int

variable_types: superiores int


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
bool v3; // zf
int result; // eax
unsigned int v5; // [rsp+Ch] [rbp-Ch]

printf("INTRODUCIR UN NUMERO N --->");
__isoc99_scanf();
do
{
comprueba(v5);
v3 = v5 == 1;
result = --v5;
}
while ( !v3 );
return result;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
bool v3; // zf
int result; // eax
unsigned int v5; // [rsp+Ch] [rbp-Ch]

printf("INTRODUCIR UN NUMERO N --->");
__isoc99_scanf();
do
{
func8(v5);
v3 = v5 == 1;
result = --v5;
}
while ( !v3 );
return result;
}

original_code:
void main (void)
{
int numero;
printf ("INTRODUCIR UN NUMERO N --->");
scanf ("%d",&numero);
do
 {
 comprueba (numero );
 numero -- ;
 }
while (numero != 0);
}

canonical_original_code:
void main()
{
int numero;
printf ("INTRODUCIR UN NUMERO N --->");
scanf ("%d",&numero);
do
 {
 comprueba (numero );
 numero -- ;
 }
while (numero != 0);
}


potencia

decompiled_code:
float __fastcall potencia(int a1, float result)
{
float v2; // xmm1_4

v2 = result;
if ( a1 <= 0 )
return 1.0;
if ( a1 > 1 )
{
do
{
result = result * v2;
--a1;
}
while ( a1 != 1 );
}
return result;
}

canonical_decompiled_code:
float __fastcall func7(int a1, float result)
{
float v2; // xmm1_4

v2 = result;
if ( a1 <= 0 )
return 1.0;
if ( a1 > 1 )
{
do
{
result = result * v2;
--a1;
}
while ( a1 != 1 );
}
return result;
}

original_code:
float potencia (float numero, int grado)
{
float potencia ;
if (grado>0)
 {
 for (potencia = numero ; grado > 1;grado --)
  potencia = potencia*numero;
 }
else
 potencia =1;
return (potencia);
}

canonical_original_code:
float potencia(float numero, int grado)
{
float potencia;
if (grado>0)
 {
 for (potencia = numero ; grado > 1;grado --)
  potencia = potencia*numero;
 }
else
 potencia =1;
return (potencia);
}

variable_types: numero float

variable_types: grado int

variable_types: potencia float

return_type: float


factorial

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

result = 1LL;
if ( a1 > 0 )
{
if ( a1 <= 1 )
{
result = (unsigned int)a1;
}
else
{
LODWORD(result) = a1;
do
result = (unsigned int)(--a1 * result);
while ( a1 != 1 );
}
}
return result;
}

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

result = 1LL;
if ( a1 > 0 )
{
if ( a1 <= 1 )
{
result = (unsigned int)a1;
}
else
{
LODWORD(result) = a1;
do
result = (unsigned int)(--a1 * result);
while ( a1 != 1 );
}
}
return result;
}

original_code:
int factorial (int grado)
{
int factorial ;
if (grado >0)
 for (factorial =grado;grado>1 ; )
  {
  grado --;
  factorial = factorial*grado;
  }
else
 factorial=1;
return (factorial);
}

canonical_original_code:
int factorial(int grado)
{
int factorial;
if (grado >0)
 for (factorial =grado;grado>1 ; )
  {
  grado --;
  factorial = factorial*grado;
  }
else
 factorial=1;
return (factorial);
}

variable_types: factorial int


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebp
int v4; // ebx
float v5; // xmm0_4
float v6; // xmm1_4
float v8; // [rsp+8h] [rbp-30h]
float v9; // [rsp+Ch] [rbp-2Ch]
float v10; // [rsp+1Ch] [rbp-1Ch]

printf("INTRODUZCA LA X --->");
__isoc99_scanf();
v3 = 1;
v4 = 0;
v8 = 0.0;
do
{
v9 = potencia(v4, v10);
v5 = v9 / (float)(int)factorial(v4);
v6 = (float)((float)v3 * v5) + v8;
v8 = v6;
v3 = -v3;
v4 += 2;
}
while ( v5 > 0.0005 );
return printf("EL COSENO DE X ES --->%f", v6);
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebp
int v4; // ebx
float v5; // xmm0_4
float v6; // xmm1_4
float v8; // [rsp+8h] [rbp-30h]
float v9; // [rsp+Ch] [rbp-2Ch]
float v10; // [rsp+1Ch] [rbp-1Ch]

printf("INTRODUZCA LA X --->");
__isoc99_scanf();
v3 = 1;
v4 = 0;
v8 = 0.0;
do
{
v9 = func7(v4, v10);
v5 = v9 / (float)(int)func8(v4);
v6 = (float)((float)v3 * v5) + v8;
v8 = v6;
v3 = -v3;
v4 += 2;
}
while ( v5 > 0.0005 );
return printf("EL COSENO DE X ES --->%f", v6);
}

original_code:
void main (void)
{
float numero;
float coseno = 0;
int grado = 0 ;
float termino;
int signo = 1 ;
printf ("INTRODUZCA LA X --->");
scanf ("%f",&numero);
do
 {
 termino= potencia (numero,grado)/factorial (grado) ;
 coseno = coseno + signo*termino ;
 signo = -signo ;
 grado = grado + 2 ;
 }
while (termino > 0.0005 );
printf ("EL COSENO DE X ES --->%f",coseno);
}

canonical_original_code:
void main()
{
float numero;
float coseno = 0;
int grado = 0;
float termino;
int signo = 1;
printf ("INTRODUZCA LA X --->");
scanf ("%f",&numero);
do
 {
 termino= potencia (numero,grado)/factorial (grado) ;
 coseno = coseno + signo*termino ;
 signo = -signo ;
 grado = grado + 2 ;
 }
while (termino > 0.0005 );
printf ("EL COSENO DE X ES --->%f",coseno);
}

variable_types: coseno float

variable_types: termino float

variable_types: signo int


suma

decompiled_code:
__int64 __fastcall suma(unsigned int *a1)
{
unsigned int *v1; // rax
int v2; // ebx

v1 = a1;
v2 = 0;
do
v2 += *v1++;
while ( v1 != a1 + 8 );
printf("\n%d LA SUMA ES %d", *a1, (unsigned int)v2);
for ( ; v2 > 10; v2 -= 10 )
;
return (unsigned int)v2;
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned int *a1)
{
unsigned int *v1; // rax
int v2; // ebx

v1 = a1;
v2 = 0;
do
v2 += *v1++;
while ( v1 != a1 + 8 );
printf("\n%d LA SUMA ES %d", *a1, (unsigned int)v2);
for ( ; v2 > 10; v2 -= 10 )
;
return (unsigned int)v2;
}

original_code:
int suma (int cuenta [])
{
int indi, suma;
for (indi=0, suma=0; indi+1<9; indi++)
 suma = suma + cuenta [indi];
printf ("\n%d      LA SUMA ES %d", cuenta [0], suma);
for (;suma>10;)
 suma=suma-10;
return (suma);
}

canonical_original_code:
int suma(int cuenta[])
{
int indi; int suma;
for (indi=0, suma=0; indi+1<9; indi++)
 suma = suma + cuenta [indi];
printf ("\n%d      LA SUMA ES %d", cuenta [0], suma);
for (;suma>10;)
 suma=suma-10;
return (suma);
}

variable_types:
cuenta
int []

variable_types: indi int

variable_types: suma int


resta

decompiled_code:
__int64 __fastcall resta(unsigned int *a1)
{
__int64 v1; // rsi
unsigned int *v2; // rax
unsigned int *v3; // rdi
__int64 v4; // rdx
unsigned int v5; // ebx
int v6; // ebp
__int64 result; // rax

v1 = *a1;
v2 = a1 + 1;
v3 = a1 + 8;
LODWORD(v4) = v1;
do
{
v5 = *v2;
v6 = v4;
v4 = (unsigned int)v4 - *v2++;
}
while ( v2 != v3 );
printf("\n%d LA RESTA ES %d", v1, v4);
for ( result = v5 - v6; (int)result > 10; result = (unsigned int)(result - 10) )
;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(unsigned int *a1)
{
__int64 v1; // rsi
unsigned int *v2; // rax
unsigned int *v3; // rdi
__int64 v4; // rdx
unsigned int v5; // ebx
int v6; // ebp
__int64 result; // rax

v1 = *a1;
v2 = a1 + 1;
v3 = a1 + 8;
LODWORD(v4) = v1;
do
{
v5 = *v2;
v6 = v4;
v4 = (unsigned int)v4 - *v2++;
}
while ( v2 != v3 );
printf("\n%d LA RESTA ES %d", v1, v4);
for ( result = v5 - v6; (int)result > 10; result = (unsigned int)(result - 10) )
;
return result;
}

original_code:
int resta (int cuenta [])
{
int indi, resta;
for (indi=1, resta =cuenta [0]; indi+1<9; indi++)
 resta = resta - cuenta [indi];
printf ("\n%d      LA RESTA ES %d", cuenta [0], resta);
resta = -resta;
for (;resta>10;)
 resta=resta-10;
return (resta);
}

canonical_original_code:
int resta(int cuenta[])
{
int indi; int resta;
for (indi=1, resta =cuenta [0]; indi+1<9; indi++)
 resta = resta - cuenta [indi];
printf ("\n%d      LA RESTA ES %d", cuenta [0], resta);
resta = -resta;
for (;resta>10;)
 resta=resta-10;
return (resta);
}

variable_types: resta int


multi

decompiled_code:
__int64 __fastcall multi(unsigned int *a1)
{
unsigned int *v1; // rax
int v2; // ebx

v1 = a1;
v2 = 1;
do
v2 *= *v1++;
while ( v1 != a1 + 8 );
printf("\n%d LA MULTIPLICACION ES %d", *a1, (unsigned int)v2);
for ( ; v2 > 10; v2 -= 10 )
;
return (unsigned int)v2;
}

canonical_decompiled_code:
__int64 __fastcall func9(unsigned int *a1)
{
unsigned int *v1; // rax
int v2; // ebx

v1 = a1;
v2 = 1;
do
v2 *= *v1++;
while ( v1 != a1 + 8 );
printf("\n%d LA MULTIPLICACION ES %d", *a1, (unsigned int)v2);
for ( ; v2 > 10; v2 -= 10 )
;
return (unsigned int)v2;
}

original_code:
int multi (int cuenta [])
{
int multi, indi;
for (indi=0, multi =1 ; indi+1<9; indi++)
 multi = multi * cuenta [indi];
printf ("\n%d      LA MULTIPLICACION ES %d", cuenta [0], multi);
for (;multi>10;)
 multi=multi-10;
return (multi);
}

canonical_original_code:
int multi(int cuenta[])
{
int multi; int indi;
for (indi=0, multi =1 ; indi+1<9; indi++)
 multi = multi * cuenta [indi];
printf ("\n%d      LA MULTIPLICACION ES %d", cuenta [0], multi);
for (;multi>10;)
 multi=multi-10;
return (multi);
}

variable_types: multi int


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int *v3; // rbx
char *v4; // rbp
int result; // eax
int v6; // ebx
int v7; // ebx
int v8; // ebx
int v9; // ebx
int v10; // ebx
int v11; // ebx
int v12; // ebx
int v13; // ebx
int v14; // ebx
unsigned int v15[8]; // [rsp+0h] [rbp-48h] BYREF
int v16; // [rsp+20h] [rbp-28h]
char v17[36]; // [rsp+24h] [rbp-24h] BYREF

v3 = v15;
v4 = (char *)v15;
do
{
__isoc99_scanf();
v4 += 4;
}
while ( v4 != v17 );
do
result = printf("%d", *v3++);
while ( v3 != (unsigned int *)v17 );
if ( v15[0] == 1 )
{
v6 = v16;
if ( v6 == (unsigned int)suma(v15) )
{
result = printf("\nLA CUENTA ES VALIDA");
}
else
{
v7 = v16;
if ( v7 == (unsigned int)resta(v15) || (v8 = v16, v8 == (unsigned int)multi(v15)) )
result = printf("\nEL CODIGO DE OPERACION ES INCORRECTO");
else
result = printf("\nLA CUENTA NO ES VALIDA");
}
}
if ( v15[0] == 2 )
{
v9 = v16;
if ( v9 == (unsigned int)resta(v15) )
{
result = printf("\nLA CUENTA ES VALIDA");
}
else
{
v10 = v16;
if ( v10 == (unsigned int)suma(v15) || (v11 = v16, v11 == (unsigned int)multi(v15)) )
result = printf("\nEL CODIGO DE OPERACION ES INCORRECTO");
else
result = printf("\nLA CUENTA NO ES VALIDA");
}
}
if ( v15[0] == 3 )
{
v12 = v16;
if ( v12 == (unsigned int)multi(v15) )
{
result = printf("\nLA CUENTA ES VALIDA");
}
else
{
v13 = v16;
if ( v13 == (unsigned int)resta(v15) || (v14 = v16, v14 == (unsigned int)suma(v15)) )
result = printf("\nEL CODIGO DE OPERACION ES INCORRECTO");
else
result = printf("\nLA CUENTA NO ES VALIDA");
}
}
return result;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int *v3; // rbx
char *v4; // rbp
int result; // eax
int v6; // ebx
int v7; // ebx
int v8; // ebx
int v9; // ebx
int v10; // ebx
int v11; // ebx
int v12; // ebx
int v13; // ebx
int v14; // ebx
unsigned int v15[8]; // [rsp+0h] [rbp-48h] BYREF
int v16; // [rsp+20h] [rbp-28h]
char v17[36]; // [rsp+24h] [rbp-24h] BYREF

v3 = v15;
v4 = (char *)v15;
do
{
__isoc99_scanf();
v4 += 4;
}
while ( v4 != v17 );
do
result = printf("%d", *v3++);
while ( v3 != (unsigned int *)v17 );
if ( v15[0] == 1 )
{
v6 = v16;
if ( v6 == (unsigned int)func7(v15) )
{
result = printf("\nLA CUENTA ES VALIDA");
}
else
{
v7 = v16;
if ( v7 == (unsigned int)func8(v15) || (v8 = v16, v8 == (unsigned int)func9(v15)) )
result = printf("\nEL CODIGO DE OPERACION ES INCORRECTO");
else
result = printf("\nLA CUENTA NO ES VALIDA");
}
}
if ( v15[0] == 2 )
{
v9 = v16;
if ( v9 == (unsigned int)func8(v15) )
{
result = printf("\nLA CUENTA ES VALIDA");
}
else
{
v10 = v16;
if ( v10 == (unsigned int)func7(v15) || (v11 = v16, v11 == (unsigned int)func9(v15)) )
result = printf("\nEL CODIGO DE OPERACION ES INCORRECTO");
else
result = printf("\nLA CUENTA NO ES VALIDA");
}
}
if ( v15[0] == 3 )
{
v12 = v16;
if ( v12 == (unsigned int)func9(v15) )
{
result = printf("\nLA CUENTA ES VALIDA");
}
else
{
v13 = v16;
if ( v13 == (unsigned int)func8(v15) || (v14 = v16, v14 == (unsigned int)func7(v15)) )
result = printf("\nEL CODIGO DE OPERACION ES INCORRECTO");
else
result = printf("\nLA CUENTA NO ES VALIDA");
}
}
return result;
}

original_code:
void main (void)
{
int indice;
int cuenta [9];
for (indice=0; indice<9; indice++)
 scanf ("%d", &cuenta [indice]);
for (indice=0; indice<9; indice++)
 printf ("%d", cuenta [indice]);
if (cuenta [0]==1)
 {
 if (cuenta [9 -1]==suma (cuenta ))
  printf ("\nLA CUENTA ES VALIDA");
 else
  {
  if (cuenta [9 -1]==resta (cuenta ) || cuenta [9 -1]== multi (cuenta ))
   printf ("\nEL CODIGO DE OPERACION ES INCORRECTO");
  else
   printf ("\nLA CUENTA NO ES VALIDA");
  }
 }
if (cuenta [0]==2)
 {
 if (cuenta [9 -1]==resta (cuenta ))
  printf ("\nLA CUENTA ES VALIDA");
 else
  {
  if (cuenta [9 -1]==suma (cuenta ) || cuenta [9 -1]== multi (cuenta ))
   printf ("\nEL CODIGO DE OPERACION ES INCORRECTO");
  else
   printf ("\nLA CUENTA NO ES VALIDA");
  }
 }
if (cuenta [0]==3)
 {
 if (cuenta [9 -1]==multi (cuenta ))
  printf ("\nLA CUENTA ES VALIDA");
 else
  {
  if (cuenta [9 -1]==resta (cuenta ) || cuenta [9 -1]== suma (cuenta ))
   printf ("\nEL CODIGO DE OPERACION ES INCORRECTO");
  else
   printf ("\nLA CUENTA NO ES VALIDA");
  }
 }
}

canonical_original_code:
void main()
{
int indice;
int cuenta[9];
for (indice=0; indice<9; indice++)
 scanf ("%d", &cuenta [indice]);
for (indice=0; indice<9; indice++)
 printf ("%d", cuenta [indice]);
if (cuenta [0]==1)
 {
 if (cuenta [9 -1]==suma (cuenta ))
  printf ("\nLA CUENTA ES VALIDA");
 else
  {
  if (cuenta [9 -1]==resta (cuenta ) || cuenta [9 -1]== multi (cuenta ))
   printf ("\nEL CODIGO DE OPERACION ES INCORRECTO");
  else
   printf ("\nLA CUENTA NO ES VALIDA");
  }
 }
if (cuenta [0]==2)
 {
 if (cuenta [9 -1]==resta (cuenta ))
  printf ("\nLA CUENTA ES VALIDA");
 else
  {
  if (cuenta [9 -1]==suma (cuenta ) || cuenta [9 -1]== multi (cuenta ))
   printf ("\nEL CODIGO DE OPERACION ES INCORRECTO");
  else
   printf ("\nLA CUENTA NO ES VALIDA");
  }
 }
if (cuenta [0]==3)
 {
 if (cuenta [9 -1]==multi (cuenta ))
  printf ("\nLA CUENTA ES VALIDA");
 else
  {
  if (cuenta [9 -1]==resta (cuenta ) || cuenta [9 -1]== suma (cuenta ))
   printf ("\nEL CODIGO DE OPERACION ES INCORRECTO");
  else
   printf ("\nLA CUENTA NO ES VALIDA");
  }
 }
}

variable_types: indice int

variable_types:
cuenta
int [9]


decompiled_code:
void *crea_array()
{
char *v0; // rbx

v0 = (char *)&array_0;
do
{
__isoc99_scanf();
v0 += 4;
}
while ( v0 != (char *)&end );
return &array_0;
}

canonical_decompiled_code:
void *func7()
{
char *v0; // rbx

v0 = (char *)&array_0;
do
{
__isoc99_scanf();
v0 += 4;
}
while ( v0 != (char *)&end );
return &array_0;
}

original_code:
int *crea_array(void) {
  static int array[10];
  int indice = 0;
  do {
    scanf("%d", &array[indice++]);
  } while (indice < 10);
  return array;
}

canonical_original_code:
int *crea_array() {
  static int array[10];
  int indice = 0;
  do {
    scanf("%d", &array[indice++]);
  } while (indice < 10);
  return array;
}

variable_types:
array
int [10]

return_type: int *


decompiled_code:
int __fastcall visualiza_array(unsigned int *a1)
{
unsigned int *v1; // rbx
int result; // eax

v1 = a1;
do
result = printf("%6d", *v1++);
while ( v1 != a1 + 10 );
return result;
}

canonical_decompiled_code:
int __fastcall func8(unsigned int *a1)
{
unsigned int *v1; // rbx
int result; // eax

v1 = a1;
do
result = printf("%6d", *v1++);
while ( v1 != a1 + 10 );
return result;
}

original_code:
void visualiza_array(int numeros[]) {
  int indice;
  for (indice = 0; indice < 10; indice++) {
    printf("%6d", *(numeros + indice));
  }
}

variable_types:
numeros
int []


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

v3 = (unsigned int *)crea_array();
return visualiza_array(v3);
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int *v3; // rax

v3 = (unsigned int *)func7();
return func8(v3);
}

original_code:
void main(void) {
  int *puntero;
  puntero = crea_array();
  visualiza_array(puntero);
}

canonical_original_code:
void main() {
  int *puntero;
  puntero = crea_array();
  visualiza_array(puntero);
}

variable_types:
puntero
int *


estrella

original_code:
float estrella (int cielo [] [20],int indice1,int indice2)
{
float suma;
 suma= cielo [indice1+1] [indice2] + cielo [indice1-1] [indice2] + cielo [indice1] [indice2] +
 cielo [indice1+1] [indice2+1] + cielo [indice1-1] [indice2+1] + cielo [indice1] [indice2+1] +
 cielo [indice1+1] [indice2-1] + cielo [indice1-1] [indice2-1] + cielo [indice1] [indice2-1];
return (suma);
}

canonical_original_code:
float estrella(int cielo[][20], int indice1, int indice2)
{
float suma;
 suma= cielo [indice1+1] [indice2] + cielo [indice1-1] [indice2] + cielo [indice1] [indice2] +
 cielo [indice1+1] [indice2+1] + cielo [indice1-1] [indice2+1] + cielo [indice1] [indice2+1] +
 cielo [indice1+1] [indice2-1] + cielo [indice1-1] [indice2-1] + cielo [indice1] [indice2-1];
return (suma);
}

variable_types:
cielo
int [][20]

variable_types: suma float


decompiled_code:
int __fastcall introduce_array(__int64 a1, int *a2, int *a3)
{
int result; // eax
int v5; // er15
int i; // ebx

do
{
printf("INTRODUZCA EL NUMERO DE COLUMNAS --->");
__isoc99_scanf();
}
while ( *a3 > 20 );
do
{
printf("INTRODUZCA EL NUMERO DE FILAS --->");
__isoc99_scanf();
}
while ( *a2 > 20 );
result = puts("\nINTRODUZCA LOS ELEMENTOS DEL ARRAY");
if ( *a2 > 0 )
{
v5 = 0;
do
{
for ( i = 0; *a3 > i; ++i )
{
result = __isoc99_scanf();
if ( *(_DWORD *)(a1 + 4LL * i) > 0x14u )
{
result = printf("VALOR NO VALIDO. INTRODUZCA OTRO");
--i;
}
}
++v5;
a1 += 80LL;
}
while ( *a2 > v5 );
}
return result;
}

canonical_decompiled_code:
int __fastcall func7(__int64 a1, int *a2, int *a3)
{
int result; // eax
int v5; // er15
int i; // ebx

do
{
printf("INTRODUZCA EL NUMERO DE COLUMNAS --->");
__isoc99_scanf();
}
while ( *a3 > 20 );
do
{
printf("INTRODUZCA EL NUMERO DE FILAS --->");
__isoc99_scanf();
}
while ( *a2 > 20 );
result = puts("\nINTRODUZCA LOS ELEMENTOS DEL ARRAY");
if ( *a2 > 0 )
{
v5 = 0;
do
{
for ( i = 0; *a3 > i; ++i )
{
result = __isoc99_scanf();
if ( *(_DWORD *)(a1 + 4LL * i) > 0x14u )
{
result = printf("VALOR NO VALIDO. INTRODUZCA OTRO");
--i;
}
}
++v5;
a1 += 80LL;
}
while ( *a2 > v5 );
}
return result;
}

original_code:
void introduce_array (int cielo [] [20],int *filas, int *columnas)
{
int indice1, indice2;
do
 {
 printf ("INTRODUZCA EL NUMERO DE COLUMNAS --->");
 scanf ("%d",columnas);
 }
while (*columnas>20);
do
 {
 printf ("INTRODUZCA EL NUMERO DE FILAS --->");
 scanf ("%d",filas);
 }
while (*filas>20);
printf ("\nINTRODUZCA LOS ELEMENTOS DEL ARRAY\n");
for (indice1=0; indice1<*filas; indice1++)
 for (indice2=0; indice2<*columnas; indice2++)
  {
  scanf ("%d",&cielo [indice1] [indice2]);
  if (cielo [indice1] [indice2]<0 || cielo [indice1] [indice2]>20)
   {
   printf ("VALOR NO VALIDO. INTRODUZCA OTRO");
   indice2--;
   }
  }
}

canonical_original_code:
void introduce_array(int cielo[][20], int *filas, int *columnas)
{
int indice1; int indice2;
do
 {
 printf ("INTRODUZCA EL NUMERO DE COLUMNAS --->");
 scanf ("%d",columnas);
 }
while (*columnas>20);
do
 {
 printf ("INTRODUZCA EL NUMERO DE FILAS --->");
 scanf ("%d",filas);
 }
while (*filas>20);
printf ("\nINTRODUZCA LOS ELEMENTOS DEL ARRAY\n");
for (indice1=0; indice1<*filas; indice1++)
 for (indice2=0; indice2<*columnas; indice2++)
  {
  scanf ("%d",&cielo [indice1] [indice2]);
  if (cielo [indice1] [indice2]<0 || cielo [indice1] [indice2]>20)
   {
   printf ("VALOR NO VALIDO. INTRODUZCA OTRO");
   indice2--;
   }
  }
}

variable_types:
filas
int *

variable_types:
columnas
int *


main

original_code:
void main (void)
{
int cielo [20] [20];
char plano [20] [20];
int filas, columnas;
int indice1, indice2;
introduce_array (cielo, &filas, &columnas);
for (indice1=0; indice1<filas; indice1++)
 for (indice2=0; indice2<columnas; indice2++)
  {
  if (indice1==0 || indice1==filas-1 || indice2==0 || indice2==columnas-1)
   plano [indice1] [indice2]=' ';
  if (indice1!=0 && indice1!=filas-1 && indice2!=0 && indice2!=columnas-1)
   {
   if (estrella (cielo , indice1, indice2)/9>6.0)
    plano [indice1] [indice2]='*';
   else
    plano [indice1] [indice2]='.';
   }
  }
for (indice1=0; indice1<filas; indice1++)
 {
 printf ("\n");
 for (indice2=0; indice2<columnas; indice2++)
  printf ("  %c",plano [indice1] [indice2]);
 }
}

canonical_original_code:
void main()
{
int cielo[20][20];
char plano[20][20];
int filas; int columnas;
int indice1; int indice2;
introduce_array (cielo, &filas, &columnas);
for (indice1=0; indice1<filas; indice1++)
 for (indice2=0; indice2<columnas; indice2++)
  {
  if (indice1==0 || indice1==filas-1 || indice2==0 || indice2==columnas-1)
   plano [indice1] [indice2]=' ';
  if (indice1!=0 && indice1!=filas-1 && indice2!=0 && indice2!=columnas-1)
   {
   if (estrella (cielo , indice1, indice2)/9>6.0)
    plano [indice1] [indice2]='*';
   else
    plano [indice1] [indice2]='.';
   }
  }
for (indice1=0; indice1<filas; indice1++)
 {
 printf ("\n");
 for (indice2=0; indice2<columnas; indice2++)
  printf ("  %c",plano [indice1] [indice2]);
 }
}

variable_types:
cielo
int [20][20]

variable_types:
plano
char [20][20]

variable_types: filas int

variable_types: columnas int


mayusculas

decompiled_code:
const char *__fastcall mayusculas(const char *a1)
{
const char *result; // rax
int v2; // edx

result = (const char *)strlen(a1);
if ( (int)result > 0 )
{
v2 = (int)result;
result = a1;
do
{
if ( (unsigned __int8)(*result - 97) <= 0x19u )
*result -= 32;
++result;
}
while ( result != &a1[v2 - 1 + 1] );
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func8(const char *a1)
{
const char *result; // rax
int v2; // edx

result = (const char *)strlen(a1);
if ( (int)result > 0 )
{
v2 = (int)result;
result = a1;
do
{
if ( (unsigned __int8)(*result - 97) <= 0x19u )
*result -= 32;
++result;
}
while ( result != &a1[v2 - 1 + 1] );
}
return result;
}

original_code:
void mayusculas(char cadena[]) {
  int indice, num_elem;
  num_elem = strlen(cadena);
  for (indice = 0; indice < num_elem; indice ++) {
  if (cadena[indice] >= 97 && cadena[indice] <= 122) {
    cadena[indice] = cadena[indice] - 32;
   }
 }
}

canonical_original_code:
void mayusculas(char cadena[]) {
  int indice; int num_elem;
  num_elem = strlen(cadena);
  for (indice = 0; indice < num_elem; indice ++) {
  if (cadena[indice] >= 97 && cadena[indice] <= 122) {
    cadena[indice] = cadena[indice] - 32;
   }
 }
}

variable_types:
cadena
char []


comprueba

decompiled_code:
int __fastcall comprueba(const char *a1)
{
__int64 v1; // rax
__int64 v2; // rdx
int v3; // ecx
int result; // eax

LODWORD(v1) = strlen(a1) - 1;
if ( (int)v1 < 0 )
goto LABEL_8;
v1 = (int)v1;
v2 = 0LL;
v3 = 1;
do
{
if ( a1[v2] != a1[v1] )
v3 = 0;
++v2;
--v1;
}
while ( (int)v2 <= (int)v1 );
if ( v3 )
LABEL_8:
result = printf("\n\nES UN PALINDROMO");
else
result = printf("\n\nNO ES UN PALINDROMO");
return result;
}

canonical_decompiled_code:
int __fastcall func9(const char *a1)
{
__int64 v1; // rax
__int64 v2; // rdx
int v3; // ecx
int result; // eax

LODWORD(v1) = strlen(a1) - 1;
if ( (int)v1 < 0 )
goto LABEL_8;
v1 = (int)v1;
v2 = 0LL;
v3 = 1;
do
{
if ( a1[v2] != a1[v1] )
v3 = 0;
++v2;
--v1;
}
while ( (int)v2 <= (int)v1 );
if ( v3 )
LABEL_8:
result = printf("\n\nES UN PALINDROMO");
else
result = printf("\n\nNO ES UN PALINDROMO");
return result;
}

original_code:
void comprueba(char cadena []) {
  int indice_1, indice_2, comprueba = 1;
  indice_2 = strlen(cadena) - 1;
  for (indice_1 = 0; indice_1 <= indice_2; indice_1++, indice_2--) {
    if (cadena[indice_1] != cadena[indice_2]) {
    comprueba = 0;
   }
  }
  if (comprueba) {
    printf("\n\nES UN PALINDROMO");
  } else {
    printf("\n\nNO ES UN PALINDROMO");
  }
}

canonical_original_code:
void comprueba(char cadena[]) {
  int indice_1; int indice_2; int comprueba = 1;
  indice_2 = strlen(cadena) - 1;
  for (indice_1 = 0; indice_1 <= indice_2; indice_1++, indice_2--) {
    if (cadena[indice_1] != cadena[indice_2]) {
    comprueba = 0;
   }
  }
  if (comprueba) {
    printf("\n\nES UN PALINDROMO");
  } else {
    printf("\n\nNO ES UN PALINDROMO");
  }
}

variable_types: comprueba int


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char v4[120]; // [rsp+0h] [rbp-78h] BYREF

introduce(v4);
puts(v4);
mayusculas(v4);
puts(v4);
puts(v4);
return comprueba(v4);
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char v4[120]; // [rsp+0h] [rbp-78h] BYREF

func7(v4);
puts(v4);
func8(v4);
puts(v4);
puts(v4);
return func9(v4);
}

original_code:
void main (void) {
  char cadena [100];
  introduce(cadena);
  puts(cadena);
  mayusculas(cadena);
  puts(cadena);
  puts(cadena);
  comprueba(cadena);
}

canonical_original_code:
void main() {
  char cadena[100];
  introduce(cadena);
  puts(cadena);
  mayusculas(cadena);
  puts(cadena);
  puts(cadena);
  comprueba(cadena);
}

variable_types:
cadena
char [100]


repo: jreisinger/hithere

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

if ( argc == 1 )
{
puts("hi there, world!");
}
else
{
printf("hi there");
if ( argc > 1 )
{
v3 = argv + 1;
do
printf(", %s", *v3++);
while ( v3 != &argv[(unsigned int)(argc - 2) + 2] );
}
putchar(10);
}
return 0;
}

original_code:
int main(int argc, char **argv)
{
    if (argc == 1)
        printf("hi there, world!\n");
    else {
        printf("hi there");
        for (int i = 1; i < argc; ++i)
            printf(", %s", argv[i]);
        printf("\n");
    }
    return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: i int


repo: jrenner/renbits

original_code:
void dec_to_bin(long n){
    int num_of_bits;
    if(n < 128 && n >= -128)
        num_of_bits = 8;
    else if(n < 32768 && n >= -32768)
        num_of_bits = 16;
    else if(n < 8388608 && n >= -8388608)
        num_of_bits = 24;
    else if(n < 2147483648 && n >= -2147483648)
        num_of_bits = 32;
    else{
        printf("Number out of bounds: %ld\n", n);
        exit(1);
    }
    int spaces = (num_of_bits / 4) - 1;
    int j = num_of_bits - 1;
    long check = 1;
    for(;j > 0; j--)
        check = check << 1;
    char *buff = malloc(sizeof(char) * (num_of_bits + 1 + spaces));
    int i = 0;
    while(check)
    {
        if ((i % 5) == 0)
            buff[i++] = ' ';
        if(n & check){
            buff[i++] = '1';
        }
        else
            buff[i++] = '0';
        check = check>>1;
    }
    buff[i]= '\0';
    printf("%40s -> %d-BIT integer: %ld", buff, num_of_bits, n);
    if(n >= 0 && n <= 255)
        printf(" char: %c", (int)n);
    printf("\n");
    free(buff);
}

variable_types: n long

variable_types: spaces int

variable_types: j int

variable_types: check long

variable_types:
buff
char *


decompiled_code:
void __fastcall run_bitwise_operation(char *s1, signed __int64 a2, unsigned __int64 a3, int a4)
{
__int64 v6; // r14
unsigned int v7; // ebx
const char *v8; // r15

if ( !strcasecmp(s1, "and") || !strcasecmp(s1, "&") )
{
v6 = a2 & a3;
v7 = 0;
v8 = "AND &";
LABEL_4:
dec_to_bin(a2);
if ( a4 == 3 && !v7 )
{
dec_to_bin(a3);
}
else
{
if ( a4 <= 1 )
return;
if ( v7 )
{
printf("%48s (%d)\n", v8, v7);
LABEL_9:
dec_to_bin(v6);
return;
}
}
printf("%48s\n", v8);
goto LABEL_9;
}
if ( !strcasecmp(s1, "or") || !strcasecmp(s1, "|") )
{
v6 = a2 | a3;
v7 = 0;
v8 = "OR |";
goto LABEL_4;
}
if ( !strcasecmp(s1, "xor") || !strcasecmp(s1, "^") )
{
v6 = a2 ^ a3;
v7 = 0;
v8 = "XOR ^";
goto LABEL_4;
}
if ( !strcasecmp(s1, "twiddle") || !strcasecmp(s1, "~") )
{
v6 = ~a2;
v7 = 0;
v8 = "TWIDDLE ~";
goto LABEL_4;
}
if ( !strcasecmp(s1, "rshift") || !strcasecmp(s1, ">>") )
{
v6 = a2 >> a3;
v7 = a3;
v8 = "RSHIFT >>";
goto LABEL_4;
}
if ( !strcasecmp(s1, "lshift") || !strcasecmp(s1, "<<") )
{
v6 = a2 << a3;
v7 = a3;
v8 = "LSHIFT <<";
goto LABEL_4;
}
if ( a4 > 1 )
{
printf("Unhandled bitwise operator word argument: %s\n", s1);
exit(1);
}
dec_to_bin(a2);
}

canonical_decompiled_code:
void __fastcall func9(char *s1, signed __int64 a2, unsigned __int64 a3, int a4)
{
__int64 v6; // r14
unsigned int v7; // ebx
const char *v8; // r15

if ( !strcasecmp(s1, "and") || !strcasecmp(s1, "&") )
{
v6 = a2 & a3;
v7 = 0;
v8 = "AND &";
LABEL_4:
func8(a2);
if ( a4 == 3 && !v7 )
{
func8(a3);
}
else
{
if ( a4 <= 1 )
return;
if ( v7 )
{
printf("%48s (%d)\n", v8, v7);
LABEL_9:
func8(v6);
return;
}
}
printf("%48s\n", v8);
goto LABEL_9;
}
if ( !strcasecmp(s1, "or") || !strcasecmp(s1, "|") )
{
v6 = a2 | a3;
v7 = 0;
v8 = "OR |";
goto LABEL_4;
}
if ( !strcasecmp(s1, "xor") || !strcasecmp(s1, "^") )
{
v6 = a2 ^ a3;
v7 = 0;
v8 = "XOR ^";
goto LABEL_4;
}
if ( !strcasecmp(s1, "twiddle") || !strcasecmp(s1, "~") )
{
v6 = ~a2;
v7 = 0;
v8 = "TWIDDLE ~";
goto LABEL_4;
}
if ( !strcasecmp(s1, "rshift") || !strcasecmp(s1, ">>") )
{
v6 = a2 >> a3;
v7 = a3;
v8 = "RSHIFT >>";
goto LABEL_4;
}
if ( !strcasecmp(s1, "lshift") || !strcasecmp(s1, "<<") )
{
v6 = a2 << a3;
v7 = a3;
v8 = "LSHIFT <<";
goto LABEL_4;
}
if ( a4 > 1 )
{
printf("Unhandled bitwise operator word argument: %s\n", s1);
exit(1);
}
func8(a2);
}

original_code:
void run_bitwise_operation(char *word, long num1,
                         long num2, int num_of_args){
    long result = 0;
    char *opname;
    int shift = 0;
    if (strcasecmp(word, "and") == 0 || strcasecmp(word, "&") == 0){
        result = num1 & num2;
        opname = "AND &";
    }
    else if (strcasecmp(word, "or") == 0 || strcasecmp(word, "|") == 0){
        result = num1 | num2;
        opname = "OR |";
    }
    else if (strcasecmp(word, "xor") == 0 || strcasecmp(word, "^") == 0){
        result = num1 ^ num2;
        opname = "XOR ^";
    }
    else if (strcasecmp(word, "twiddle") == 0 || strcasecmp(word, "~") == 0){
        result = ~num1;
        opname = "TWIDDLE ~";
    }
    else if (strcasecmp(word, "rshift") == 0 || strcasecmp(word, ">>") == 0){
        result = num1 >> num2;
        opname = "RSHIFT >>";
        shift = num2;
    }
    else if (strcasecmp(word, "lshift") == 0 || strcasecmp(word, "<<") == 0){
        result = num1 << num2;
        opname = "LSHIFT <<";
        shift = num2;
    }
    else{
        if(num_of_args > 1){
            printf("Unhandled bitwise operator word argument: %s\n", word);
            exit(1);
        }
    }
    dec_to_bin(num1);
    if (num_of_args == 3 && !shift)
        dec_to_bin(num2);
    if (num_of_args > 1){
        if(shift)
            printf("%48s (%d)\n", opname, shift);
        else
            printf("%48s\n", opname);
        dec_to_bin(result);
    }
}

variable_types:
word
char *

variable_types: result long

variable_types:
opname
char *

variable_types: shift int


variable_types:
word
char [40]

variable_types:
buff
char [100]


repo: jrjohansson/qdpack

decompiled_code:
void __fastcall qdpack_matrix_free(void *ptr)
{
if ( ptr )
{
gsl_matrix_complex_free(*((_QWORD *)ptr + 1));
free(ptr);
}
else
{
fprintf(stderr, "%s: ERROR: mat is NULL\n", "qdpack_matrix_free");
}
}

canonical_decompiled_code:
void __fastcall func0(void *ptr)
{
if ( ptr )
{
gsl_matrix_complex_free(*((_QWORD *)ptr + 1));
free(ptr);
}
else
{
fprintf(stderr, "%s: ERROR: mat is NULL\n", "qdpack_matrix_free");
}
}

original_code:
void
qdpack_matrix_free(qdpack_matrix_t *mat)
{
    if (mat == ((void *)0))
    {
        fprintf(stderr, "%s: ERROR: mat is NULL\n", __PRETTY_FUNCTION__);
        return;
    }
    gsl_matrix_complex_free(mat->data);
    free(mat);
}

canonical_original_code:
void qdpack_matrix_free(struct _qdpack_matrix *mat)
{
    if (mat == ((void *)0))
    {
        fprintf(stderr, "%s: ERROR: mat is NULL\n", __PRETTY_FUNCTION__);
        return;
    }
    gsl_matrix_complex_free(mat->data);
    free(mat);
}

variable_types: struct _qdpack_matrix { int n; struct gsl_matrix_complex { unsigned long size1; unsigned long size2; unsigned long tda; double *data; struct gsl_block_complex_struct { unsigned long size; double *data; } *block; int owner; } *data; } *

user_defined_types: struct _qdpack_matrix { int n; struct gsl_matrix_complex *data; }

user_defined_types: struct gsl_matrix_complex { unsigned long size1; unsigned long size2; unsigned long tda; double *data; struct gsl_block_complex_struct *block; int owner; }


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

if ( a1 )
result = gsl_matrix_complex_get(*(_QWORD *)(a1 + 8));
else
result = gsl_complex_rect(0.0);
return result;
}

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

if ( a1 )
result = gsl_matrix_complex_get(*(_QWORD *)(a1 + 8));
else
result = gsl_complex_rect(0.0);
return result;
}

original_code:
gsl_complex
qdpack_matrix_get(qdpack_matrix_t *mat, size_t i, size_t j)
{
    if (mat == ((void *)0))
        return (gsl_complex_rect(0.0,0.0));
    return gsl_matrix_complex_get(mat->data, i, j);
}

canonical_original_code:
struct gsl_complex qdpack_matrix_get(struct _qdpack_matrix *mat, unsigned long i, unsigned long j)
{
    if (mat == ((void *)0))
        return (gsl_complex_rect(0.0,0.0));
    return gsl_matrix_complex_get(mat->data, i, j);
}

variable_types:
i
unsigned long

variable_types:
j
unsigned long

return_type: struct gsl_complex { double dat[2]; }

user_defined_types: struct gsl_block_complex_struct { unsigned long size; double *data; }


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

if ( a1 )
result = gsl_matrix_complex_set(*(_QWORD *)(a1 + 8));
return result;
}

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

if ( a1 )
result = gsl_matrix_complex_set(*(_QWORD *)(a1 + 8));
return result;
}

original_code:
void
qdpack_matrix_set(qdpack_matrix_t *mat, size_t i, size_t j, gsl_complex value)
{
    if (mat == ((void *)0))
        return;
    return gsl_matrix_complex_set(mat->data, i, j, value);
}

canonical_original_code:
void qdpack_matrix_set(struct _qdpack_matrix *mat, unsigned long i, unsigned long j, struct gsl_complex value)
{
    if (mat == ((void *)0))
        return;
    return gsl_matrix_complex_set(mat->data, i, j, value);
}

variable_types:
value
struct gsl_complex { double dat[2]; }


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

if ( a1 )
result = gsl_matrix_complex_set_all(*(_QWORD *)(a1 + 8));
return result;
}

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

if ( a1 )
result = gsl_matrix_complex_set_all(*(_QWORD *)(a1 + 8));
return result;
}

original_code:
void
qdpack_matrix_set_all(qdpack_matrix_t *mat, gsl_complex value)
{
    if (mat == ((void *)0))
        return;
    return gsl_matrix_complex_set_all(mat->data, value);
}

canonical_original_code:
void qdpack_matrix_set_all(struct _qdpack_matrix *mat, struct gsl_complex value)
{
    if (mat == ((void *)0))
        return;
    return gsl_matrix_complex_set_all(mat->data, value);
}


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

if ( a1 )
result = gsl_matrix_complex_set_zero(*(_QWORD *)(a1 + 8));
return result;
}

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

if ( a1 )
result = gsl_matrix_complex_set_zero(*(_QWORD *)(a1 + 8));
return result;
}

original_code:
void
qdpack_matrix_set_zero(qdpack_matrix_t *mat)
{
    if (mat == ((void *)0))
        return;
    return gsl_matrix_complex_set_zero(mat->data);
}

canonical_original_code:
void qdpack_matrix_set_zero(struct _qdpack_matrix *mat)
{
    if (mat == ((void *)0))
        return;
    return gsl_matrix_complex_set_zero(mat->data);
}


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

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

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

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

original_code:
void
qdpack_matrix_set_identity(qdpack_matrix_t *mat)
{
    if (mat && mat->data)
    {
        gsl_matrix_complex_set_identity(mat->data);
    }
}

canonical_original_code:
void qdpack_matrix_set_identity(struct _qdpack_matrix *mat)
{
    if (mat && mat->data)
    {
        gsl_matrix_complex_set_identity(mat->data);
    }
}


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

if ( a2 )
{
if ( a1 )
{
*(_DWORD *)a1 = *(_DWORD *)a2;
*(_DWORD *)(a1 + 4) = *(_DWORD *)(a2 + 4);
result = gsl_matrix_complex_memcpy(*(_QWORD *)(a1 + 8), *(_QWORD *)(a2 + 8));
}
}
return result;
}

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

if ( a2 )
{
if ( a1 )
{
*(_DWORD *)a1 = *(_DWORD *)a2;
*(_DWORD *)(a1 + 4) = *(_DWORD *)(a2 + 4);
result = gsl_matrix_complex_memcpy(*(_QWORD *)(a1 + 8), *(_QWORD *)(a2 + 8));
}
}
return result;
}

original_code:
void
qdpack_matrix_memcpy(qdpack_matrix_t *dst, qdpack_matrix_t *src)
{
    if (src == ((void *)0) || dst == ((void *)0))
        return;
    dst->n = src->n;
    dst->m = src->m;
    gsl_matrix_complex_memcpy(dst->data, src->data);
}

canonical_original_code:
void qdpack_matrix_memcpy(struct _qdpack_matrix *dst, struct _qdpack_matrix *src)
{
    if (src == ((void *)0) || dst == ((void *)0))
        return;
    dst->n = src->n;
    dst->m = src->m;
    gsl_matrix_complex_memcpy(dst->data, src->data);
}

variable_types:
src
struct _qdpack_matrix *


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

if ( a1 )
result = gsl_matrix_complex_scale(*(_QWORD *)(a1 + 8));
return result;
}

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

if ( a1 )
result = gsl_matrix_complex_scale(*(_QWORD *)(a1 + 8));
return result;
}

original_code:
void
qdpack_matrix_scale(qdpack_matrix_t *op, gsl_complex z)
{
    if (op == ((void *)0))
        return;
    gsl_matrix_complex_scale(op->data, z);
}

canonical_original_code:
void qdpack_matrix_scale(struct _qdpack_matrix *op, struct gsl_complex z)
{
    if (op == ((void *)0))
        return;
    gsl_matrix_complex_scale(op->data, z);
}

variable_types:
z
struct gsl_complex { double dat[2]; }


decompiled_code:
int __fastcall qdpack_matrix_add(__int64 a1, __int64 a2)
{
int result; // eax

if ( a1 && a2 )
result = gsl_matrix_complex_add(*(_QWORD *)(a1 + 8), *(_QWORD *)(a2 + 8));
else
result = fprintf(stderr, "%s: ERROR: op1 or op2 is NULL\n", "qdpack_matrix_add");
return result;
}

canonical_decompiled_code:
int __fastcall func8(__int64 a1, __int64 a2)
{
int result; // eax

if ( a1 && a2 )
result = gsl_matrix_complex_add(*(_QWORD *)(a1 + 8), *(_QWORD *)(a2 + 8));
else
result = fprintf(stderr, "%s: ERROR: op1 or op2 is NULL\n", "qdpack_matrix_add");
return result;
}

original_code:
void
qdpack_matrix_add(qdpack_matrix_t *op1, qdpack_matrix_t *op2)
{
    if (op1 == ((void *)0) || op2 == ((void *)0))
    {
        fprintf(stderr, "%s: ERROR: op1 or op2 is NULL\n", __PRETTY_FUNCTION__);
        return;
    }
    gsl_matrix_complex_add(op1->data, op2->data);
}

canonical_original_code:
void qdpack_matrix_add(struct _qdpack_matrix *op1, struct _qdpack_matrix *op2)
{
    if (op1 == ((void *)0) || op2 == ((void *)0))
    {
        fprintf(stderr, "%s: ERROR: op1 or op2 is NULL\n", __PRETTY_FUNCTION__);
        return;
    }
    gsl_matrix_complex_add(op1->data, op2->data);
}


decompiled_code:
int __fastcall qdpack_matrix_sub(__int64 a1, __int64 a2)
{
int result; // eax

if ( a1 && a2 )
result = gsl_matrix_complex_sub(*(_QWORD *)(a1 + 8), *(_QWORD *)(a2 + 8));
else
result = fprintf(stderr, "%s: ERROR: op1 or op2 is NULL\n", "qdpack_matrix_sub");
return result;
}

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

if ( a1 && a2 )
result = gsl_matrix_complex_sub(*(_QWORD *)(a1 + 8), *(_QWORD *)(a2 + 8));
else
result = fprintf(stderr, "%s: ERROR: op1 or op2 is NULL\n", "qdpack_matrix_sub");
return result;
}

original_code:
void
qdpack_matrix_sub(qdpack_matrix_t *op1, qdpack_matrix_t *op2)
{
    if (op1 == ((void *)0) || op2 == ((void *)0))
    {
        fprintf(stderr, "%s: ERROR: op1 or op2 is NULL\n", __PRETTY_FUNCTION__);
        return;
    }
    gsl_matrix_complex_sub(op1->data, op2->data);
}

canonical_original_code:
void qdpack_matrix_sub(struct _qdpack_matrix *op1, struct _qdpack_matrix *op2)
{
    if (op1 == ((void *)0) || op2 == ((void *)0))
    {
        fprintf(stderr, "%s: ERROR: op1 or op2 is NULL\n", __PRETTY_FUNCTION__);
        return;
    }
    gsl_matrix_complex_sub(op1->data, op2->data);
}


decompiled_code:
int __fastcall qdpack_matrix_blas_zgemm(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
__int64 v5; // rdx
__int64 v6; // rcx
int result; // eax

if ( a3 && (v5 = *(_QWORD *)(a3 + 8), a4) && v5 && (v6 = *(_QWORD *)(a4 + 8), a5) && v6 && *(_QWORD *)(a5 + 8) )
result = gsl_blas_zgemm();
else
result = fprintf(stderr, "%s: ERROR: NULL valued operator\n", "qdpack_matrix_blas_zgemm");
return result;
}

canonical_decompiled_code:
int __fastcall func10(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
__int64 v5; // rdx
__int64 v6; // rcx
int result; // eax

if ( a3 && (v5 = *(_QWORD *)(a3 + 8), a4) && v5 && (v6 = *(_QWORD *)(a4 + 8), a5) && v6 && *(_QWORD *)(a5 + 8) )
result = gsl_blas_zgemm();
else
result = fprintf(stderr, "%s: ERROR: NULL valued operator\n", "qdpack_matrix_blas_zgemm");
return result;
}

original_code:
void
qdpack_matrix_blas_zgemm(CBLAS_TRANSPOSE_t transA,
                         CBLAS_TRANSPOSE_t transB,
                         gsl_complex alpha,
                         qdpack_matrix_t *A,
                         qdpack_matrix_t *B,
                         gsl_complex beta,
                         qdpack_matrix_t *C)
{
    if (A && A->data && B && B->data && C && C->data)
    {
        gsl_blas_zgemm(transA, transB, alpha, A->data, B->data, beta, C->data);
    }
    else
    {
        fprintf(stderr, "%s: ERROR: NULL valued operator\n", __PRETTY_FUNCTION__);
    }
}

canonical_original_code:
void qdpack_matrix_blas_zgemm(enum CBLAS_TRANSPOSE transA, enum CBLAS_TRANSPOSE transB, struct gsl_complex alpha, struct _qdpack_matrix *A, struct _qdpack_matrix *B, struct gsl_complex beta, struct _qdpack_matrix *C)
{
    if (A && A->data && B && B->data && C && C->data)
    {
        gsl_blas_zgemm(transA, transB, alpha, A->data, B->data, beta, C->data);
    }
    else
    {
        fprintf(stderr, "%s: ERROR: NULL valued operator\n", __PRETTY_FUNCTION__);
    }
}

variable_types: enum CBLAS_TRANSPOSE { CblasNoTrans=111, CblasTrans=112, CblasConjTrans=113 }

variable_types:
alpha
struct gsl_complex { double dat[2]; }

variable_types:
B
struct _qdpack_matrix *

variable_types:
beta
struct gsl_complex

variable_types:
C
struct _qdpack_matrix *


decompiled_code:
int __fastcall qdpack_matrix_multiply(__int64 a1, __int64 a2, __int64 a3)
{
if ( !a1 || !*(_QWORD *)(a1 + 8) || !a2 || !*(_QWORD *)(a2 + 8) || !a3 || !*(_QWORD *)(a3 + 8) )
return fprintf(stderr, "%s: ERROR: NULL valued operator\n", "qdpack_matrix_multiply");
gsl_complex_rect(0.0);
gsl_complex_rect(1.0);
return qdpack_matrix_blas_zgemm(111LL, 111LL, a1, a2, a3);
}

canonical_decompiled_code:
int __fastcall func11(__int64 a1, __int64 a2, __int64 a3)
{
if ( !a1 || !*(_QWORD *)(a1 + 8) || !a2 || !*(_QWORD *)(a2 + 8) || !a3 || !*(_QWORD *)(a3 + 8) )
return fprintf(stderr, "%s: ERROR: NULL valued operator\n", "qdpack_matrix_multiply");
gsl_complex_rect(0.0);
gsl_complex_rect(1.0);
return func10(111LL, 111LL, a1, a2, a3);
}

original_code:
void
qdpack_matrix_multiply(qdpack_matrix_t *A, qdpack_matrix_t *B, qdpack_matrix_t *C)
{
    if (A && A->data && B && B->data && C && C->data)
    {
        qdpack_matrix_blas_zgemm(CblasNoTrans, CblasNoTrans, (gsl_complex_rect(1.0,0.0)), A, B, (gsl_complex_rect(0.0,0.0)), C);
    }
    else
    {
        fprintf(stderr, "%s: ERROR: NULL valued operator\n", __PRETTY_FUNCTION__);
    }
}

canonical_original_code:
void qdpack_matrix_multiply(struct _qdpack_matrix *A, struct _qdpack_matrix *B, struct _qdpack_matrix *C)
{
    if (A && A->data && B && B->data && C && C->data)
    {
        qdpack_matrix_blas_zgemm(CblasNoTrans, CblasNoTrans, (gsl_complex_rect(1.0,0.0)), A, B, (gsl_complex_rect(0.0,0.0)), C);
    }
    else
    {
        fprintf(stderr, "%s: ERROR: NULL valued operator\n", __PRETTY_FUNCTION__);
    }
}


decompiled_code:
void __fastcall qdpack_matrix_multiply_vmv(__int64 a1, __int64 a2)
{
_QWORD *v2; // rbx
_QWORD *v3; // rbp
__int64 v4; // r15
__int64 v5; // r14
__int64 v6; // r13
double v7; // xmm0_8
__int64 v8; // r15
double v9; // r14
__int64 v10; // r13
__int64 v11; // r12
double v12; // xmm0_8
double v13; // [rsp+0h] [rbp-48h]

v2 = qdpack_matrix_alloc(*(int *)(a1 + 4), 1LL);
v3 = qdpack_matrix_alloc(1LL, 1LL);
v4 = v2[1];
v13 = gsl_complex_rect(0.0);
v5 = *(_QWORD *)(a2 + 8);
v6 = *(_QWORD *)(a1 + 8);
v7 = gsl_complex_rect(1.0);
gsl_blas_zgemm(111LL, 111LL, v6, v5, v4, v7, 0.0, v13, 0.0);
v8 = v3[1];
v9 = gsl_complex_rect(0.0);
v10 = v2[1];
v11 = *(_QWORD *)(a2 + 8);
v12 = gsl_complex_rect(1.0);
gsl_blas_zgemm(112LL, 111LL, v11, v10, v8, v12, 0.0, v9, 0.0);
qdpack_matrix_get((__int64)v3);
qdpack_matrix_free(v3);
qdpack_matrix_free(v2);
}

original_code:
gsl_complex
qdpack_matrix_multiply_vmv(qdpack_matrix_t *mat, qdpack_matrix_t *v)
{
    qdpack_matrix_t *prod, *expt;
    gsl_complex res;
    prod = qdpack_matrix_alloc(mat->m, 1);
    expt = qdpack_matrix_alloc(1, 1);
    gsl_blas_zgemm(CblasNoTrans, CblasNoTrans, (gsl_complex_rect(1.0,0.0)), mat->data, v->data, (gsl_complex_rect(0.0,0.0)), prod->data);
    gsl_blas_zgemm(CblasTrans, CblasNoTrans, (gsl_complex_rect(1.0,0.0)), v->data, prod->data, (gsl_complex_rect(0.0,0.0)), expt->data);
    res = qdpack_matrix_get(expt, 0, 0);
    qdpack_matrix_free(expt);
    qdpack_matrix_free(prod);
    return res;
}

canonical_original_code:
struct gsl_complex qdpack_matrix_multiply_vmv(struct _qdpack_matrix *mat, struct _qdpack_matrix *v)
{
    struct _qdpack_matrix *prod; struct _qdpack_matrix *expt;
    struct gsl_complex res;
    prod = qdpack_matrix_alloc(mat->m, 1);
    expt = qdpack_matrix_alloc(1, 1);
    gsl_blas_zgemm(CblasNoTrans, CblasNoTrans, (gsl_complex_rect(1.0,0.0)), mat->data, v->data, (gsl_complex_rect(0.0,0.0)), prod->data);
    gsl_blas_zgemm(CblasTrans, CblasNoTrans, (gsl_complex_rect(1.0,0.0)), v->data, prod->data, (gsl_complex_rect(0.0,0.0)), expt->data);
    res = qdpack_matrix_get(expt, 0, 0);
    qdpack_matrix_free(expt);
    qdpack_matrix_free(prod);
    return res;
}

variable_types:
v
struct _qdpack_matrix *

variable_types:
res
struct gsl_complex { double dat[2]; }


decompiled_code:
__int64 __fastcall qdpack_matrix_exp(__int64 a1, __int64 a2)
{
return gsl_linalg_complex_exponential_ss(*(_QWORD *)(a1 + 8), *(_QWORD *)(a2 + 8), 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, __int64 a2)
{
return gsl_linalg_complex_exponential_ss(*(_QWORD *)(a1 + 8), *(_QWORD *)(a2 + 8), 0LL);
}

original_code:
void
qdpack_matrix_exp(qdpack_matrix_t *m, qdpack_matrix_t *exp_m)
{
    gsl_linalg_complex_exponential_ss(m->data, exp_m->data, 0);
}

canonical_original_code:
void qdpack_matrix_exp(struct _qdpack_matrix *m, struct _qdpack_matrix *exp_m)
{
    gsl_linalg_complex_exponential_ss(m->data, exp_m->data, 0);
}


decompiled_code:
void __fastcall qdpack_matrix_dot(__int64 a1, __int64 a2)
{
_QWORD *v2; // rbx
__int64 v3; // r15
double v4; // r12
__int64 v5; // r14
__int64 v6; // r13
double v7; // xmm0_8

v2 = qdpack_matrix_alloc(1LL, 1LL);
v3 = v2[1];
v4 = gsl_complex_rect(0.0);
v5 = *(_QWORD *)(a2 + 8);
v6 = *(_QWORD *)(a1 + 8);
v7 = gsl_complex_rect(1.0);
gsl_blas_zgemm(112LL, 111LL, v6, v5, v3, v7, 0.0, v4, 0.0);
qdpack_matrix_get((__int64)v2);
qdpack_matrix_free(v2);
}

original_code:
gsl_complex
qdpack_matrix_dot(qdpack_matrix_t *a, qdpack_matrix_t *b)
{
    qdpack_matrix_t *prod;
    gsl_complex z;
    prod = qdpack_matrix_alloc(1, 1);
    gsl_blas_zgemm(CblasTrans, CblasNoTrans, (gsl_complex_rect(1.0,0.0)), a->data, b->data, (gsl_complex_rect(0.0,0.0)), prod->data);
    z = qdpack_matrix_get(prod, 0, 0);
    qdpack_matrix_free(prod);
    return z;
}

canonical_original_code:
struct gsl_complex qdpack_matrix_dot(struct _qdpack_matrix *a, struct _qdpack_matrix *b)
{
    struct _qdpack_matrix *prod;
    struct gsl_complex z;
    prod = qdpack_matrix_alloc(1, 1);
    gsl_blas_zgemm(CblasTrans, CblasNoTrans, (gsl_complex_rect(1.0,0.0)), a->data, b->data, (gsl_complex_rect(0.0,0.0)), prod->data);
    z = qdpack_matrix_get(prod, 0, 0);
    qdpack_matrix_free(prod);
    return z;
}

variable_types:
b
struct _qdpack_matrix *


decompiled_code:
__int64 __fastcall qdpack_matrix_eigen_hermv(__int64 a1, __int64 a2, __int64 a3, unsigned int a4)
{
__int64 v6; // r12
__int64 v7; // rbx

if ( !hermv_workspace )
hermv_workspace = gsl_eigen_hermv_alloc(*(int *)(a1 + 4));
v6 = gsl_vector_alloc(*(int *)(a2 + 4));
gsl_eigen_hermv(*(_QWORD *)(a1 + 8), v6, *(_QWORD *)(a3 + 8), hermv_workspace);
gsl_eigen_hermv_sort(v6, *(_QWORD *)(a3 + 8), a4);
if ( *(int *)(a2 + 4) > 0 )
{
v7 = 0LL;
do
{
gsl_vector_get(v6, v7);
qdpack_matrix_set(a2);
++v7;
}
while ( *(_DWORD *)(a2 + 4) > (int)v7 );
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func17(__int64 a1, __int64 a2, __int64 a3, unsigned int a4)
{
__int64 v6; // r12
__int64 v7; // rbx

if ( !hermv_workspace )
hermv_workspace = gsl_eigen_hermv_alloc(*(int *)(a1 + 4));
v6 = gsl_vector_alloc(*(int *)(a2 + 4));
gsl_eigen_hermv(*(_QWORD *)(a1 + 8), v6, *(_QWORD *)(a3 + 8), hermv_workspace);
gsl_eigen_hermv_sort(v6, *(_QWORD *)(a3 + 8), a4);
if ( *(int *)(a2 + 4) > 0 )
{
v7 = 0LL;
do
{
gsl_vector_get(v6, v7);
func2(a2);
++v7;
}
while ( *(_DWORD *)(a2 + 4) > (int)v7 );
}
return 0LL;
}

original_code:
int
qdpack_matrix_eigen_hermv(qdpack_matrix_t *m,
                          qdpack_matrix_t *eval,
                          qdpack_matrix_t *evec,
                          int sort_order)
{
    int i;
    gsl_vector *eval_vector;
    if (hermv_workspace == ((void *)0))
    {
        hermv_workspace = gsl_eigen_hermv_alloc(m->m);
    }
    eval_vector = gsl_vector_alloc(eval->m);
    gsl_eigen_hermv(m->data, eval_vector, evec->data, hermv_workspace);
    gsl_eigen_hermv_sort(eval_vector, evec->data, sort_order);
    for (i = 0; i < eval->m; i++)
    {
        gsl_complex z;
        do {(&z)->dat[0]=(gsl_vector_get(eval_vector, i)); (&z)->dat[1]=(0.0);} while(0);
        qdpack_matrix_set(eval, i, 0, z);
    }
    return 0;
}

canonical_original_code:
int qdpack_matrix_eigen_hermv(struct _qdpack_matrix *m, struct _qdpack_matrix *eval, struct _qdpack_matrix *evec, int sort_order)
{
    int i;
    struct gsl_vector *eval_vector;
    if (hermv_workspace == ((void *)0))
    {
        hermv_workspace = gsl_eigen_hermv_alloc(m->m);
    }
    eval_vector = gsl_vector_alloc(eval->m);
    gsl_eigen_hermv(m->data, eval_vector, evec->data, hermv_workspace);
    gsl_eigen_hermv_sort(eval_vector, evec->data, sort_order);
    for (i = 0; i < eval->m; i++)
    {
        struct gsl_complex z;
        do {(&z)->dat[0]=(gsl_vector_get(eval_vector, i)); (&z)->dat[1]=(0.0);} while(0);
        qdpack_matrix_set(eval, i, 0, z);
    }
    return 0;
}

variable_types:
eval
struct _qdpack_matrix *

variable_types:
evec
struct _qdpack_matrix *

variable_types: i int

variable_types: struct gsl_vector { unsigned long size; unsigned long stride; double *data; struct gsl_block_struct { unsigned long size; double *data; } *block; int owner; } *

user_defined_types: struct gsl_vector { unsigned long size; unsigned long stride; double *data; struct gsl_block_struct *block; int owner; }


decompiled_code:
__int64 __fastcall qdpack_matrix_eigen_zgeev(__int64 a1, __int64 a2, __int64 a3, unsigned int a4)
{
__int64 v6; // r12
__int64 v7; // rbx

v6 = gsl_vector_complex_alloc(*(int *)(a2 + 4));
gsl_ext_eigen_zgeev(*(_QWORD *)(a1 + 8), *(_QWORD *)(a3 + 8), v6);
gsl_ext_eigen_sort(*(_QWORD *)(a3 + 8), v6, a4);
if ( *(int *)(a2 + 4) > 0 )
{
v7 = 0LL;
do
{
gsl_vector_complex_get(v6, v7);
qdpack_matrix_set(a2);
++v7;
}
while ( *(_DWORD *)(a2 + 4) > (int)v7 );
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func18(__int64 a1, __int64 a2, __int64 a3, unsigned int a4)
{
__int64 v6; // r12
__int64 v7; // rbx

v6 = gsl_vector_complex_alloc(*(int *)(a2 + 4));
gsl_ext_eigen_zgeev(*(_QWORD *)(a1 + 8), *(_QWORD *)(a3 + 8), v6);
gsl_ext_eigen_sort(*(_QWORD *)(a3 + 8), v6, a4);
if ( *(int *)(a2 + 4) > 0 )
{
v7 = 0LL;
do
{
gsl_vector_complex_get(v6, v7);
func2(a2);
++v7;
}
while ( *(_DWORD *)(a2 + 4) > (int)v7 );
}
return 0LL;
}

original_code:
int
qdpack_matrix_eigen_zgeev(qdpack_matrix_t *m,
                          qdpack_matrix_t *eval,
                          qdpack_matrix_t *evec,
                          int sort_order)
{
    int i;
    gsl_vector_complex *eval_vector;
    eval_vector = gsl_vector_complex_alloc(eval->m);
    gsl_ext_eigen_zgeev(m->data, evec->data, eval_vector);
    gsl_ext_eigen_sort(evec->data, eval_vector, sort_order);
    for (i = 0; i < eval->m; i++)
    {
        qdpack_matrix_set(eval, i, 0, gsl_vector_complex_get(eval_vector, i));
    }
    return 0;
}

canonical_original_code:
int qdpack_matrix_eigen_zgeev(struct _qdpack_matrix *m, struct _qdpack_matrix *eval, struct _qdpack_matrix *evec, int sort_order)
{
    int i;
    struct gsl_vector_complex *eval_vector;
    eval_vector = gsl_vector_complex_alloc(eval->m);
    gsl_ext_eigen_zgeev(m->data, evec->data, eval_vector);
    gsl_ext_eigen_sort(evec->data, eval_vector, sort_order);
    for (i = 0; i < eval->m; i++)
    {
        qdpack_matrix_set(eval, i, 0, gsl_vector_complex_get(eval_vector, i));
    }
    return 0;
}

variable_types: struct _qdpack_matrix { int n; struct gsl_matrix_complex { unsigned long size1; unsigned long size2; unsigned long tda; double *data; struct gsl_block_complex_struct { unsigned long size; double *data; } *block; int owner; } *data; } *

variable_types: struct gsl_vector_complex { unsigned long size; unsigned long stride; double *data; struct gsl_block_complex_struct { unsigned long size; double *data; } *block; int owner; } *

user_defined_types: struct gsl_vector_complex { unsigned long size; unsigned long stride; double *data; struct gsl_block_complex_struct *block; int owner; }


decompiled_code:
int __fastcall qdpack_operator_print(_DWORD *a1, double a2, double a3)
{
__int64 i; // r13
double v4; // rbp
__int64 j; // rbx
int result; // eax

for ( i = 0LL; a1[1] > (int)i; ++i )
{
for ( j = 0LL; *a1 > (int)j; ++j )
{
v4 = qdpack_operator_get(a1, i, j);
qdpack_operator_get(a1, i, j);
printf(" (%2.5f,%2.5f)", v4, a3);
}
result = putchar(10);
}
return result;
}

canonical_decompiled_code:
int __fastcall func0(_DWORD *a1, double a2, double a3)
{
__int64 i; // r13
double v4; // rbp
__int64 j; // rbx
int result; // eax

for ( i = 0LL; a1[1] > (int)i; ++i )
{
for ( j = 0LL; *a1 > (int)j; ++j )
{
v4 = qdpack_operator_get(a1, i, j);
qdpack_operator_get(a1, i, j);
printf(" (%2.5f,%2.5f)", v4, a3);
}
result = putchar(10);
}
return result;
}

original_code:
void
qdpack_operator_print(qdpack_operator_t *m)
{
    double val_re, val_im;
    int i, j;
    for (i = 0; i < m->m; i++)
    {
           for (j = 0; j < m->n; j++)
        {
            val_re = ((qdpack_operator_get(m, i, j)).dat[0]);
            val_im = ((qdpack_operator_get(m, i, j)).dat[1]);
            printf (" (%2.5f,%2.5f)", val_re, val_im);
        }
        printf("\n");
    }
}

canonical_original_code:
void qdpack_operator_print(struct _qdpack_operator_t *m)
{
    double val_re; double val_im;
    int i; int j;
    for (i = 0; i < m->m; i++)
    {
           for (j = 0; j < m->n; j++)
        {
            val_re = ((qdpack_operator_get(m, i, j)).dat[0]);
            val_im = ((qdpack_operator_get(m, i, j)).dat[1]);
            printf (" (%2.5f,%2.5f)", val_re, val_im);
        }
        printf("\n");
    }
}

variable_types: struct _qdpack_operator_t { int n; struct qdpack_hilbert_space_t { int nsubsys; int *nstates; } *qs; struct _qdpack_matrix { int n; struct gsl_matrix_complex { unsigned long size1; unsigned long size2; unsigned long tda; double *data; struct gsl_block_complex_struct { unsigned long size; double *data; } *block; int owner; } *data; } *data; } *

variable_types: j int

user_defined_types: struct _qdpack_operator_t { int n; struct qdpack_hilbert_space_t *qs; struct _qdpack_matrix *data; }


decompiled_code:
int __fastcall qdpack_operator_print_real(_DWORD *a1)
{
__int64 i; // r12
__int64 j; // rbx
double v3; // xmm0_8
int result; // eax

for ( i = 0LL; a1[1] > (int)i; ++i )
{
for ( j = 0LL; *a1 > (int)j; ++j )
{
v3 = qdpack_operator_get(a1, i, j);
if ( v3 < 0.0 )
printf("%2.5f ", v3);
else
printf(" %2.5f ", v3);
}
result = putchar(10);
}
return result;
}

canonical_decompiled_code:
int __fastcall func1(_DWORD *a1)
{
__int64 i; // r12
__int64 j; // rbx
double v3; // xmm0_8
int result; // eax

for ( i = 0LL; a1[1] > (int)i; ++i )
{
for ( j = 0LL; *a1 > (int)j; ++j )
{
v3 = qdpack_operator_get(a1, i, j);
if ( v3 < 0.0 )
printf("%2.5f ", v3);
else
printf(" %2.5f ", v3);
}
result = putchar(10);
}
return result;
}

original_code:
void
qdpack_operator_print_real(qdpack_operator_t *m)
{
    double val;
    int i, j;
    for (i = 0; i < m->m; i++)
    {
           for (j = 0; j < m->n; j++)
        {
            val = ((qdpack_operator_get(m, i, j)).dat[0]);
            if (val >= 0.0)
                printf (" %2.5f  ", val);
            else
                printf ("%2.5f  ", val);
        }
        printf("\n");
    }
}

canonical_original_code:
void qdpack_operator_print_real(struct _qdpack_operator_t *m)
{
    double val;
    int i; int j;
    for (i = 0; i < m->m; i++)
    {
           for (j = 0; j < m->n; j++)
        {
            val = ((qdpack_operator_get(m, i, j)).dat[0]);
            if (val >= 0.0)
                printf (" %2.5f  ", val);
            else
                printf ("%2.5f  ", val);
        }
        printf("\n");
    }
}

variable_types: val double

user_defined_types: struct qdpack_hilbert_space_t { int nsubsys; int *nstates; }


decompiled_code:
int __fastcall qdpack_operator_print_imag(_DWORD *a1, double a2, double a3)
{
__int64 i; // r12
__int64 j; // rbx
int result; // eax

for ( i = 0LL; a1[1] > (int)i; ++i )
{
for ( j = 0LL; *a1 > (int)j; ++j )
{
qdpack_operator_get(a1, i, j);
printf("%2.5f ", a3);
}
result = putchar(10);
}
return result;
}

canonical_decompiled_code:
int __fastcall func2(_DWORD *a1, double a2, double a3)
{
__int64 i; // r12
__int64 j; // rbx
int result; // eax

for ( i = 0LL; a1[1] > (int)i; ++i )
{
for ( j = 0LL; *a1 > (int)j; ++j )
{
qdpack_operator_get(a1, i, j);
printf("%2.5f ", a3);
}
result = putchar(10);
}
return result;
}

original_code:
void
qdpack_operator_print_imag(qdpack_operator_t *m)
{
    int i, j;
    for (i = 0; i < m->m; i++)
    {
           for (j = 0; j < m->n; j++)
            printf ("%2.5f  ", ((qdpack_operator_get(m, i, j)).dat[1]));
        printf("\n");
    }
}

canonical_original_code:
void qdpack_operator_print_imag(struct _qdpack_operator_t *m)
{
    int i; int j;
    for (i = 0; i < m->m; i++)
    {
           for (j = 0; j < m->n; j++)
            printf ("%2.5f  ", ((qdpack_operator_get(m, i, j)).dat[1]));
        printf("\n");
    }
}


decompiled_code:
int __fastcall qdpack_operator_print_abs2(_DWORD *a1, double a2, double a3)
{
__int64 i; // r12
double v4; // xmm0_8
__int64 j; // rbx
int result; // eax

for ( i = 0LL; a1[1] > (int)i; ++i )
{
for ( j = 0LL; *a1 > (int)j; ++j )
{
v4 = qdpack_operator_get(a1, i, j);
a3 = a3 * a3;
printf("%2.5f ", v4 * v4 + a3);
}
result = putchar(10);
}
return result;
}

canonical_decompiled_code:
int __fastcall func3(_DWORD *a1, double a2, double a3)
{
__int64 i; // r12
double v4; // xmm0_8
__int64 j; // rbx
int result; // eax

for ( i = 0LL; a1[1] > (int)i; ++i )
{
for ( j = 0LL; *a1 > (int)j; ++j )
{
v4 = qdpack_operator_get(a1, i, j);
a3 = a3 * a3;
printf("%2.5f ", v4 * v4 + a3);
}
result = putchar(10);
}
return result;
}

original_code:
void
qdpack_operator_print_abs2(qdpack_operator_t *m)
{
    gsl_complex z;
    int i, j;
    for (i = 0; i < m->m; i++)
    {
           for (j = 0; j < m->n; j++)
        {
            z = qdpack_operator_get(m, i, j);
            printf("%2.5f  ", ((z).dat[0])*((z).dat[0]) + ((z).dat[1])*((z).dat[1]));
        }
        printf("\n");
    }
}

canonical_original_code:
void qdpack_operator_print_abs2(struct _qdpack_operator_t *m)
{
    struct gsl_complex z;
    int i; int j;
    for (i = 0; i < m->m; i++)
    {
           for (j = 0; j < m->n; j++)
        {
            z = qdpack_operator_get(m, i, j);
            printf("%2.5f  ", ((z).dat[0])*((z).dat[0]) + ((z).dat[1])*((z).dat[1]));
        }
        printf("\n");
    }
}

variable_types:
z
struct gsl_complex { double dat[2]; }


decompiled_code:
int __fastcall qdpack_state_print_real(int *a1, double a2)
{
__int64 v2; // rbx

if ( *a1 > 0 )
{
v2 = 0LL;
do
{
qdpack_state_get(a1, v2);
printf("%2.5f ", a2);
++v2;
}
while ( *a1 > (int)v2 );
}
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func14(int *a1, double a2)
{
__int64 v2; // rbx

if ( *a1 > 0 )
{
v2 = 0LL;
do
{
qdpack_state_get(a1, v2);
printf("%2.5f ", a2);
++v2;
}
while ( *a1 > (int)v2 );
}
return putchar(10);
}

original_code:
void
qdpack_state_print_real(qdpack_state_t *v)
{
    int i;
    for (i = 0; i < v->n; i++)
    {
        printf("%2.5f ", ((qdpack_state_get(v, i)).dat[0]));
    }
    printf("\n");
}

canonical_original_code:
void qdpack_state_print_real(struct _qdpack_state *v)
{
    int i;
    for (i = 0; i < v->n; i++)
    {
        printf("%2.5f ", ((qdpack_state_get(v, i)).dat[0]));
    }
    printf("\n");
}

variable_types: struct _qdpack_state { int n; struct qdpack_hilbert_space_t { int nsubsys; int *nstates; } *qs; struct _qdpack_matrix { int n; struct gsl_matrix_complex { unsigned long size1; unsigned long size2; unsigned long tda; double *data; struct gsl_block_complex_struct { unsigned long size; double *data; } *block; int owner; } *data; } *data; } *

user_defined_types: struct _qdpack_state { int n; struct qdpack_hilbert_space_t *qs; struct _qdpack_matrix *data; }


decompiled_code:
int __fastcall qdpack_state_print_imag(int *a1, double a2, double a3)
{
__int64 v3; // rbx

if ( *a1 > 0 )
{
v3 = 0LL;
do
{
qdpack_state_get(a1, v3);
printf("%2.5f ", a3);
++v3;
}
while ( *a1 > (int)v3 );
}
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func15(int *a1, double a2, double a3)
{
__int64 v3; // rbx

if ( *a1 > 0 )
{
v3 = 0LL;
do
{
qdpack_state_get(a1, v3);
printf("%2.5f ", a3);
++v3;
}
while ( *a1 > (int)v3 );
}
return putchar(10);
}

original_code:
void
qdpack_state_print_imag(qdpack_state_t *v)
{
    int i;
    for (i = 0; i < v->n; i++)
    {
        printf("%2.5f ", ((qdpack_state_get(v, i)).dat[1]));
    }
    printf("\n");
}

canonical_original_code:
void qdpack_state_print_imag(struct _qdpack_state *v)
{
    int i;
    for (i = 0; i < v->n; i++)
    {
        printf("%2.5f ", ((qdpack_state_get(v, i)).dat[1]));
    }
    printf("\n");
}


decompiled_code:
__int64 __fastcall qdpack_dm_pure_TLS(double a1)
{
__int64 v1; // rbp
__int64 v2; // rbx
double v3; // xmm0_8
double v5; // [rsp+0h] [rbp-28h]
double xa; // [rsp+8h] [rbp-20h]

v1 = qdpack_hilbert_space_new();
qdpack_hilbert_space_add(v1, 2LL);
v2 = qdpack_operator_alloc(v1);
if ( v2 )
{
v3 = 1.0 - a1;
if ( 1.0 - a1 < 0.0 )
v5 = sqrt(v3);
else
v5 = sqrt(v3);
if ( a1 < 0.0 )
xa = sqrt(a1);
else
xa = sqrt(a1);
qdpack_operator_set(v2, 0LL, 0LL, v5 * v5, 0.0);
qdpack_operator_set(v2, 0LL, 1LL, v5 * xa, 0.0);
qdpack_operator_set(v2, 1LL, 0LL, v5 * xa, 0.0);
qdpack_operator_set(v2, 1LL, 1LL, xa * xa, 0.0);
qdpack_hilbert_space_free(v1);
}
else
{
fprintf(stderr, "%s: Failed to allocate dm (Out of memory?).\n", "qdpack_dm_pure_TLS");
}
return v2;
}

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

v1 = qdpack_hilbert_space_new();
qdpack_hilbert_space_add(v1, 2LL);
v2 = qdpack_operator_alloc(v1);
if ( v2 )
{
v3 = 1.0 - a1;
if ( 1.0 - a1 < 0.0 )
v5 = sqrt(v3);
else
v5 = sqrt(v3);
if ( a1 < 0.0 )
xa = sqrt(a1);
else
xa = sqrt(a1);
qdpack_operator_set(v2, 0LL, 0LL, v5 * v5, 0.0);
qdpack_operator_set(v2, 0LL, 1LL, v5 * xa, 0.0);
qdpack_operator_set(v2, 1LL, 0LL, v5 * xa, 0.0);
qdpack_operator_set(v2, 1LL, 1LL, xa * xa, 0.0);
qdpack_hilbert_space_free(v1);
}
else
{
fprintf(stderr, "%s: Failed to allocate dm (Out of memory?).\n", "qdpack_dm_pure_TLS");
}
return v2;
}

original_code:
qdpack_operator_t *
qdpack_dm_pure_TLS(double p_ex)
{
    double aa, bb;
    qdpack_operator_t *dm;
    gsl_complex z;
    qdpack_hilbert_space_t *qs;
    qs = qdpack_hilbert_space_new();
    qdpack_hilbert_space_add(qs, 2);
    if ((dm = qdpack_operator_alloc(qs)) == ((void *)0))
    {
        fprintf(stderr, "%s: Failed to allocate dm (Out of memory?).\n", __PRETTY_FUNCTION__);
        return ((void *)0);
    }
    aa = sqrt(1-p_ex);
    bb = sqrt(p_ex);
    do {(&z)->dat[0]=(aa * aa); (&z)->dat[1]=(0.0);} while(0); qdpack_operator_set(dm, 0, 0, z);
    do {(&z)->dat[0]=(aa * bb); (&z)->dat[1]=(0.0);} while(0); qdpack_operator_set(dm, 0, 1, z);
    do {(&z)->dat[0]=(bb * aa); (&z)->dat[1]=(0.0);} while(0); qdpack_operator_set(dm, 1, 0, z);
    do {(&z)->dat[0]=(bb * bb); (&z)->dat[1]=(0.0);} while(0); qdpack_operator_set(dm, 1, 1, z);
    qdpack_hilbert_space_free(qs);
    return dm;
}

canonical_original_code:
struct _qdpack_operator_t *qdpack_dm_pure_TLS(double p_ex)
{
    double aa; double bb;
    struct _qdpack_operator_t *dm;
    struct gsl_complex z;
    struct qdpack_hilbert_space_t *qs;
    qs = qdpack_hilbert_space_new();
    qdpack_hilbert_space_add(qs, 2);
    if ((dm = qdpack_operator_alloc(qs)) == ((void *)0))
    {
        fprintf(stderr, "%s: Failed to allocate dm (Out of memory?).\n", __PRETTY_FUNCTION__);
        return ((void *)0);
    }
    aa = sqrt(1-p_ex);
    bb = sqrt(p_ex);
    do {(&z)->dat[0]=(aa * aa); (&z)->dat[1]=(0.0);} while(0); qdpack_operator_set(dm, 0, 0, z);
    do {(&z)->dat[0]=(aa * bb); (&z)->dat[1]=(0.0);} while(0); qdpack_operator_set(dm, 0, 1, z);
    do {(&z)->dat[0]=(bb * aa); (&z)->dat[1]=(0.0);} while(0); qdpack_operator_set(dm, 1, 0, z);
    do {(&z)->dat[0]=(bb * bb); (&z)->dat[1]=(0.0);} while(0); qdpack_operator_set(dm, 1, 1, z);
    qdpack_hilbert_space_free(qs);
    return dm;
}

variable_types: aa double

variable_types: bb double

return_type: struct _qdpack_operator_t { int n; struct qdpack_hilbert_space_t { int nsubsys; int *nstates; } *qs; struct _qdpack_matrix { int n; struct gsl_matrix_complex { unsigned long size1; unsigned long size2; unsigned long tda; double *data; struct gsl_block_complex_struct { unsigned long size; double *data; } *block; int owner; } *data; } *data; } *


decompiled_code:
__int64 __fastcall qdpack_wf_pure_TLS(double a1)
{
__int64 v1; // rbp
__int64 v2; // rbx
double v3; // xmm0_8
double v4; // r13
double v5; // r12

v1 = qdpack_hilbert_space_new();
qdpack_hilbert_space_add(v1, 2LL);
v2 = qdpack_state_alloc(v1);
if ( v2 )
{
v3 = 1.0 - a1;
if ( 1.0 - a1 < 0.0 )
v4 = sqrt(v3);
else
v4 = sqrt(v3);
if ( a1 < 0.0 )
v5 = sqrt(a1);
else
v5 = sqrt(a1);
qdpack_state_set(v2, 0LL, v4, 0.0);
qdpack_state_set(v2, 1LL, v5, 0.0);
qdpack_hilbert_space_free(v1);
}
else
{
fwrite("qdpack_wf_pure_TLS: Failed to allocate wf (Out of memory?).\n", 1uLL, 0x3CuLL, stderr);
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func1(double a1)
{
__int64 v1; // rbp
__int64 v2; // rbx
double v3; // xmm0_8
double v4; // r13
double v5; // r12

v1 = qdpack_hilbert_space_new();
qdpack_hilbert_space_add(v1, 2LL);
v2 = qdpack_state_alloc(v1);
if ( v2 )
{
v3 = 1.0 - a1;
if ( 1.0 - a1 < 0.0 )
v4 = sqrt(v3);
else
v4 = sqrt(v3);
if ( a1 < 0.0 )
v5 = sqrt(a1);
else
v5 = sqrt(a1);
qdpack_state_set(v2, 0LL, v4, 0.0);
qdpack_state_set(v2, 1LL, v5, 0.0);
qdpack_hilbert_space_free(v1);
}
else
{
fwrite("qdpack_wf_pure_TLS: Failed to allocate wf (Out of memory?).\n", 1uLL, 0x3CuLL, stderr);
}
return v2;
}

original_code:
qdpack_state_t *
qdpack_wf_pure_TLS(double p_ex)
{
    double aa, bb;
    qdpack_state_t *wf;
    gsl_complex z;
    qdpack_hilbert_space_t *qs;
    qs = qdpack_hilbert_space_new();
    qdpack_hilbert_space_add(qs, 2);
    if ((wf = qdpack_state_alloc(qs)) == ((void *)0))
    {
        fprintf(stderr, "qdpack_wf_pure_TLS: Failed to allocate wf (Out of memory?).\n");
        return ((void *)0);
    }
    aa = sqrt(1-p_ex);
    bb = sqrt(p_ex);
    do {(&z)->dat[0]=(aa); (&z)->dat[1]=(0.0);} while(0); qdpack_state_set(wf, 0, z);
    do {(&z)->dat[0]=(bb); (&z)->dat[1]=(0.0);} while(0); qdpack_state_set(wf, 1, z);
    qdpack_hilbert_space_free(qs);
    return wf;
}

canonical_original_code:
struct _qdpack_state *qdpack_wf_pure_TLS(double p_ex)
{
    double aa; double bb;
    struct _qdpack_state *wf;
    struct gsl_complex z;
    struct qdpack_hilbert_space_t *qs;
    qs = qdpack_hilbert_space_new();
    qdpack_hilbert_space_add(qs, 2);
    if ((wf = qdpack_state_alloc(qs)) == ((void *)0))
    {
        fprintf(stderr, "qdpack_wf_pure_TLS: Failed to allocate wf (Out of memory?).\n");
        return ((void *)0);
    }
    aa = sqrt(1-p_ex);
    bb = sqrt(p_ex);
    do {(&z)->dat[0]=(aa); (&z)->dat[1]=(0.0);} while(0); qdpack_state_set(wf, 0, z);
    do {(&z)->dat[0]=(bb); (&z)->dat[1]=(0.0);} while(0); qdpack_state_set(wf, 1, z);
    qdpack_hilbert_space_free(qs);
    return wf;
}

return_type: struct _qdpack_state { int n; struct qdpack_hilbert_space_t { int nsubsys; int *nstates; } *qs; struct _qdpack_matrix { int n; struct gsl_matrix_complex { unsigned long size1; unsigned long size2; unsigned long tda; double *data; struct gsl_block_complex_struct { unsigned long size; double *data; } *block; int owner; } *data; } *data; } *