//
// GameManager::saveDPadLayout from 0x5ffad4 to 0x600360 (2188 bytes)
//
// 2 xrefs:
// > UISaveLoadLayer::onSave @ 0x8d85b0
// > ??> @ 0xbd930
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
void GameManager::saveDPadLayout(GameManager *a1, int a2, bool a3)
{
const char *v5; // x27
size_t v6; // x22
size_t v7; // x0
size_t v8; // x26
unsigned __int64 v9; // x24
char *v10; // x0
const char *v11; // x2
char *v12; // x0
size_t v13; // x24
size_t v14; // x22
const char *v15; // x27
size_t v16; // x22
size_t v17; // x0
size_t v18; // x26
unsigned __int64 v19; // x24
char *v20; // x0
const char *v21; // x1
char *v22; // x0
size_t v23; // x25
size_t v24; // x24
size_t v25; // x24
size_t v26; // x0
size_t v27; // x28
unsigned __int64 v28; // x25
char *v29; // x0
const char *v30; // x1
char *v31; // x0
size_t v32; // x25
size_t v33; // x24
size_t v34; // x24
size_t v35; // x0
size_t v36; // x28
unsigned __int64 v37; // x25
char *v38; // x0
const char *v39; // x1
char *v40; // x0
size_t v41; // x25
size_t v42; // x24
size_t v43; // x24
size_t v44; // x0
size_t v45; // x27
unsigned __int64 v46; // x25
char *v47; // x0
const char *v48; // x1
char *v49; // x0
size_t v50; // x22
std::string *p_m_dpadLayoutDual2; // x20
unsigned __int64 v52; // x1
char *v53; // x0
char *v54; // x0
char *v55; // x0
char *v56; // x0
char *v57; // x0
size_t v58; // x0
unsigned int *v59; // x1
int v60; // w2
unsigned int *v61; // x2
int v62; // w1
unsigned int *v63; // x1
int v64; // w2
unsigned int *v65; // x1
int v66; // w2
unsigned int *v67; // x1
int v68; // w2
const char *v69; // [xsp+68h] [xbp+68h]
const char *v70; // [xsp+68h] [xbp+68h]
const char *v71; // [xsp+68h] [xbp+68h]
const char *v72; // [xsp+68h] [xbp+68h]
unsigned int GameVariable; // [xsp+78h] [xbp+78h]
const char *v74; // [xsp+80h] [xbp+80h] BYREF
const char *v75; // [xsp+88h] [xbp+88h] BYREF
const char *v76; // [xsp+90h] [xbp+90h] BYREF
const char *v77; // [xsp+98h] [xbp+98h] BYREF
const char *v78; // [xsp+A0h] [xbp+A0h] BYREF
size_t v79; // [xsp+A8h] [xbp+A8h] BYREF
unsigned __int64 v80; // [xsp+B0h] [xbp+B0h]
char *v81; // [xsp+B8h] [xbp+B8h]
_BYTE v82[504]; // [xsp+C0h] [xbp+C0h] BYREF
v80 = 500;
v79 = 0;
v81 = v82;
if ( a3 )
{
GameManager::dpadConfigToString((__int64)&a1->m_dpad2, (__int64)&v75);
v15 = v75;
v16 = *((_QWORD *)v75 - 3);
if ( v16 )
{
v18 = v79;
v19 = v79 + v16;
if ( v79 + v16 <= v80 )
{
v79 += v16;
v56 = &v81[v18];
goto LABEL_62;
}
}
else
{
v17 = strlen(v75);
v18 = v79;
v16 = v17;
v19 = v17 + v79;
if ( v17 + v79 <= v80 )
{
v79 += v17;
v20 = v81;
if ( !v16 )
goto LABEL_18;
LABEL_61:
v56 = &v20[v18];
LABEL_62:
memmove(v56, v15, v16);
v21 = v75;
v22 = (char *)(v75 - 24);
if ( v75 - 24 == (const char *)&qword_124B6B0 )
goto LABEL_19;
goto LABEL_84;
}
}
fmt::internal::Array::grow(&v79, v19);
v79 = v19;
v20 = v81;
if ( !v16 )
{
LABEL_18:
v21 = v75;
v22 = (char *)(v75 - 24);
if ( v75 - 24 == (const char *)&qword_124B6B0 )
goto LABEL_19;
LABEL_84:
if ( &pthread_create )
{
v59 = (unsigned int *)(v21 - 8);
do
v60 = __ldaxr(v59);
while ( __stlxr(v60 - 1, v59) );
}
else
{
v60 = *((_DWORD *)v21 - 2);
*((_DWORD *)v21 - 2) = v60 - 1;
}
if ( v60 <= 0 )
operator delete(v22);
LABEL_19:
v23 = v79;
v24 = v79 + 1;
if ( v79 + 1 > v80 )
fmt::internal::Array::grow(&v79, v79 + 1);
v79 = v24;
v81[v23] = asc_EA4078[0];
GameManager::dpadConfigToString((__int64)&a1->m_dpad3, (__int64)&v76);
v69 = v76;
v25 = *((_QWORD *)v76 - 3);
if ( v25 )
{
v27 = v79;
v28 = v79 + v25;
if ( v80 >= v79 + v25 )
{
v79 += v25;
v55 = &v81[v27];
goto LABEL_56;
}
}
else
{
v26 = strlen(v76);
v27 = v79;
v25 = v26;
v28 = v26 + v79;
if ( v26 + v79 <= v80 )
{
v79 += v26;
v29 = v81;
if ( !v25 )
goto LABEL_24;
LABEL_55:
v55 = &v29[v27];
LABEL_56:
memmove(v55, v69, v25);
v30 = v76;
v31 = (char *)(v76 - 24);
if ( v76 - 24 == (const char *)&qword_124B6B0 )
goto LABEL_25;
goto LABEL_104;
}
}
fmt::internal::Array::grow(&v79, v28);
v79 = v28;
v29 = v81;
if ( !v25 )
{
LABEL_24:
v30 = v76;
v31 = (char *)(v76 - 24);
if ( v76 - 24 == (const char *)&qword_124B6B0 )
goto LABEL_25;
LABEL_104:
if ( &pthread_create )
{
v67 = (unsigned int *)(v30 - 8);
do
v68 = __ldaxr(v67);
while ( __stlxr(v68 - 1, v67) );
}
else
{
v68 = *((_DWORD *)v30 - 2);
*((_DWORD *)v30 - 2) = v68 - 1;
}
if ( v68 <= 0 )
operator delete(v31);
LABEL_25:
v32 = v79;
v33 = v79 + 1;
if ( v79 + 1 > v80 )
fmt::internal::Array::grow(&v79, v79 + 1);
v79 = v33;
v81[v32] = asc_EA4078[0];
GameManager::dpadConfigToString((__int64)&a1->m_dpad4, (__int64)&v77);
v70 = v77;
v34 = *((_QWORD *)v77 - 3);
if ( v34 )
{
v36 = v79;
v37 = v79 + v34;
if ( v80 >= v79 + v34 )
{
v79 += v34;
v54 = &v81[v36];
goto LABEL_59;
}
}
else
{
v35 = strlen(v77);
v36 = v79;
v34 = v35;
v37 = v35 + v79;
if ( v35 + v79 <= v80 )
{
v79 += v35;
v38 = v81;
if ( !v34 )
goto LABEL_30;
LABEL_58:
v54 = &v38[v36];
LABEL_59:
memmove(v54, v70, v34);
v39 = v77;
v40 = (char *)(v77 - 24);
if ( v77 - 24 == (const char *)&qword_124B6B0 )
goto LABEL_31;
goto LABEL_94;
}
}
fmt::internal::Array::grow(&v79, v37);
v79 = v37;
v38 = v81;
if ( !v34 )
{
LABEL_30:
v39 = v77;
v40 = (char *)(v77 - 24);
if ( v77 - 24 == (const char *)&qword_124B6B0 )
goto LABEL_31;
LABEL_94:
if ( &pthread_create )
{
v63 = (unsigned int *)(v39 - 8);
do
v64 = __ldaxr(v63);
while ( __stlxr(v64 - 1, v63) );
}
else
{
v64 = *((_DWORD *)v39 - 2);
*((_DWORD *)v39 - 2) = v64 - 1;
}
if ( v64 <= 0 )
operator delete(v40);
LABEL_31:
v41 = v79;
v42 = v79 + 1;
if ( v79 + 1 > v80 )
fmt::internal::Array::grow(&v79, v79 + 1);
v79 = v42;
v81[v41] = asc_EA4078[0];
GameManager::dpadConfigToString((__int64)&a1->m_dpad5, (__int64)&v78);
v71 = v78;
v43 = *((_QWORD *)v78 - 3);
if ( v43 )
{
v45 = v79;
v46 = v79 + v43;
if ( v80 >= v79 + v43 )
{
v79 += v43;
v53 = &v81[v45];
goto LABEL_65;
}
}
else
{
v44 = strlen(v78);
v45 = v79;
v43 = v44;
v46 = v44 + v79;
if ( v44 + v79 <= v80 )
{
v79 += v44;
v47 = v81;
if ( !v43 )
goto LABEL_36;
LABEL_64:
v53 = &v47[v45];
LABEL_65:
memmove(v53, v71, v43);
v48 = v78;
v49 = (char *)(v78 - 24);
if ( v78 - 24 == (const char *)&qword_124B6B0 )
goto LABEL_37;
goto LABEL_99;
}
}
fmt::internal::Array::grow(&v79, v46);
v79 = v46;
v47 = v81;
if ( !v43 )
{
LABEL_36:
v48 = v78;
v49 = (char *)(v78 - 24);
if ( v78 - 24 == (const char *)&qword_124B6B0 )
goto LABEL_37;
LABEL_99:
if ( &pthread_create )
{
v65 = (unsigned int *)(v48 - 8);
do
v66 = __ldaxr(v65);
while ( __stlxr(v66 - 1, v65) );
}
else
{
v66 = *((_DWORD *)v48 - 2);
*((_DWORD *)v48 - 2) = v66 - 1;
}
if ( v66 <= 0 )
operator delete(v49);
LABEL_37:
if ( a2 == 2 )
{
v50 = v79;
p_m_dpadLayoutDual2 = &a1->m_dpadLayoutDual2;
v52 = v79 + 1;
if ( v79 + 1 <= v80 )
goto LABEL_79;
goto LABEL_78;
}
if ( a2 == 3 )
{
v50 = v79;
p_m_dpadLayoutDual2 = &a1->m_dpadLayoutDual3;
v52 = v79 + 1;
if ( v79 + 1 <= v80 )
goto LABEL_79;
goto LABEL_78;
}
if ( a2 != 1 )
goto LABEL_11;
v50 = v79;
p_m_dpadLayoutDual2 = &a1->m_dpadLayoutDual1;
v52 = v79 + 1;
if ( v79 + 1 > v80 )
goto LABEL_78;
goto LABEL_79;
}
goto LABEL_64;
}
goto LABEL_58;
}
goto LABEL_55;
}
goto LABEL_61;
}
GameManager::dpadConfigToString((__int64)&a1->m_dpad1, (__int64)&v74);
v5 = v74;
v6 = *((_QWORD *)v74 - 3);
if ( v6 )
{
v8 = v79;
v9 = v79 + v6;
if ( v79 + v6 <= v80 )
{
v79 += v6;
v57 = &v81[v8];
goto LABEL_53;
}
}
else
{
v7 = strlen(v74);
v8 = v79;
v6 = v7;
v9 = v7 + v79;
if ( v7 + v79 <= v80 )
{
v79 += v7;
v10 = v81;
if ( !v6 )
goto LABEL_5;
goto LABEL_52;
}
}
fmt::internal::Array::grow(&v79, v9);
v79 = v9;
v10 = v81;
if ( v6 )
{
LABEL_52:
v57 = &v10[v8];
LABEL_53:
memmove(v57, v5, v6);
v11 = v74;
v12 = (char *)(v74 - 24);
if ( v74 - 24 == (const char *)&qword_124B6B0 )
goto LABEL_6;
goto LABEL_89;
}
LABEL_5:
v11 = v74;
v12 = (char *)(v74 - 24);
if ( v74 - 24 == (const char *)&qword_124B6B0 )
goto LABEL_6;
LABEL_89:
if ( &pthread_create )
{
v61 = (unsigned int *)(v11 - 8);
do
v62 = __ldaxr(v61);
while ( __stlxr(v62 - 1, v61) );
}
else
{
v62 = *((_DWORD *)v11 - 2);
*((_DWORD *)v11 - 2) = v62 - 1;
}
if ( v62 <= 0 )
operator delete(v12);
LABEL_6:
v13 = v79;
v14 = v79 + 1;
if ( v79 + 1 > v80 )
fmt::internal::Array::grow(&v79, v79 + 1);
v79 = v14;
v81[v13] = asc_EA4078[0];
GameVariable = GameManager::getGameVariable(a1, "0113");
fmt::BasicWriter::FormatInt,char>>(&v79, GameVariable);
if ( a2 != 2 )
{
if ( a2 == 3 )
{
v50 = v79;
p_m_dpadLayoutDual2 = &a1->m_dpadLayout3;
v52 = v79 + 1;
if ( v79 + 1 <= v80 )
goto LABEL_79;
}
else
{
if ( a2 != 1 )
goto LABEL_11;
v50 = v79;
p_m_dpadLayoutDual2 = &a1->m_dpadLayout1;
v52 = v79 + 1;
if ( v79 + 1 <= v80 )
goto LABEL_79;
}
goto LABEL_78;
}
v50 = v79;
p_m_dpadLayoutDual2 = &a1->m_dpadLayout2;
v52 = v79 + 1;
if ( v79 + 1 > v80 )
LABEL_78:
fmt::internal::Array::grow(&v79, v52);
LABEL_79:
v81[v50] = 0;
v72 = v81;
v58 = strlen(v81);
sub_D1798C(p_m_dpadLayoutDual2, v72, v58);
LABEL_11:
if ( v81 != v82 )
{
if ( v81 )
operator delete[](v81);
}
}