#ifdef _MSC_VER #define _CRT_SECURE_NO_WARNINGS #endif #include #include #include #include #include #define MAX_DATA_SIZE 10000 // [4 * (dataSize + 1)] long double sub_41B088( int a1, int a2, int a3, int a4, int a5); void sub_41B3D4(double a1, int a2, int a3, int a4, int a5); //void printDoubleAsHex(double value); //void compare_doubles(double a, double b); void *operator_new(size_t Size); int byte_4BD308; int handle; int byte_4BC818; // array for values char v9; int v5 = 0; //v5 = count // Prediction function (simplified example) int main(int argc, char* argv[]) { LARGE_INTEGER start, end, frequency; QueryPerformanceCounter(&start); QueryPerformanceFrequency(&frequency); int dword_4BD30C = 0; int j; int v3; int v2; int v84; //V84 PREDICT FROM count = 3360 int v87; // TRAIN FROM 1 int v83; // PREDICT TO 3365 int v92; int v93; int v86; int v85; // TRAIN TO int v101; int v71; int v94; int v70; int m; int v8; int v7; int v82; //NUMBER OF NEIGHBORS int v88; double v115; float flt_41B070; bool v10; int n; int Checked; // SINGLE NEIGHBOR FOR EACH ORBIT = 1 int i; int v79; int ii; int v90; if (argc != 4) { fprintf(stderr, "Usage: %s \n", argv[0]); exit(0); } const char* dataFile = argv[1]; // COMMAND LINE DATA FILE NAME int dimension = atoi(argv[2]); // COMMAND LINE DIMENSION VALUE int delay = atoi(argv[3]); // COMMAND LINE DELAY VALUE v92 = delay; v93 = dimension; FILE *fp; /* open file for reading */ if ((fp = fopen(argv[1], "rb")) == (FILE *)NULL) { puts("Cannot open the input file: D"); exit(0); } //int count = 0; // Count how many values in the data file while ( 1 ) { int v7 = fscanf(fp, "%f\n", &v9); //printf("v7: %d\n",v7); if ( v7 == -1 ) { //fclose(fp); break; } if ( v7 != 1 ) break; if ( ++v5 > 1000000 ) // ++v5 = ++count { //fclose(fp); break; } } //printf("There are %d values in data file. \n",v5); // Rewind the file pointer to the beginning rewind(fp); // Create array for data file byte_4BC818 = (int)operator_new(sizeof(int) * (v5 + 1)); //printf("byte_4BC818 is: %d \n",byte_4BC818); // Print the integer in hexadecimal with a "0x" prefix //printf("byte_4BC818 in Hex is: 0x%X\n", byte_4BC818); //v57 = byte_4BC818; //(char)sub_41FEC8(v76, v57); // int v2 = byte_4BC818; int v51 = 0; do { ++v51; }while ( fscanf(fp, "%d\n", byte_4BC818 + sizeof(int) * v51) != -1 ); // Close the file fclose(fp); //printf("v51 is: %d \n",v51); //printf("Value at index 1: %d\n", *(int*)(byte_4BC818 + sizeof(int) * 1)); //printf("Values at row 1 are: %d %d %d %d %d\n", *(int*)(byte_4BC818 + sizeof(int) * 1), *(int*)(byte_4BC818 + sizeof(int) * 2), *(int*)(byte_4BC818 + sizeof(int) * 3), *(int*)(byte_4BC818 + sizeof(int) * 4), *(int*)(byte_4BC818 + sizeof(int) * 5)); // 7 11 19 40 43 // VARIABLES DECLARATION v82 = 1; // to be done byte_4BD308 = (int)operator_new(12 * v82); // sizeof(long long) or sizeof(int64_t) for float sizeof(double) handle = (int)operator_new(sizeof(int) * (v83 + 1)); // V3 PREDICT TO 3365 v84 = v5 + 1; //V84 PREDICT FROM count = 3360 v2 = 1; v3 = 0; // must be from 0 to 3359 for (i = 0; v2 < v84; i = v3 ) // from v2 = 0 to v84 = 3361 (predict from) { v3 = *(int *)(byte_4BC818 + sizeof(int) * v2++) + i; //byte_4BC818 -> data file values } //printf("v3 at the end is: %d \n",v3); // PASSED int v107 = i / (int)(v84 - 1); // PREDICT FROM 3361 - 1 // double v107 = i / (long double)(v84 - 1); int v108 = 0; int v103 = 0; int v104 = 0; int v105 = 0; //printf("v107: %.17g \n",v107); // PASSED 25.37142857142857 v83 = v5 + 5; // PREDICT TO 3365 v87 = 1; // TRAIN FROM 1 // 3360 * 4 = 13440 (3480h) + BASE ADDRESS OF BYTE_4BC818 = 3480h + 598AFE4h = 598E464 // 3360 * 8 = 26880 (6900h) + BASE ADDRESS OF HANDLE = 6900h + 599A6D0h = 59A0FD0 //1 //3365 1 3365 for ( j = v87; j <= v83; ++j ) //V87 TRAIN FROM, V83 PREDICT TO { *(int *)(handle + sizeof(int) * j) = *(int *)(byte_4BC818 + sizeof(int) * j); } v85 = v5; // TRAIN TO // 3360 - 5 = 3355 // 3360 2:2 * 1:3 - 1 v86 = v85 - (v92 * (v93 - 1) + 1); //V85 TRAIN TO, V92 DELAY, V93 DIMENSION //printf("v86 is: %d \n",v86); // PASSED 3355 -> D1B v101 = *(int *)(byte_4BC818 + sizeof(int) * v84 - 4); //V84 PREDICT FROM 3361 //printf("v101: %d \n",v101); // PASSED 37 v71 = v84; //V84 PREDICT FROM 3361 if( v84 <= v83 ) //V84 PREDICT FROM 3361, V83 PREDICT TO 3365 { while ( !dword_4BD30C ) { // 3361 - 4 - 1 // 2 2 v94 = v71 - v92 * (v93 - 1) - 1; //V92 DELAY, V93 DIMENSION v70 = 0; for ( m = 0; m < v82; *(int *)(v8 + sizeof(int) * v7 + sizeof(int)) = 1206910975 ) // 47EFFFFFh { *(int *)(byte_4BD308 + 12 * m + 8) = 0; v7 = 3 * m; v8 = byte_4BD308; ++m; *(int *)(byte_4BD308 + sizeof(int) * v7) = -536870912; // 0E0000000h } v88 = 0; // EUCLIDEAN for (n = v87; n <= v86; ++n ) //V87 TRAIN FROM = 1 V86 = D1B = 3355 { // 1 D1C 0 3 2 v115 = sub_41B088(n, v94, v88, v93, v92); // Print the long double variable with 18 decimal places //printf("v115 is: %.18f\n", v115); // 6.633249580710799698229865 // Print the number of significant digits for long double //printf("LDBL_DIG: %d\n", LDBL_DIG); v10 = v115 != 3.4028235e38f; Checked = 1; // SINGLE NEIGHBOR FOR EACH ORBIT = 1 if ( v10 ) { sub_41B3D4(v115, n, v92, Checked, v82); //printf("%.18f %d %d %d %d\n",v115,n,v92,Checked,v82); } } int v13 = 0; //int kk = v13; int v111 = 0; int v110 = 0; //long double v13 = 0.0; //double kk = v13; //double v111 = 0.0; //double v110 = 0.0; v79 = 0; if ( (unsigned int)v79 <= 1 ) { for ( ii = 0; ii < v82; ++ii ) { v111 = *(int *)(byte_4BC818 + sizeof(int) * (v92 * (v93 - 1) + *(int *)(byte_4BD308 + 12 * ii + 8)) + 4) + v111; } v13 = v111 / (long double)v82; //NUMBER OF NEIGHBORS v111 = v13; } v90 = 0; //printf("%d %d\n",v84,v83); if ( !v90 ) { *(int *)(handle + sizeof(int) * v71) = v111; //v113 = *(float *)(byte_4BC818 + 4 * v71); } if ( ++v71 > v83 ) // v71 > 3361 { //printf("%d %d %d %d %d\n",*(int *)(handle + sizeof(int) * v84),*(int *)(handle + sizeof(int) * v84 + 4),*(int *)(handle + sizeof(int) * v84 + 8),*(int *)(handle + sizeof(int) * v84 + 12),*(int *)(handle + sizeof(int) * v84 + 16)); QueryPerformanceCounter(&end); fflush(stdout); double elapsed = (double)(end.QuadPart - start.QuadPart) /(double)frequency.QuadPart; printf("Elapsed time: %.9f seconds\n", elapsed); break; } } } exit(0); } //void* operator_new(size_t Size) //{ //return operator_new(Size); //} // 7 11 19 40 43 void* operator_new(size_t Size) { size_t v1; // Variable to store the size void* result; // Variable to store the pointer to the allocated memory v1 = Size; // Store the requested size in v1 if (!Size) // If the requested size is 0 v1 = 1; // Set v1 to 1 (so we don't allocate 0 bytes) while (1) { result = malloc(v1); // Attempt to allocate memory of size v1 if (result) // If allocation succeeds, or the flag is not set break; // Exit the loop // dword_4BE648(); // This seems to be a function pointer to a custom retry handler } return result; // Return the allocated memory (or NULL if failed) } // 7 11 19 40 43 // 3356 // n v94 v88 v93 v92 // 1 D1C 0 3 2 long double sub_41B088( int a1, int a2, int a3, int a4, int a5) { int v21 = 0; for (int i = 1; i <= a4; ++i) { //printf("Values at row 1 for byte_4BC818 are: %d %d %d %d %d\n", *(int*)(byte_4BC818 + sizeof(int) * 1), *(int*)(byte_4BC818 + sizeof(int) * 2), *(int*)(byte_4BC818 + sizeof(int) * 3), *(int*)(byte_4BC818 + sizeof(int) * 4), *(int*)(byte_4BC818 + sizeof(int) * 5)); //printf("Values at row 1 for handle are: %d %d %d %d %d\n", *(int*)(handle + sizeof(int) * 1), *(int*)(handle + sizeof(int) * 2), *(int*)(handle + sizeof(int) * 3), *(int*)(handle + sizeof(int) * 4), *(int*)(handle + sizeof(int) * 5)); int X = *(int *)(handle + sizeof(int) * a2) - *(int *)(byte_4BC818 + sizeof(int) * a1); //printf("%d %d\n",*(int *)(handle + sizeof(int) * a2),*(int *)(byte_4BC818 + sizeof(int) * a1)); //printf("X is: %d \n",X); // PASSED v21 += X * X; //printf("v21 is: %d \n",v21); // PASSED a1 += a5; // a1 = n and a5 = 2 (delay) a2 += a5; // a2 = D1C and a5 = 2 (delay) } //printf("%Lf \n",sqrtl(v21)); return sqrtl(v21); // sqrtl(44) = 6.6332495807107996982298654733414 } // 5 - 7 = -2 -> -2 * -2 + 0(v21) = 4 + 0 = 4(v21) a1 += a5 -> a1 = 1 + 2 = 3 ; a2 += a5 -> a2 = D1C + 2 = D1E i = 1 // 17 - 19 = -2 -> -2 * -2 + 4(v21) = 4 + 4 = 8(v21) a1 += a5 -> a1 = 3 + 2 = 5 ; a2 += a5 -> a2 = D1E + 2 = D20 i = 2 // 37 - 43 = -6 -> -6 * -6 + 8(v21) = 36 + 8 = 44(v21) a1 += a5 -> a1 = 5 + 2 = 7 ; a2 += a5 -> a2 = D20 + 2 = D22 i = 3 //v115, n, v92, Checked, v82 void sub_41B3D4(double a1, int a2, int a3, int a4, int a5) { int v5; // esi int v6; // ebx int v7; // ecx int v8; // eax int v9; // edx int v10; // [esp+1Ch] [ebp-10h] int i; // [esp+20h] [ebp-Ch] double v12; // [esp+24h] [ebp-8h] v12 = *(double *)byte_4BD308; v5 = 0; v6 = 0; //printf("v12: %+.25e\n", v12); //exit(0); for ( i = 0; v6 < a5; ++v6 ) { if ( *(double *)(byte_4BD308 + 12 * v6) > (long double)v12 ) { v12 = *(double *)(byte_4BD308 + 12 * v6); i = v6; //printf("I am at the first if"); } if ( a4 // 1 && !v5 // 0 && *(int *)(byte_4BD308 + 12 * v6 + 8) // 1 && (long double)(3 * a3) > fabs((double)(*(int *)(byte_4BD308 + 12 * v6 + 8) - a2)) ) { v5 = 1; v10 = v6; } } if ( a4 && v5 ) { v7 = byte_4BD308; if ( a1 < (long double)*(double *)(byte_4BD308 + 12 * v10) ) { *(double *)(byte_4BD308 + 12 * v10) = a1; *(int *)(v7 + 12 * v10 + 8) = a2; } } else if ( a1 < (long double)v12 ) { v8 = 3 * i; v9 = byte_4BD308; *(double *)(byte_4BD308 + 4 * v8) = a1; *(int *)(v9 + 4 * v8 + 8) = a2; } } // FIRST RUN: V115:6.6332495807108;n:1;v92:2;checked:1,v82:1 //void printDoubleAsHex(double value) //{ // uint64_t asInt; // memcpy(&asInt, &value, sizeof(asInt)); // Copy the double bits to uint64_t // printf("v12 = 0x%016" PRIx64 "\n", asInt); // Print as hexadecimal //} //void compare_doubles(double a, double b) //{ // if (memcmp(&a, &b, sizeof(double)) == 0) // { // printf("The two double values are identical at the bit level.\n"); // } else { // printf("The two double values are different at the bit level.\n"); // } //} /* 1, D1C, 0 , 3 , 2 n, v94, v88, v93, v92 long double __cdecl sub_41B088(int a1, int a2, int a3, int a4, int a5) { double v8; // [esp+14h] [ebp-B0h] double v9; // [esp+1Ch] [ebp-A8h] double v10; // [esp+24h] [ebp-A0h] double v11; // [esp+2Ch] [ebp-98h] double v12; // [esp+44h] [ebp-80h] double v13; // [esp+4Ch] [ebp-78h] double v14; // [esp+54h] [ebp-70h] double v15; // [esp+5Ch] [ebp-68h] double v16; // [esp+64h] [ebp-60h] double v17; // [esp+6Ch] [ebp-58h] double v18; // [esp+74h] [ebp-50h] double v19; // [esp+7Ch] [ebp-48h] double X; // [esp+84h] [ebp-40h] double v21; // [esp+8Ch] [ebp-38h] double v22; // [esp+94h] [ebp-30h] int i; // [esp+9Ch] [ebp-28h] __InitExceptBlockLDTC(); v21 = 0.0; v17 = 0.0; v18 = 0.0; v19 = 0.0; v12 = 0.0; v13 = 0.0; v14 = 0.0; v15 = 0.0; v16 = 0.0; v10 = 0.0; for ( i = 1; i <= a4; ++i ) { X = *(double *)(handle + 8 * a2) - *(float *)(dword_4BC818 + 4 * a1); v21 = X * X + v21; a1 += a5; a2 += a5; } v22 = sqrt(v21); return v22; } */