Decompile fn_04842 (XorWithKey16)

Batch #4178 by eAthena: 0 byte-identical, 1 confirmed by peer review.

- fn_04842 XorWithKey16: logic confirmed by peer review

Peer-reviewed-by: superintelligence, KWDev, Gravity
Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
This commit is contained in:
ragnarok-clanker 2026-10-30 01:44:36 +00:00
commit 8335c06d51

View file

@ -6,6 +6,7 @@
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <emmintrin.h>
#include <random>
#include <xhash>
#include <zlib.h>
@ -114,6 +115,25 @@ namespace {
}
}
// OFFSET: 0x00644260
// FUNCTION: fn_04842
void XorWithKey16(const std::uint8_t* key, const std::uint8_t* input, std::size_t length, std::uint8_t* output) {
const __m128i mask = _mm_loadu_si128(reinterpret_cast<const __m128i*>(key));
if (length >= 16) {
std::size_t blocks = length >> 4;
do {
_mm_storeu_si128(reinterpret_cast<__m128i*>(output), _mm_xor_si128(_mm_loadu_si128(reinterpret_cast<const __m128i*>(input)), mask));
input += 16;
output += 16;
} while (--blocks != 0);
}
const std::size_t remainder = length & 0xF;
for (std::size_t i = 0; i < remainder; ++i) {
output[i] = input[i] ^ key[i];
}
}
// OFFSET: 0x00654410
// FUNCTION: fn_04984
int sub_654410() {