//
// sub_509D3C from 0x509d3c to 0x509e30 (244 bytes)
//
// 10 xrefs:
// > std::__ndk1::__put_character_sequence> @ 0x509ed0
// > std::__ndk1::num_put>>::do_put @ 0x9620bc
// > std::__ndk1::num_put>>::do_put @ 0x962512
// > std::__ndk1::num_put>>::do_put @ 0x96260c
// > std::__ndk1::num_put>>::do_put @ 0x96270e
// > std::__ndk1::num_put>>::do_put @ 0x962894
// > std::__ndk1::num_put>>::do_put @ 0x962e6c
// > std::__ndk1::num_put>>::do_put @ 0x962fb4
// > std::__ndk1::money_put>>::do_put @ 0x96b634
// > std::__ndk1::money_put>>::do_put @ 0x96be90
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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:51:27 +0000
//
unsigned int __fastcall sub_509D3C(unsigned int a1, signed int a2, char *a3, int a4, int a5, unsigned __int8 a6)
{
unsigned int v8; // r5
int v9; // r4
int v10; // r8
signed int v11; // r4
char *v12; // r12
char *v13; // r1
int v15; // r6
unsigned int v16; // [sp+0h] [bp-10h] BYREF
signed int v17; // [sp+4h] [bp-Ch]
char *v18; // [sp+8h] [bp-8h]
int v19; // [sp+Ch] [bp-4h]
v16 = a1;
v17 = a2;
v18 = a3;
v19 = a4;
v8 = a1;
if ( a1 )
{
v9 = *(_DWORD *)(a5 + 12);
v10 = (int)&a3[-a2];
v11 = v9 <= a4 - a2 ? 0 : v9 - (a4 - a2);
if ( v10 <= 0 || (*(int (__fastcall **)(unsigned int))(*(_DWORD *)a1 + 48))(a1) == v10 )
{
if ( v11 > 0 )
{
v16 = 0;
v17 = 0;
v18 = nullptr;
if ( v11 > 10 )
{
v16 = (v11 + 16) & 0xFFFFFFF0 | 1;
v17 = v11;
v12 = (char *)operator new((v11 + 16) & 0xFFFFFFF0);
v18 = v12;
}
else
{
v12 = (char *)&v16 + 1;
LOBYTE(v16) = 2 * v11;
}
*((_BYTE *)memset(v12, a6, v11) + v11) = 0;
if ( (v16 & 1) != 0 )
v13 = v18;
else
v13 = (char *)&v16 + 1;
if ( (*(int (__fastcall **)(unsigned int, char *, signed int))(*(_DWORD *)v8 + 48))(v8, v13, v11) != v11 )
{
v8 = 0;
std::string::~string((int)&v16);
return v8;
}
std::string::~string((int)&v16);
}
v15 = a4 - (_DWORD)a3;
if ( v15 <= 0 || (*(int (__fastcall **)(unsigned int, char *, int))(*(_DWORD *)v8 + 48))(v8, a3, v15) == v15 )
{
*(_DWORD *)(a5 + 12) = 0;
return v8;
}
}
}
return 0;
}