//
// sub_14003B190 from 0x14003b190 to 0x14003b2d4 (324 bytes)
//
// 54 xrefs:
// > sub_14003AE70 @ 0x14003af6f
// > sub_14003AE70 @ 0x14003af92
// > sub_14003AE70 @ 0x14003afbc
// > sub_14003AE70 @ 0x14003afdf
// > sub_14003AE70 @ 0x14003b0c6
// > sub_14003AE70 @ 0x14003b0e6
// > CCTextInputNode::onTextFieldInsertText @ 0x140050697
// > GameLevelManager::uploadLevel @ 0x14014cdd3
// > GameLevelManager::onGetOnlineLevelsCompleted @ 0x14014ea49
// > GameLevelManager::onGetOnlineLevelsCompleted @ 0x14014ea69
// > GameLevelManager::onGetMapPacksCompleted @ 0x14014f9c3
// > GameLevelManager::onGetMapPacksCompleted @ 0x14014f9e3
// > GameLevelManager::uploadLevelList @ 0x1401501b4
// > GameLevelManager::processOnDownloadLevelCompleted @ 0x140152c73
// > sub_140179B40 @ 0x140179c18
// > GJSmartTemplate::getSimplifiedKey @ 0x1402b160a
// > GJSmartTemplate::getSimplifiedKey @ 0x1402b1616
// > GJSmartTemplate::getSimplifiedKey @ 0x1402b1622
// > GJSmartTemplate::getSimplifiedKey @ 0x1402b162e
// > GJSmartTemplate::getSimplifiedKey @ 0x1402b163a
// > GJSmartTemplate::getSimplifiedKey @ 0x1402b1647
// > GJSmartTemplate::getSimplifiedKey @ 0x1402b1654
// > GJSmartTemplate::getSimplifiedKey @ 0x1402b1660
// > GJSmartTemplate::getSimplifiedKey @ 0x1402b166c
// > GJSmartTemplate::keyFromNeighbors @ 0x1402b3e57
// > GJSmartTemplate::keyFromNeighbors @ 0x1402b3e67
// > GJSmartTemplate::keyFromNeighbors @ 0x1402b3e73
// > GJSmartTemplate::keyFromNeighbors @ 0x1402b3e7f
// > GJSmartTemplate::keyFromNeighbors @ 0x1402b3e8b
// > GJSmartTemplate::keyFromNeighbors @ 0x1402b3e97
// > GJSmartTemplate::keyFromNeighbors @ 0x1402b3ea3
// > GJSmartTemplate::keyFromNeighbors @ 0x1402b3eaf
// > GJSmartTemplate::keyFromNeighbors @ 0x1402b3ebc
// > GJSmartTemplate::rotateKey @ 0x1402b45f1
// > GJSmartTemplate::rotateKey @ 0x1402b4601
// > GJSmartTemplate::rotateKey @ 0x1402b460d
// > GJSmartTemplate::rotateKey @ 0x1402b4619
// > GJSmartTemplate::rotateKey @ 0x1402b4625
// > GJSmartTemplate::rotateKey @ 0x1402b4631
// > GJSmartTemplate::rotateKey @ 0x1402b463d
// > GJSmartTemplate::rotateKey @ 0x1402b4649
// > GJSmartTemplate::rotateKey @ 0x1402b4655
// > GJSmartTemplate::flipKey @ 0x1402b492a
// > GJSmartTemplate::flipKey @ 0x1402b493a
// > GJSmartTemplate::flipKey @ 0x1402b4946
// > GJSmartTemplate::flipKey @ 0x1402b4952
// > GJSmartTemplate::flipKey @ 0x1402b495e
// > GJSmartTemplate::flipKey @ 0x1402b496a
// > GJSmartTemplate::flipKey @ 0x1402b4976
// > GJSmartTemplate::flipKey @ 0x1402b4982
// > GJSmartTemplate::flipKey @ 0x1402b498e
// > ??> @ 0x140661844
// > ??> @ 0x140661884
// > ??> @ 0x1406c3d8c
//
// 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
//
void __fastcall sub_14003B190(void **Src, char a2)
{
size_t v2; // rsi
unsigned __int64 v4; // rbp
void **v5; // rbx
__int64 v6; // rdi
unsigned __int64 v7; // rcx
unsigned __int64 v8; // rdx
_QWORD *v9; // rax
_QWORD *v10; // r14
_QWORD *v11; // rdi
v2 = (size_t)Src[2];
v4 = (unsigned __int64)Src[3];
v5 = Src;
if ( v2 >= v4 )
{
v6 = 0x7FFFFFFFFFFFFFFFLL;
if ( v2 == 0x7FFFFFFFFFFFFFFFLL )
sub_140007B50();
v7 = (v2 + 1) | 0xF;
if ( v7 <= 0x7FFFFFFFFFFFFFFFLL )
{
v8 = v4 >> 1;
if ( v4 <= 0x7FFFFFFFFFFFFFFFLL - (v4 >> 1) )
{
v6 = (v2 + 1) | 0xF;
if ( v7 < v8 + v4 )
v6 = v8 + v4;
}
}
v9 = sub_14003AA10(v6 + 1);
v5[2] = (void *)(v2 + 1);
v10 = v9;
v5[3] = (void *)v6;
if ( v4 <= 0xF )
{
memcpy(v9, v5, v2);
*((_BYTE *)v10 + v2) = a2;
*((_BYTE *)v10 + v2 + 1) = 0;
}
else
{
v11 = *v5;
memcpy(v9, *v5, v2);
*((_BYTE *)v10 + v2) = a2;
*((_BYTE *)v10 + v2 + 1) = 0;
if ( v4 + 1 >= 0x1000 )
{
if ( (unsigned __int64)v11 - *(v11 - 1) - 8 > 0x1F )
invalid_parameter_noinfo_noreturn();
v11 = (_QWORD *)*(v11 - 1);
}
j_j_free(v11);
}
*v5 = v10;
}
else
{
Src[2] = (void *)(v2 + 1);
if ( v4 > 0xF )
v5 = (void **)*Src;
*((_BYTE *)v5 + v2) = a2;
*((_BYTE *)v5 + v2 + 1) = 0;
}
}