//
// GJKeybindManager::parseImportFile from 0x7153e4 to 0x7156ae (714 bytes)
//
// 1 xrefs:
// > KeybindingsSettingsPopup::onImport @ 0x797600
//
// 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:57:47 +0000
//
int __fastcall GJKeybindManager::parseImportFile(
GJKeybindManager *a1,
unsigned __int8 *a2,
int *a3,
_DWORD *a4,
int *a5)
{
bool v7; // zf
void *v9; // r3
int v10; // r2
int v11; // r6
cocos2d::CCString *v12; // r0
cocos2d::CCString *v13; // r0
int v14; // r6
const char *CString; // r6
size_t v16; // r0
int v17; // r3
size_t v18; // r8
const char *v19; // r0
int v20; // r11
unsigned int v21; // r6
int v22; // r1
size_t v23; // r2
char *v24; // r0
char *v25; // r0
size_t v26; // r2
size_t v27; // r3
unsigned int v28; // r3
const char *v29; // r0
char *v30; // r1
size_t v31; // r6
int v32; // r3
unsigned int v33; // r2
void *v34; // r3
int v35; // r3
int v37; // r3
_DWORD v39[2]; // [sp+24h] [bp+0h] BYREF
cocos2d::CCString *v40; // [sp+2Ch] [bp+8h]
int v41[3]; // [sp+30h] [bp+Ch] BYREF
int v42; // [sp+3Ch] [bp+18h] BYREF
unsigned int v43; // [sp+40h] [bp+1Ch]
int v44; // [sp+44h] [bp+20h]
int v45[3]; // [sp+48h] [bp+24h] BYREF
int v46; // [sp+54h] [bp+30h] BYREF
size_t v47; // [sp+58h] [bp+34h]
void *v48; // [sp+5Ch] [bp+38h]
int v49[5]; // [sp+60h] [bp+3Ch] BYREF
v7 = (*a2 & 1) == 0;
v9 = &_stack_chk_guard;
v10 = _stack_chk_guard;
if ( (*a2 & 1) != 0 )
{
v9 = nullptr;
}
else
{
a2[1] = 0;
*a2 = 0;
}
v49[3] = v10;
if ( !v7 )
{
**((_BYTE **)a2 + 2) = (_BYTE)v9;
*((_DWORD *)a2 + 1) = v9;
}
*a3 = 0;
*a4 = 0;
*a5 = 0;
v39[0] = 0;
v39[1] = 0;
v40 = nullptr;
memset(v41, 0, sizeof(v41));
std::string::__init(v41, "keybinds.gdkb", 0xDu);
v11 = GameToolbox::showOpenFileDialog(
(cocos2d::CCFileUtils *)"Import Keybinds",
(int)"GD Keybind Files (*.gdkb)",
(unsigned __int8 *)v41,
(int)v39);
std::string::~string((int)v41);
if ( !v11 )
{
v14 = -1;
goto LABEL_67;
}
if ( (v39[0] & 1) != 0 )
v12 = v40;
else
v12 = (cocos2d::CCString *)((char *)v39 + 1);
v13 = (cocos2d::CCString *)cocos2d::CCString::createWithContentsOfFile(v12, (const char *)(LOBYTE(v39[0]) << 31));
v14 = (int)v13;
if ( v13 )
{
CString = (const char *)cocos2d::CCString::getCString(v13);
v42 = 0;
v43 = 0;
v44 = 0;
v16 = strlen(CString);
std::string::__init(&v42, CString, v16);
if ( (v42 & 1) != 0 )
v17 = v43;
else
v17 = (int)(unsigned __int8)v42 >> 1;
if ( !v17
|| (v18 = std::string::find((unsigned __int8 *)&v42, 59, 0), v18 == -1)
|| ((std::string::basic_string(v45, (unsigned __int8 *)&v42, 0, v18), (v45[0] & 1) != 0)
? (v19 = (const char *)v45[2])
: (v19 = (char *)v45 + 1),
v20 = atoi(v19),
std::string::~string((int)v45),
v20 != 1) )
{
v14 = 0;
LABEL_65:
std::string::~string((int)&v42);
goto LABEL_67;
}
v21 = std::string::find((unsigned __int8 *)&v42, 59, v18 + 1);
if ( v21 == -1 )
{
if ( (v42 & 1) != 0 )
v21 = v43;
else
v21 = (int)(unsigned __int8)v42 >> 1;
}
std::string::basic_string(&v46, (unsigned __int8 *)&v42, v18 + 1, ~v18 + v21);
while ( 1 )
{
v22 = v46 & 1;
if ( v22 )
{
v23 = v47;
if ( !v47 )
goto LABEL_36;
v24 = (char *)v48;
}
else
{
v23 = (int)(unsigned __int8)v46 >> 1;
if ( !v23 )
goto LABEL_37;
v24 = (char *)&v46 + 1;
}
if ( v24[v23 - 1] != 10 )
{
if ( v22 )
{
v25 = (char *)v48;
v26 = v47;
}
else
{
v26 = (int)(unsigned __int8)v46 >> 1;
v25 = (char *)&v46 + 1;
}
if ( v25[v26 - 1] != 13 )
break;
}
if ( v22 )
{
--v47;
*((_BYTE *)v48 + v47) = 0;
}
else
{
v37 = ((int)(unsigned __int8)v46 >> 1) - 1;
LOBYTE(v46) = 2 * v37;
*((_BYTE *)&v49[-2] + v37 - 3) = 0;
}
}
if ( v22 )
{
LABEL_36:
v27 = v47;
goto LABEL_38;
}
LABEL_37:
v27 = (int)(unsigned __int8)v46 >> 1;
LABEL_38:
if ( !v27 )
goto LABEL_39;
if ( (v42 & 1) != 0 )
v28 = v43;
else
v28 = (int)(unsigned __int8)v42 >> 1;
if ( v21 < v28 )
{
std::string::basic_string(v49, (unsigned __int8 *)&v42, v21 + 1, 0xFFFFFFFF);
if ( (v49[0] & 1) != 0 )
v29 = (const char *)v49[2];
else
v29 = (char *)v49 + 1;
*a5 = atoi(v29);
std::string::~string((int)v49);
}
GJKeybindManager::parseBindsBlob(a1, (unsigned __int8 *)&v46, 0, a3, a4);
if ( *a3 <= 0 )
{
LABEL_39:
v14 = 0;
LABEL_64:
std::string::~string((int)&v46);
goto LABEL_65;
}
if ( (v46 & 1) != 0 )
{
v30 = (char *)v48;
v31 = v47;
}
else
{
v31 = (int)(unsigned __int8)v46 >> 1;
v30 = (char *)&v46 + 1;
}
v32 = *a2;
if ( (v32 & 1) != 0 )
{
v33 = (*(_DWORD *)a2 & 0xFFFFFFFE) - 1;
if ( v33 >= v31 )
{
v34 = *((void **)a2 + 2);
LABEL_56:
if ( v31 )
v34 = memmove(v34, v30, v31);
*((_BYTE *)v34 + v31) = 0;
if ( (*a2 & 1) != 0 )
*((_DWORD *)a2 + 1) = v31;
else
*a2 = 2 * v31;
goto LABEL_63;
}
v35 = *((_DWORD *)a2 + 1);
}
else
{
if ( v31 <= 0xA )
{
v34 = a2 + 1;
goto LABEL_56;
}
v35 = v32 >> 1;
v33 = 10;
}
std::string::__grow_by_and_replace((int)a2, v33, v31 - v33, v35, 0, v35, v31, v30);
LABEL_63:
v14 = 1;
goto LABEL_64;
}
LABEL_67:
std::string::~string((int)v39);
return v14;
}