//
// GJKeybindManager::exportBindingsToFile from 0xc0e2c4 to 0xc0e690 (972 bytes)
//
// 2 xrefs:
// > KeybindingsSettingsPopup::onExport @ 0xceffe4
// > ??> @ 0xc8290
//
// 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:56 +0000
//
__int64 __fastcall GJKeybindManager::exportBindingsToFile(GJKeybindManager *this)
{
__int64 v2; // x0
__int64 v3; // x5
char *v4; // x1
size_t v5; // x2
__int64 v6; // x0
__int64 v7; // x5
__int64 v8; // x0
__int64 v9; // x3
char *v10; // x1
size_t v11; // x2
__int64 v12; // x0
size_t v13; // x3
int v14; // w21
const char *v15; // x0
FILE *v16; // x19
char *v17; // x0
size_t v18; // x2
size_t v19; // x22
size_t v20; // x21
unsigned int v21; // w19
__int64 v23; // [xsp+30h] [xbp+30h] BYREF
size_t n; // [xsp+38h] [xbp+38h]
void *ptr; // [xsp+40h] [xbp+40h]
void *v26[3]; // [xsp+48h] [xbp+48h] BYREF
_QWORD v27[2]; // [xsp+60h] [xbp+60h] BYREF
void *v28; // [xsp+70h] [xbp+70h]
__int64 v29[2]; // [xsp+78h] [xbp+78h] BYREF
void *v30; // [xsp+88h] [xbp+88h]
_QWORD v31[2]; // [xsp+90h] [xbp+90h] BYREF
void *v32; // [xsp+A0h] [xbp+A0h]
__int64 v33; // [xsp+A8h] [xbp+A8h] BYREF
__int64 v34; // [xsp+B0h] [xbp+B0h]
void *v35; // [xsp+B8h] [xbp+B8h]
__int64 v36; // [xsp+C0h] [xbp+C0h] BYREF
size_t v37; // [xsp+C8h] [xbp+C8h]
void *v38; // [xsp+D0h] [xbp+D0h]
std::to_string(v26, 1);
v2 = std::string::append((__int64)v26, ";");
v3 = *(_QWORD *)(v2 + 8);
v27[0] = *(_QWORD *)v2;
v27[1] = v3;
v28 = *(void **)(v2 + 16);
*(_QWORD *)v2 = 0;
*(_QWORD *)(v2 + 8) = 0;
*(_QWORD *)(v2 + 16) = 0;
GJKeybindManager::buildBindsBlob(this, v29);
if ( (v29[0] & 1) != 0 )
{
v4 = (char *)v30;
v5 = v29[1];
}
else
{
v5 = LOBYTE(v29[0]) >> 1;
v4 = (char *)v29 + 1;
}
v6 = std::string::append((__int64)v27, v4, v5);
v7 = *(_QWORD *)(v6 + 8);
v31[0] = *(_QWORD *)v6;
v31[1] = v7;
v32 = *(void **)(v6 + 16);
*(_QWORD *)v6 = 0;
*(_QWORD *)(v6 + 8) = 0;
*(_QWORD *)(v6 + 16) = 0;
v8 = std::string::append((__int64)v31, ";");
v9 = *(_QWORD *)(v8 + 8);
v33 = *(_QWORD *)v8;
v34 = v9;
v35 = *(void **)(v8 + 16);
*(_QWORD *)v8 = 0;
*(_QWORD *)(v8 + 8) = 0;
*(_QWORD *)(v8 + 16) = 0;
std::to_string(&v36, 2);
if ( (v36 & 1) != 0 )
{
v10 = (char *)v38;
v11 = v37;
}
else
{
v11 = (unsigned __int8)v36 >> 1;
v10 = (char *)&v36 + 1;
}
v12 = std::string::append((__int64)&v33, v10, v11);
v13 = *(_QWORD *)(v12 + 8);
v23 = *(_QWORD *)v12;
n = v13;
ptr = *(void **)(v12 + 16);
*(_QWORD *)v12 = 0;
*(_QWORD *)(v12 + 8) = 0;
*(_QWORD *)(v12 + 16) = 0;
if ( (v36 & 1) != 0 )
operator delete(v38);
if ( (v33 & 1) != 0 )
operator delete(v35);
if ( (v31[0] & 1) != 0 )
operator delete(v32);
if ( (v29[0] & 1) != 0 )
operator delete(v30);
if ( (v27[0] & 1) != 0 )
operator delete(v28);
if ( ((__int64)v26[0] & 1) != 0 )
operator delete(v26[2]);
v33 = 0;
v34 = 0;
v35 = nullptr;
v36 = 0;
v37 = 0;
v38 = nullptr;
std::string::__init(&v36, "keybinds.gdkb", 0xDu);
v14 = (unsigned __int8)GameToolbox::showSaveFileDialog(
(__int64)"Export Keybinds",
(__int64)"GD Keybind Files (*.gdkb)",
(__int64)"gdkb",
(__int64)&v36,
(unsigned __int8 *)&v33);
if ( (v36 & 1) != 0 )
operator delete(v38);
if ( v14 )
{
v15 = (char *)&v33 + 1;
if ( (v33 & 1) != 0 )
v15 = (const char *)v35;
v16 = fopen(v15, "w");
if ( v16 )
{
if ( (v23 & 1) != 0 )
{
v17 = (char *)ptr;
v18 = n;
}
else
{
v18 = (unsigned __int8)v23 >> 1;
v17 = (char *)&v23 + 1;
}
v19 = fwrite(v17, 1u, v18, v16);
v20 = (unsigned __int8)v23 >> 1;
if ( (v23 & 1) != 0 )
v20 = n;
fclose(v16);
if ( v19 == v20 )
v21 = 1;
else
v21 = -1;
if ( (v33 & 1) != 0 )
goto LABEL_31;
goto LABEL_34;
}
v21 = -1;
}
else
{
v21 = 0;
}
if ( (v33 & 1) != 0 )
LABEL_31:
operator delete(v35);
LABEL_34:
if ( (v23 & 1) != 0 )
operator delete(ptr);
return v21;
}