//
// GJKeybindManager::parseImportFile from 0xc0c0d0 to 0xc0c5ec (1308 bytes)
//
// 2 xrefs:
// > KeybindingsSettingsPopup::onImport @ 0xcf0708
// > ??> @ 0x93700
//
// This function is hookable on this platform (idp: arm, 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 13:03:55 +0000
//
__int64 __fastcall GJKeybindManager::parseImportFile(GJKeybindManager *a1, __int64 a2, int *a3, _DWORD *a4, int *a5)
{
int v10; // w22
cocos2d::CCString *v11; // x0
cocos2d::CCString *v12; // x0
size_t v13; // x0
size_t v14; // x19
char *v15; // x28
int v16; // w26
int v17; // w19
unsigned __int64 v19; // x28
int v20; // w19
size_t v21; // x0
int v22; // w3
__int64 v23; // x0
int v24; // w1
unsigned __int64 v25; // x1
char *v26; // x19
char *v27; // x7
size_t v28; // x6
unsigned __int64 v29; // x1
void *v30; // x3
char v31; // w0
__int64 v32; // x3
char v33; // w0
char *CString; // [xsp+68h] [xbp+68h]
size_t v35; // [xsp+68h] [xbp+68h]
char *v36[2]; // [xsp+78h] [xbp+78h] BYREF
void *v37; // [xsp+88h] [xbp+88h]
__int64 v38[2]; // [xsp+90h] [xbp+90h] BYREF
void *v39; // [xsp+A0h] [xbp+A0h]
__int64 v40; // [xsp+A8h] [xbp+A8h] BYREF
unsigned __int64 v41; // [xsp+B0h] [xbp+B0h]
void *v42; // [xsp+B8h] [xbp+B8h]
__int64 v43[2]; // [xsp+C0h] [xbp+C0h] BYREF
char *v44; // [xsp+D0h] [xbp+D0h]
__int64 v45; // [xsp+D8h] [xbp+D8h] BYREF
size_t v46; // [xsp+E0h] [xbp+E0h]
void *v47; // [xsp+E8h] [xbp+E8h]
__int64 v48[2]; // [xsp+F0h] [xbp+F0h] BYREF
char *v49; // [xsp+100h] [xbp+100h]
if ( (*(_BYTE *)a2 & 1) != 0 )
{
**(_BYTE **)(a2 + 16) = 0;
*(_QWORD *)(a2 + 8) = 0;
}
else
{
*(_BYTE *)(a2 + 1) = 0;
*(_BYTE *)a2 = 0;
}
*a3 = 0;
*a4 = 0;
*a5 = 0;
v36[0] = nullptr;
v36[1] = nullptr;
v37 = nullptr;
v38[0] = 0;
v38[1] = 0;
v39 = nullptr;
std::string::__init(v38, "keybinds.gdkb", 0xDu);
v10 = (unsigned __int8)GameToolbox::showOpenFileDialog(
(__int64)"Import Keybinds",
(__int64)"GD Keybind Files (*.gdkb)",
(__int64)v38,
(unsigned __int8 *)v36);
if ( (v38[0] & 1) != 0 )
operator delete(v39);
if ( !v10 )
{
v17 = -1;
goto LABEL_16;
}
v11 = (cocos2d::CCString *)((char *)v36 + 1);
if ( ((__int64)v36[0] & 1) != 0 )
v11 = (cocos2d::CCString *)v37;
v12 = (cocos2d::CCString *)cocos2d::CCString::createWithContentsOfFile(v11, (const char *)LOBYTE(v36[0]));
if ( !v12 )
goto LABEL_22;
CString = (char *)cocos2d::CCString::getCString(v12);
v40 = 0;
v41 = 0;
v42 = nullptr;
v13 = strlen(CString);
std::string::__init(&v40, CString, v13);
if ( (v40 & 1) == 0 )
{
v17 = (int)(unsigned __int8)v40 >> 1;
if ( !v17 )
goto LABEL_16;
v14 = std::string::find((__int64)&v40, 0x3Bu, 0);
if ( v14 != -1 )
goto LABEL_12;
LABEL_22:
v17 = 0;
goto LABEL_16;
}
if ( !v41 || (v14 = std::string::find((__int64)&v40, 0x3Bu, 0), v14 == -1) )
{
v17 = 0;
goto LABEL_24;
}
LABEL_12:
std::string::basic_string(v43, (__int64)&v40, 0, v14);
if ( (v43[0] & 1) != 0 )
{
v15 = v44;
v16 = atoi(v44);
operator delete(v15);
}
else
{
v16 = atoi((const char *)v43 + 1);
}
if ( v16 != 1 )
{
v17 = 0;
if ( (v40 & 1) != 0 )
goto LABEL_24;
goto LABEL_16;
}
v19 = std::string::find((__int64)&v40, 0x3Bu, v14 + 1);
if ( v19 == -1 )
{
v19 = (unsigned __int8)v40 >> 1;
if ( (v40 & 1) != 0 )
v19 = v41;
}
std::string::basic_string(&v45, (__int64)&v40, v14 + 1, ~v14 + v19);
while ( 1 )
{
v20 = (unsigned __int8)v45;
if ( (v45 & 1) != 0 )
{
while ( v46 )
{
v21 = v46 - 1;
v22 = *((unsigned __int8 *)v47 + v46 - 1);
if ( v22 != 10 && v22 != 13 )
break;
--v46;
*((_BYTE *)v47 + v21) = 0;
v20 = (unsigned __int8)v45;
if ( (v45 & 1) == 0 )
goto LABEL_32;
}
if ( !v46 )
{
v17 = 0;
goto LABEL_38;
}
LABEL_44:
v25 = (unsigned __int8)v40 >> 1;
if ( (v40 & 1) != 0 )
v25 = v41;
if ( v19 < v25 )
{
std::string::basic_string(v48, (__int64)&v40, v19 + 1, 0xFFFFFFFFFFFFFFFFLL);
if ( (v48[0] & 1) != 0 )
{
v26 = v49;
*a5 = atoi(v49);
operator delete(v26);
}
else
{
*a5 = atoi((const char *)v48 + 1);
}
}
GJKeybindManager::parseBindsBlob(a1, (__int64)&v45, 0, a3, a4);
if ( *a3 <= 0 )
{
v17 = 0;
if ( (v45 & 1) == 0 )
goto LABEL_39;
goto LABEL_38;
}
if ( (v45 & 1) != 0 )
{
v27 = (char *)v47;
v28 = v46;
}
else
{
v28 = (unsigned __int8)v45 >> 1;
v27 = (char *)&v45 + 1;
}
if ( (*(_BYTE *)a2 & 1) != 0 )
{
v29 = (*(_QWORD *)a2 & 0xFFFFFFFFFFFFFFFELL) - 1;
if ( v28 <= v29 )
{
v30 = *(void **)(a2 + 16);
goto LABEL_55;
}
v32 = *(_QWORD *)(a2 + 8);
}
else
{
if ( v28 <= 0x16 )
{
v30 = (void *)(a2 + 1);
LABEL_55:
if ( v28 )
{
v35 = v28;
v30 = memmove(v30, v27, v28);
v28 = v35;
}
*((_BYTE *)v30 + v28) = 0;
if ( (*(_BYTE *)a2 & 1) != 0 )
{
v31 = v45;
v17 = 1;
*(_QWORD *)(a2 + 8) = v28;
if ( (v31 & 1) == 0 )
goto LABEL_39;
}
else
{
v33 = v45;
v17 = 1;
*(_BYTE *)a2 = 2 * v28;
if ( (v33 & 1) == 0 )
goto LABEL_39;
}
LABEL_38:
operator delete(v47);
goto LABEL_39;
}
v32 = *(_BYTE *)a2 >> 1;
v29 = 22;
}
std::string::__grow_by_and_replace(a2, v29, v28 - v29, v32, 0, v32, v28, v27);
v17 = 1;
if ( (v45 & 1) == 0 )
goto LABEL_39;
goto LABEL_38;
}
LABEL_32:
v17 = v20 >> 1;
if ( !v17 )
break;
v23 = v17 - 1LL;
v24 = *((unsigned __int8 *)&v45 + v23 + 1);
if ( v24 != 10 && v24 != 13 )
break;
LOBYTE(v45) = 2 * (v17 - 1);
*((_BYTE *)&v45 + v23 + 1) = 0;
}
if ( v17 )
goto LABEL_44;
LABEL_39:
if ( (v40 & 1) != 0 )
LABEL_24:
operator delete(v42);
LABEL_16:
if ( ((__int64)v36[0] & 1) != 0 )
operator delete(v37);
return (unsigned int)v17;
}