//
// sub_140522B40 from 0x140522b40 to 0x140522d55 (533 bytes)
//
// 2 xrefs:
// > sub_140543730 @ 0x1405456a8
// > ??> @ 0x14092b4b4
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:33:38 +0000
//
// Hidden C++ exception states: #wind=3
__int64 __fastcall sub_140522B40(__int64 a1, __int64 a2)
{
__int64 ***v4; // rdi
__int64 **i; // rbx
_BYTE *v6; // rax
size_t v7; // r8
void *v8; // rcx
__int128 v10; // [rsp+30h] [rbp-D0h] BYREF
_BYTE v11[16]; // [rsp+48h] [rbp-B8h] BYREF
void *Block[2]; // [rsp+58h] [rbp-A8h] BYREF
__m128i si128; // [rsp+68h] [rbp-98h]
_BYTE v14[528]; // [rsp+80h] [rbp-80h] BYREF
_OWORD v15[2]; // [rsp+290h] [rbp+190h] BYREF
fmt::BasicWriter::BasicWriter(v14);
v15[0] = 0;
v15[1] = _mm_load_si128((const __m128i *)&xmmword_140836520);
LOWORD(v15[0]) = 58;
fmt::BasicWriter::operator<<(v14, *(unsigned int *)(a2 + 16));
v10 = *(_OWORD *)fmt::BasicStringRef::BasicStringRef(v11, v15);
fmt::BasicWriter::operator<<(v14, &v10);
v4 = *(__int64 ****)(a2 + 8);
for ( i = *v4; i != (__int64 **)v4; i = (__int64 **)*i )
{
fmt::BasicWriter::operator<<(v14, *((unsigned int *)i + 4));
v10 = *(_OWORD *)fmt::BasicStringRef::BasicStringRef(v11, v15);
fmt::BasicWriter::operator<<(v14, &v10);
WriteArchive::process_1((__int64)v14, i + 3);
}
v6 = (_BYTE *)fmt::BasicWriter::c_str(v14);
*(_OWORD *)Block = 0;
si128 = 0;
v7 = -1;
do
++v7;
while ( v6[v7] );
sub_14003D230(Block, v6, v7);
v10 = *(_OWORD *)fmt::BasicStringRef::BasicStringRef(v11, Block);
fmt::BasicWriter::operator<<(a1, &v10);
v10 = *(_OWORD *)fmt::BasicStringRef::BasicStringRef(v11, a1 + 528);
fmt::BasicWriter::operator<<(a1, &v10);
if ( si128.m128i_i64[1] > 0xFuLL )
{
v8 = Block[0];
if ( (unsigned __int64)(si128.m128i_i64[1] + 1) >= 0x1000 )
{
v8 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v8 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v8);
}
si128 = _mm_load_si128((const __m128i *)&Size);
LOBYTE(Block[0]) = 0;
sub_14003D310((__int64)v15);
return fmt::BasicWriter::~BasicWriter(v14);
}