//
// GJSmartTemplate::isUnrequired from 0x9d53ac to 0x9d5684 (728 bytes)
//
// 4 xrefs:
// > GJSmartTemplate::logTemplateStatus @ 0x9da788
// > GJSmartTemplate::getTemplateState @ 0x9dac08
// > BrowseSmartTemplateLayer::init @ 0x9dfbf0
// > ??> @ 0xb3310
//
// 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
//
bool __fastcall GJSmartTemplate::isUnrequired(__int64 a1, unsigned __int8 **a2)
{
unsigned __int8 *v2; // x0
unsigned __int64 v3; // x2
unsigned int v5; // w20
int v6; // w24
unsigned int v7; // w21
int v8; // w22
int v9; // w25
int v10; // w23
int v11; // w26
int v12; // w4
_BOOL8 result; // x0
unsigned int v14; // w2
v2 = *a2;
v3 = *((_QWORD *)*a2 - 3);
if ( v3 <= 1 )
sub_D13C5C("basic_string::at: __n (which is %zu) >= this->size() (which is %zu)", 1u, v3);
if ( (*((_DWORD *)v2 - 2) & 0x80000000) != 0 )
{
v5 = v2[1] != 48;
if ( v3 != 2 )
{
LABEL_30:
v6 = v2[2];
if ( v3 != 3 )
{
LABEL_31:
v7 = v2[3] != 48;
if ( v3 != 4 )
{
LABEL_32:
v8 = v2[4];
if ( v3 != 5 )
{
LABEL_33:
v9 = v2[5];
if ( v3 != 6 )
{
LABEL_34:
v10 = v2[6];
if ( v3 != 7 )
{
LABEL_35:
v11 = v2[7];
if ( v3 != 8 )
goto LABEL_18;
LABEL_36:
sub_D13C5C("basic_string::at: __n (which is %zu) >= this->size() (which is %zu)", 8u, v3);
}
LABEL_41:
sub_D13C5C("basic_string::at: __n (which is %zu) >= this->size() (which is %zu)", 7u, v3);
}
LABEL_38:
sub_D13C5C("basic_string::at: __n (which is %zu) >= this->size() (which is %zu)", 6u, v3);
}
LABEL_42:
sub_D13C5C("basic_string::at: __n (which is %zu) >= this->size() (which is %zu)", 5u, v3);
}
LABEL_39:
sub_D13C5C("basic_string::at: __n (which is %zu) >= this->size() (which is %zu)", 4u, v3);
}
LABEL_40:
sub_D13C5C("basic_string::at: __n (which is %zu) >= this->size() (which is %zu)", 3u, v3);
}
LABEL_37:
sub_D13C5C("basic_string::at: __n (which is %zu) >= this->size() (which is %zu)", 2u, v3);
}
sub_D176A8(a2);
v2 = *a2;
v3 = *((_QWORD *)*a2 - 3);
v5 = (*a2)[1] != 48;
if ( v3 <= 2 )
goto LABEL_37;
if ( (*((_DWORD *)v2 - 2) & 0x80000000) != 0 )
goto LABEL_30;
sub_D176A8(a2);
v2 = *a2;
v3 = *((_QWORD *)*a2 - 3);
v6 = (*a2)[2];
if ( v3 <= 3 )
goto LABEL_40;
if ( (*((_DWORD *)v2 - 2) & 0x80000000) != 0 )
goto LABEL_31;
sub_D176A8(a2);
v2 = *a2;
v3 = *((_QWORD *)*a2 - 3);
v7 = (*a2)[3] != 48;
if ( v3 <= 4 )
goto LABEL_39;
if ( (*((_DWORD *)v2 - 2) & 0x80000000) != 0 )
goto LABEL_32;
sub_D176A8(a2);
v2 = *a2;
v3 = *((_QWORD *)*a2 - 3);
v8 = (*a2)[4];
if ( v3 <= 5 )
goto LABEL_42;
if ( (*((_DWORD *)v2 - 2) & 0x80000000) != 0 )
goto LABEL_33;
sub_D176A8(a2);
v2 = *a2;
v3 = *((_QWORD *)*a2 - 3);
v9 = (*a2)[5];
if ( v3 <= 6 )
goto LABEL_38;
if ( (*((_DWORD *)v2 - 2) & 0x80000000) != 0 )
goto LABEL_34;
sub_D176A8(a2);
v2 = *a2;
v3 = *((_QWORD *)*a2 - 3);
v10 = (*a2)[6];
if ( v3 <= 7 )
goto LABEL_41;
if ( (*((_DWORD *)v2 - 2) & 0x80000000) != 0 )
goto LABEL_35;
sub_D176A8(a2);
v2 = *a2;
v3 = *((_QWORD *)*a2 - 3);
v11 = (*a2)[7];
if ( v3 <= 8 )
goto LABEL_36;
if ( (*((_DWORD *)v2 - 2) & 0x80000000) == 0 )
{
sub_D176A8(a2);
v2 = *a2;
}
LABEL_18:
v12 = v2[8];
if ( v9 == 48 || (result = 1, (v7 ^ 1) < v5) )
{
if ( v10 == 48 || (result = 1, (v8 == 48) < v5) )
{
v14 = v6 != 48;
if ( v11 == 48 || (result = 1, v14 > (v7 ^ 1)) )
{
if ( v12 == 48 || (result = 1, v14 > (v8 == 48)) )
{
result = 0;
if ( (v6 == 48) > v5 )
return v7 < (v8 == 48);
}
}
}
}
return result;
}