Match exp_by_squaring function (#110)

Signed-off-by: Taggerung <tyler.taggerung@gmail.com>
This commit is contained in:
Tyler McGavran
2021-12-21 00:56:24 -05:00
committed by GitHub
parent 48a06f2fa5
commit 8aca5f519e
3 changed files with 20 additions and 68 deletions
+19 -35
View File
@@ -3,51 +3,35 @@
#include <defines.h>
#include "variables.h"
#ifdef MIPS_TO_C
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
f64 func_80091750(f64 arg0, s32 arg2) {
s32 temp_t7;
s32 phi_v0;
s32 phi_v0_2;
f64 phi_f2;
f64 phi_f2_2;
f64 phi_f2_3;
f64 phi_f12;
f64 exponent_by_squaring(f64 base, s32 exponent) {
s32 positive_exponent;
f64 result;
phi_f12 = arg0;
if (arg2 < 0) {
phi_v0 = -arg2;
if (exponent < 0) {
positive_exponent = -exponent;
} else {
phi_v0 = arg2;
positive_exponent = exponent;
}
phi_v0_2 = phi_v0;
phi_f2 = 1.0;
phi_f2_3 = 1.0;
if (phi_v0 != 0) {
result = 1.0;
if (positive_exponent != 0) {
do {
temp_t7 = phi_v0_2 >> 1;
phi_f2_2 = phi_f2_3;
if ((phi_v0_2 & 1) != 0) {
phi_f2_2 = phi_f2_3 * phi_f12;
if ((positive_exponent & 1) != 0) {
result *= base;
}
phi_v0_2 = temp_t7;
phi_f2 = phi_f2_2;
phi_f2_3 = phi_f2_2;
phi_f12 *= phi_f12;
} while (temp_t7 != 0);
positive_exponent >>= 1;
base *= base;
} while (positive_exponent != 0);
}
if (arg2 >= 0) {
return phi_f2;
if (exponent >= 0) {
return result;
}
return 1.0 / phi_f2;
return 1.0 / result;
}
#else
GLOBAL_ASM("asm/non_matchings/code_80091750/func_80091750.s")
#endif
#ifdef MIPS_TO_C
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
f64 func_80091750(s32); // extern
f64 exponent_by_squaring(s32); // extern
f64 func_8009186C(f64); // extern
f64 func_8009195C(f64, f64); // extern
extern f64 D_800F0CB0;
@@ -59,7 +43,7 @@ f64 func_800917B0(f64 arg0, f64 arg1, f64 arg2) {
phi_a2 = arg2;
if ((arg1 <= D_800F0CB0) && (D_800F0CB8 <= arg1) && (temp_f8 = arg1, phi_a2 = (bitwise f64) temp_f8, (arg1 == temp_f8))) {
return func_80091750(temp_f8);
return exponent_by_squaring(temp_f8);
}
if (arg0 > 0.0) {
arg2 = arg1;