//
// sub_1404C7840 from 0x1404c7840 to 0x1404c78cf (143 bytes)
//
// 15 xrefs:
// > sub_1404C4CF0 @ 0x1404c4d30
// > sub_1404C4CF0 @ 0x1404c4d4d
// > sub_1404C5230 @ 0x1404c52df
// > sub_1404C5230 @ 0x1404c52eb
// > sub_1404C5230 @ 0x1404c52f7
// > sub_1404C5230 @ 0x1404c58da
// > sub_1404C5230 @ 0x1404c58e8
// > sub_1404C5230 @ 0x1404c5c89
// > sub_1404C5230 @ 0x1404c5c95
// > sub_1404C5230 @ 0x1404c5ca1
// > sub_1404C64E0 @ 0x1404c6577
// > sub_1404C64E0 @ 0x1404c65d7
// > ??> @ 0x1406a948c
// > ??> @ 0x1406a949c
// > ??> @ 0x1406dd1f0
//
// 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
//
__int64 __fastcall sub_1404C7840(__int64 *a1, unsigned __int64 a2)
{
char *v2; // rsi
__int64 v4; // r8
unsigned __int64 v5; // rcx
__int64 result; // rax
size_t v7; // rbx
v2 = (char *)a1[1];
v4 = *a1;
v5 = (__int64)&v2[-*a1] >> 3;
if ( a2 >= v5 )
{
if ( a2 > v5 )
{
if ( a2 <= (a1[2] - v4) >> 3 )
{
v7 = 8 * (a2 - v5);
memset(v2, 0, v7);
a1[1] = (__int64)&v2[v7];
return (__int64)&v2[v7];
}
else
{
return sub_1404C7AD0(a1);
}
}
}
else
{
result = v4 + 8 * a2;
a1[1] = result;
}
return result;
}