//
// PlatformToolbox::spriteFromSavedFile from 0x1004bd550 to 0x1004bd8fd (941 bytes)
//
// 0 xrefs:
//
// 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 12:31:04 +0000
//
char *__fastcall PlatformToolbox::spriteFromSavedFile(__int64 a1)
{
std::string *v2; // rdi
const char *v3; // r14
size_t v4; // rax
std::string::size_type v5; // r15
std::string *v6; // r12
size_t v7; // r13
std::string::pointer data; // r13
unsigned __int64 size; // r15
std::string::size_type v10; // rax
signed __int64 v11; // rdx
char *v12; // r15
std::string *v13; // rax
char *v14; // rax
std::string::size_type v15; // rax
std::string::size_type v16; // r15
std::string::size_type v17; // rcx
__int64 v18; // rax
__int64 v19; // rsi
__int64 v20; // rax
char *result; // rax
__int64 v22; // rbx
NSString *v23; // rbx
NSArray *v24; // rax
id v25; // rax
id v26; // rbx
NSFileManager *v27; // rax
unsigned __int8 v28; // cl
const char *v29; // r14
size_t v30; // rax
size_t v31; // rbx
char *v32; // r15
char *v33; // rdi
size_t v34; // r12
char *v35; // rbx
std::string::value_type __s[15]; // [rsp+1h] [rbp-6Fh] BYREF
_QWORD v37[2]; // [rsp+18h] [rbp-58h] BYREF
void *v38; // [rsp+28h] [rbp-48h]
std::string __dst[2]; // [rsp+30h] [rbp-40h] BYREF
v2 = (std::string *)cocos2d::CCDirector::sharedDirector();
if ( sub_100479350((__int64)v2) != 2.0 )
goto LABEL_33;
if ( (*(_BYTE *)a1 & 1) != 0 )
v3 = *(const char **)(a1 + 16);
else
v3 = (const char *)(a1 + 1);
v2 = (std::string *)v3;
v4 = strlen(v3);
if ( v4 >= 0xFFFFFFFFFFFFFFF8LL )
goto LABEL_55;
v5 = v4;
if ( v4 >= 0x17 )
{
v7 = 26;
if ( (v4 | 7) != 0x17 )
v7 = (v4 | 7) + 1;
v6 = (std::string *)operator new(v7);
__dst[0].__r_.__value_.__r.__words[2] = (std::string::size_type)v6;
__dst[0].__r_.__value_.__r.__words[0] = v7 + 1;
__dst[0].__r_.__value_.__l.__size_ = v5;
goto LABEL_12;
}
__dst[0].__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v4);
v6 = (std::string *)((char *)&__dst[0].__r_.__value_.__l.0 + 1);
if ( v4 )
{
LABEL_12:
v2 = v6;
memcpy(v6, v3, v5);
}
data = __dst[0].__r_.__value_.__s.__data_;
*((_BYTE *)&v6->__r_.__value_.__s.0 + v5) = 0;
*(_DWORD *)((char *)v37 + 1) = 1735290926;
strcpy(__s, "-hd.png");
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
{
data = __dst[0].__r_.__value_.__l.__data_;
size = __dst[0].__r_.__value_.__l.__size_;
}
else
{
size = *(_BYTE *)&__dst[0].__r_.__value_.__l.0 >> 1;
}
v10 = 0;
LABEL_17:
v11 = size - v10;
if ( (__int64)(size - v10) >= 4 )
{
v12 = &data[size];
v13 = (std::string *)&data[v10];
do
{
v2 = v13;
v14 = (char *)memchr(v13, 46, v11 - 3);
if ( !v14 )
break;
if ( *(_DWORD *)v14 == *(_DWORD *)((char *)v37 + 1) )
{
if ( v14 != v12 )
{
v15 = v14 - data;
if ( v15 != -1 )
{
v2 = __dst;
v16 = v15;
std::string::replace(__dst, v15, 4u, __s, 7u);
v17 = v16;
if ( (*(_BYTE *)&__dst[0].__r_.__value_.__s.0 & 1) != 0 )
{
data = __dst[0].__r_.__value_.__l.__data_;
size = __dst[0].__r_.__value_.__l.__size_;
v10 = v17 + 7;
if ( __dst[0].__r_.__value_.__l.__size_ >= v17 + 7 )
goto LABEL_17;
}
else
{
size = *(_BYTE *)&__dst[0].__r_.__value_.__l.0 >> 1;
data = __dst[0].__r_.__value_.__s.__data_;
v10 = v17 + 7;
if ( size >= v17 + 7 )
goto LABEL_17;
}
}
}
break;
}
v13 = (std::string *)(v14 + 1);
v11 = v12 - (char *)v13;
}
while ( v12 - (char *)v13 >= 4 );
}
if ( (*(_BYTE *)a1 & 1) != 0 )
{
v2 = *(std::string **)(a1 + 16);
operator delete(v2);
}
*(std::string *)a1 = __dst[0];
LABEL_33:
v18 = cocos2d::CCTextureCache::sharedTextureCache(v2);
if ( (*(_BYTE *)a1 & 1) != 0 )
v19 = *(_QWORD *)(a1 + 16);
else
v19 = a1 + 1;
v20 = cocos2d::CCTextureCache::addImage(v18, v19, 0);
if ( v20 )
return cocos2d::CCSprite::createWithTexture_1(v20);
if ( (*(_BYTE *)a1 & 1) != 0 )
v22 = *(_QWORD *)(a1 + 16);
else
v22 = a1 + 1;
v23 = +[NSString stringWithUTF8String:](&OBJC_CLASS___NSString, "stringWithUTF8String:", v22);
v24 = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, 1u, 1);
v25 = -[NSArray objectAtIndex:](v24, "objectAtIndex:", 0);
v26 = objc_msgSend(v25, "stringByAppendingPathComponent:", v23);
v27 = +[NSFileManager defaultManager](&OBJC_CLASS___NSFileManager, "defaultManager");
v28 = -[NSFileManager fileExistsAtPath:](v27, "fileExistsAtPath:", v26);
result = nullptr;
if ( v28 )
{
v29 = (const char *)objc_msgSend(v26, "cStringUsingEncoding:", 4);
v30 = strlen(v29);
if ( v30 < 0xFFFFFFFFFFFFFFF8LL )
{
v31 = v30;
if ( v30 >= 0x17 )
{
v34 = 26;
if ( (v30 | 7) != 0x17 )
v34 = (v30 | 7) + 1;
v32 = (char *)operator new(v34);
v38 = v32;
v37[0] = v34 + 1;
v37[1] = v31;
}
else
{
LOBYTE(v37[0]) = 2 * v30;
v32 = (char *)v37 + 1;
if ( !v30 )
{
BYTE1(v37[0]) = 0;
if ( (v37[0] & 1) != 0 )
{
LABEL_47:
v33 = (char *)v38;
goto LABEL_53;
}
LABEL_52:
v33 = (char *)v37 + 1;
LABEL_53:
result = cocos2d::CCSprite::create_1((__int64)v33);
if ( (v37[0] & 1) != 0 )
{
v35 = result;
operator delete(v38);
return v35;
}
return result;
}
}
memmove(v32, v29, v31);
v32[v31] = 0;
if ( (v37[0] & 1) != 0 )
goto LABEL_47;
goto LABEL_52;
}
LABEL_55:
sub_100003630();
}
return result;
}