//
// __gxx_personality_v0 from 0xccc6dc to 0xcccc18 (1340 bytes)
//
// 2 xrefs:
// > ??> @ 0x45b10
// > ??> @ 0x122f008
//
// 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
//
__int64 __fastcall _gxx_personality_v0(int a1, int a2, __int64 a3, _QWORD *a4, __int64 a5)
{
bool v5; // zf
__int64 result; // x0
char v7; // w22
unsigned int v10; // w27
char *v11; // x26
int v12; // w19
__int64 IPInfo; // x0
char *v14; // x2
unsigned __int64 v15; // x26
char v16; // w28
char *v17; // x0
char *v18; // x0
char v19; // w28
char *v20; // x0
char *v21; // x0
char v22; // w28
char *v23; // x0
__int64 v24; // x4
int v25; // w1
char v26; // t1
unsigned __int64 v27; // x0
int v28; // w0
char *v29; // x28
__int64 v30; // x4
int v31; // w2
char *v32; // x1
char v33; // t1
unsigned __int64 v34; // x0
int v35; // w0
unsigned __int64 v36; // x2
unsigned __int64 v37; // [xsp+68h] [xbp+68h]
int v38; // [xsp+7Ch] [xbp+7Ch]
__int64 **v39; // [xsp+80h] [xbp+80h]
unsigned __int64 *v40; // [xsp+88h] [xbp+88h]
unsigned __int8 *LanguageSpecificData; // [xsp+90h] [xbp+90h]
char *v42; // [xsp+98h] [xbp+98h]
char *v43; // [xsp+98h] [xbp+98h]
char *v44; // [xsp+98h] [xbp+98h]
char *v45; // [xsp+98h] [xbp+98h]
char *v46; // [xsp+98h] [xbp+98h]
int v47; // [xsp+A4h] [xbp+A4h] BYREF
__int64 v48; // [xsp+A8h] [xbp+A8h] BYREF
unsigned __int64 v49; // [xsp+B0h] [xbp+B0h] BYREF
unsigned __int64 *v50; // [xsp+B8h] [xbp+B8h] BYREF
_QWORD v51[2]; // [xsp+C0h] [xbp+C0h] BYREF
char *v52; // [xsp+D0h] [xbp+D0h]
__int64 v53; // [xsp+D8h] [xbp+D8h]
unsigned __int64 v54; // [xsp+E0h] [xbp+E0h]
unsigned __int8 v55; // [xsp+E8h] [xbp+E8h]
unsigned __int8 v56; // [xsp+E9h] [xbp+E9h]
v5 = a1 == 1;
result = 3;
v47 = 0;
v7 = a2;
if ( !v5 )
return result;
v10 = (unsigned __int64)(a3 - 0x474E5543432B2B00LL) > 1;
if ( (a2 == 6) > v10 )
{
v11 = (char *)*(a4 - 2);
LanguageSpecificData = (unsigned __int8 *)*(a4 - 3);
v12 = *((_DWORD *)a4 - 9);
if ( !v11 )
{
if ( (a2 & 8) != 0 )
std::terminate();
LABEL_6:
sub_D1EF38(a4);
}
if ( (a2 & 8) != 0 )
goto LABEL_8;
goto LABEL_13;
}
LanguageSpecificData = (unsigned __int8 *)Unwind_GetLanguageSpecificData(a5);
if ( !LanguageSpecificData )
return 8;
v42 = sub_CCC490(a5, LanguageSpecificData, (__int64)v51);
v52 = (char *)sub_CCC414(v55, a5);
IPInfo = Unwind_GetIPInfo(a5, &v47);
v14 = v42;
v15 = IPInfo - (v47 == 0);
if ( (unsigned __int64)v42 >= v54 )
{
LABEL_20:
v11 = nullptr;
v28 = 1;
LABEL_21:
v40 = nullptr;
v12 = 0;
v29 = nullptr;
goto LABEL_22;
}
while ( 1 )
{
v16 = v56;
v43 = v14;
v17 = (char *)sub_CCC414(v56, 0);
v18 = sub_CCC304(v16, v17, v43, (unsigned __int64 *)&v48);
v19 = v56;
v44 = v18;
v20 = (char *)sub_CCC414(v56, 0);
v21 = sub_CCC304(v19, v20, v44, &v49);
v22 = v56;
v45 = v21;
v23 = (char *)sub_CCC414(v56, 0);
v14 = sub_CCC304(v22, v23, v45, (unsigned __int64 *)&v50);
v24 = 0;
v25 = 0;
do
{
v26 = *v14++;
v27 = (unsigned __int64)(v26 & 0x7F) << v25;
v25 += 7;
v24 |= v27;
}
while ( v26 < 0 );
if ( v15 < v48 + v51[0] )
goto LABEL_20;
if ( v15 < v48 + v51[0] + v49 )
break;
if ( (unsigned __int64)v14 >= v54 )
goto LABEL_20;
}
if ( !v50 )
return 8;
v11 = (char *)v50 + v51[1];
if ( !v24 )
{
if ( !v11 )
return 8;
goto LABEL_36;
}
if ( !v11 )
return 8;
v29 = (char *)(v54 + v24 - 1);
if ( !v29 )
{
LABEL_36:
v28 = 2;
goto LABEL_21;
}
if ( (v7 & 8) != 0 )
{
v40 = nullptr;
v39 = &`typeinfo for'__cxxabiv1::__forced_unwind;
}
else if ( v10 )
{
v40 = nullptr;
v39 = &`typeinfo for'__cxxabiv1::__foreign_exception;
}
else
{
v40 = a4 + 4;
if ( (*a4 & 1) != 0 )
v40 = (unsigned __int64 *)*(a4 - 10);
v39 = (__int64 **)*(v40 - 14);
}
v38 = 0;
while ( 1 )
{
v46 = sub_CCC2C4(v29, &v48);
sub_CCC2C4(v46, &v49);
if ( !v48 )
{
v38 = 1;
goto LABEL_52;
}
if ( v48 <= 0 )
{
if ( ((v39 != nullptr) & (unsigned __int8)((v7 & 8) == 0)) > v10 )
{
v35 = (unsigned __int8)sub_CCC59C((__int64)v51, (__int64 *)v39, v40, v48) ^ 1;
}
else
{
v30 = 0;
v31 = 0;
v32 = (char *)(v53 + ~v48);
do
{
v33 = *v32++;
v34 = (unsigned __int64)(v33 & 0x7F) << v31;
v31 += 7;
v30 |= v34;
}
while ( v33 < 0 );
v35 = v30 == 0;
}
if ( v35 )
goto LABEL_66;
goto LABEL_52;
}
if ( v55 == 255 )
{
v36 = 0;
}
else
{
switch ( v55 & 7 )
{
case 0:
case 4:
v36 = -8 * v48;
break;
case 2:
v36 = -2 * v48;
break;
case 3:
v36 = -4 * v48;
break;
default:
abort();
return result;
}
}
sub_CCC304(v55, v52, (char *)(v53 + v36), (unsigned __int64 *)&v50);
if ( !v50 )
goto LABEL_66;
if ( v39 )
{
v37 = (unsigned __int64)v50;
v50 = v40;
if ( ((unsigned __int8 (__fastcall *)(__int64 **))(*v39)[2])(v39) )
v50 = (unsigned __int64 *)*v50;
if ( (*(unsigned __int8 (__fastcall **)(unsigned __int64, __int64 **, unsigned __int64 **, __int64))(*(_QWORD *)v37 + 32LL))(
v37,
v39,
&v50,
1) )
{
break;
}
}
LABEL_52:
if ( !v49 )
{
if ( v38 )
{
v12 = 0;
v28 = 2;
goto LABEL_22;
}
return 8;
}
v29 = &v46[v49];
}
v40 = v50;
LABEL_66:
v12 = v48;
v28 = 3;
LABEL_22:
if ( (v7 & 1) == 0 )
{
if ( (v7 & 8) != 0 || v10 )
{
if ( v28 == 1 )
std::terminate();
LABEL_8:
if ( v12 < 0 )
std::unexpected();
LABEL_9:
Unwind_SetGR(a5, 0, a4);
Unwind_SetGR(a5, 1, v12);
Unwind_SetIP(a5, v11);
return 7;
}
if ( v28 == 1 )
goto LABEL_6;
LABEL_13:
if ( v12 < 0 )
{
sub_CCC490(a5, LanguageSpecificData, (__int64)v51);
v52 = (char *)sub_CCC414(v55, a5);
*(a4 - 2) = sub_CCC414(v55, a5);
}
goto LABEL_9;
}
if ( v28 == 2 )
return 8;
result = 6;
if ( !v10 )
{
*(a4 - 3) = LanguageSpecificData;
*((_DWORD *)a4 - 9) = v12;
*(a4 - 4) = v29;
*(a4 - 1) = v40;
*(a4 - 2) = v11;
}
return result;
}