//
// sub_7CA9B4 from 0x7ca9b4 to 0x7caa94 (224 bytes)
//
// 1 xrefs:
// > ??> @ 0xac0a74
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
int __fastcall sub_7CA9B4(void *a1, _BYTE *a2, int a3, int a4)
{
int v6; // r6
unsigned int v7; // r4
int v8; // r0
int v9; // r2
int v10; // r0
_BYTE *v11; // r3
int v13; // [sp+4h] [bp-4h] BYREF
memcpy(&v13, a1, sizeof(v13));
v6 = v13;
if ( *(_DWORD *)(a4 + 20) == v13 )
return -1;
if ( v13 < ~v13 )
v7 = ~v13;
else
v7 = v13;
v8 = BN_num_bits_word(v7);
if ( (v8 & 7) != 0 )
{
v9 = (v8 + 7) >> 3;
if ( !a2 )
{
v10 = 0;
return v9 + v10;
}
v10 = 0;
LABEL_9:
if ( v9 > 0 )
{
v11 = &a2[v9];
if ( v6 < 0 )
{
do
{
*--v11 = ~(_BYTE)v7;
v7 >>= 8;
}
while ( v11 != a2 );
}
else
{
do
{
*--v11 = v7;
v7 >>= 8;
}
while ( v11 != a2 );
}
}
return v9 + v10;
}
v9 = (v8 + 7) >> 3;
if ( a2 )
{
v10 = 1;
*a2++ = v6 >> 31;
goto LABEL_9;
}
v10 = 1;
return v9 + v10;
}