//
// sub_140637120 from 0x140637120 to 0x140637334 (532 bytes)
//
// 2 xrefs:
// > AnimatedGameObject::displayFrameChanged @ 0x140646ebc
// > ??> @ 0x140930c8c
//
// 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:35:31 +0000
//
_QWORD *__fastcall sub_140637120(_QWORD *a1, _BYTE *a2)
{
size_t v3; // r8
unsigned __int64 v4; // rdi
size_t v5; // r15
void **v6; // rdx
_QWORD *v7; // r14
unsigned __int64 v8; // r8
unsigned __int64 v9; // rcx
char *v10; // rbx
__int64 v11; // rax
char *v12; // r9
void *v13; // rcx
void *v14; // rcx
void *Block[2]; // [rsp+40h] [rbp-19h] BYREF
size_t v17; // [rsp+50h] [rbp-9h]
unsigned __int64 v18; // [rsp+58h] [rbp-1h]
void *v19[2]; // [rsp+60h] [rbp+7h] BYREF
unsigned __int64 v20; // [rsp+70h] [rbp+17h]
unsigned __int64 v21; // [rsp+78h] [rbp+1Fh]
*(_OWORD *)a1 = 0;
a1[2] = 0;
a1[3] = 0;
v3 = -1;
do
++v3;
while ( a2[v3] );
sub_14003D230(a1, a2, v3);
*(_OWORD *)v19 = 0;
v20 = 0;
v21 = 0;
sub_14003D230(v19, "_001.png", 8u);
*(_OWORD *)Block = 0;
v17 = 0;
v18 = 0;
sub_14003D230(Block, "_glow_001.png", 0xDu);
v4 = 0;
v5 = v17;
while ( 1 )
{
v6 = v19;
if ( v21 > 0xF )
v6 = (void **)v19[0];
v7 = a1;
if ( a1[3] > 0xFu )
v7 = (_QWORD *)*a1;
v8 = v20;
v9 = a1[2];
if ( v20 > v9 || v4 > v9 - v20 )
break;
if ( v20 )
{
v10 = (char *)v7 + v9;
v11 = sub_1406774C0((char *)v7 + v4, (char *)v7 + v9, v6, v20);
if ( (char *)v11 == v10 )
break;
v4 = v11 - (_QWORD)v7;
v8 = v20;
}
if ( v4 == -1 )
break;
v12 = (char *)Block;
if ( v18 > 0xF )
v12 = (char *)Block[0];
sub_140045CE0(a1, v4, v8, v12, v5);
v5 = v17;
v4 += v17;
}
if ( v18 > 0xF )
{
v13 = Block[0];
if ( v18 + 1 >= 0x1000 )
{
v13 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v13 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v13);
}
if ( v21 > 0xF )
{
v14 = v19[0];
if ( v21 + 1 >= 0x1000 )
{
v14 = *((void **)v19[0] - 1);
if ( (unsigned __int64)((char *)v19[0] - (char *)v14 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v14);
}
return a1;
}