I am trying to reverse engineer some decomiled code which originally had been written in C/C++, i.e. I suspect that the below FPU related code sequence is probably derived from some simple C-code "double" handling that justs looks more complicated in the generated assembly code. Leading up to this point, some floating point multiplications had been performed with the result in ST0 (corresponding to d1). I've read the docs on what the underlying FPU operations technically do, still the intention of the respective code sequence still isn't obvious to me.
d1 = (float10)1.442695040888963 *(float10)0.6931471805599453 * (float10)DOUBLE_00430088 * (float10)param_1[0x58];
d2 = ROUND(d1);
d1 = (float10)f2xm1(d1 - d2);
d1 = (float10)fscale((float10)1 + d1,d2);
what is the intended change performed to the original d1 result, i.e. what would the C code have done with the original d1 "double"?
PS: below the actual x86 code (just in case Ghidra misinterpreted something while decompiling):
* Push ST(i) onto the FPU register stack, i.e. *
* duplicate ST0 *
**************************************************************
0040aeef d9 c0 FLD ST0
**************************************************************
* Rounds the source value in the ST(0) register *
* to the nearest integral value, depending on *
* the current rounding mode (lets suppose some *
* "floor" mode was used?) *
**************************************************************
0040aef1 d9 fc FRNDINT
**************************************************************
* Exchange the contents of ST(0) and ST(1). *
**************************************************************
0040aef3 d9 c9 FXCH
**************************************************************
* get fractional part? *
**************************************************************
0040aef5 d8 e1 FSUB d2[0],d1[0]
**************************************************************
* Computes the exponential value of 2 to the power *
* of the source operand minus 1. *
**************************************************************
0040aef7 d9 f0 F2XM1
**************************************************************
* Push +1.0 onto the FPU register stack. *
**************************************************************
0040aef9 d9 e8 FLD1
**************************************************************
* Add ST(0) to ST(1), store result in ST(1), *
* and pop the register stack. *
**************************************************************
0040aefb de c1 FADDP
**************************************************************
* Scale ST(0) by ST(1). This instruction provides *
* rapid multiplication or division by integral *
* powers of 2. *
**************************************************************
0040aefd d9 fd FSCALE
**************************************************************
* The FSTP instruction copies the value in the ST(0) *
* register to the destination operand and then pops *
* the register stack. *
**************************************************************
0040aeff dd d9 FSTP d1[0]