//
// GJGameLevel::rollSession from 0x854580 to 0x854d40 (1984 bytes)
//
// 2 xrefs:
// > PlayLayer::resetLevel @ 0x71166c
// > ??> @ 0x58930
//
// 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 12:55:29 +0000
//
__int64 __fastcall GJGameLevel::rollSession(GJGameLevel *this, int a2, int a3)
{
int v5; // w0
char *v6; // x26
__int64 v7; // x0
char *v8; // x27
__int64 v9; // x1
unsigned __int64 v10; // x20
unsigned __int64 v11; // x0
__int64 v12; // x1
int32x4_t v13; // q0
int32x4_t *v14; // x4
unsigned __int64 v15; // x3
int32x4_t v16; // t1
signed int v17; // w21
signed int v18; // w3
unsigned __int64 v19; // x0
signed int v20; // w3
unsigned __int64 v21; // x0
signed int v22; // w0
unsigned __int64 v23; // x1
unsigned int v24; // w1
size_t v25; // x27
size_t v26; // x25
size_t v27; // x27
size_t v28; // x0
size_t v29; // x25
unsigned __int64 v30; // x27
size_t v31; // x25
unsigned __int64 v32; // x25
char *v34; // x0
size_t v35; // x25
size_t v36; // x25
size_t v37; // x0
unsigned __int8 v38; // w0
int v39; // w1
__int64 v40; // x2
size_t v41; // x1
__int64 v42; // x2
char v43; // w0
char *v44; // x1
size_t v45; // x2
__int64 *v46; // x0
size_t v47; // x3
char *v48; // [xsp+68h] [xbp+68h]
const char *v49; // [xsp+70h] [xbp+70h]
size_t v50; // [xsp+70h] [xbp+70h]
size_t v51; // [xsp+78h] [xbp+78h]
size_t v52; // [xsp+78h] [xbp+78h]
size_t v53; // [xsp+78h] [xbp+78h]
void *v54; // [xsp+78h] [xbp+78h]
int v55; // [xsp+78h] [xbp+78h]
int32x4_t *v56; // [xsp+98h] [xbp+98h] BYREF
int32x4_t *v57; // [xsp+A0h] [xbp+A0h]
__int64 v58; // [xsp+A8h] [xbp+A8h]
__int64 v59; // [xsp+B0h] [xbp+B0h] BYREF
size_t v60; // [xsp+B8h] [xbp+B8h]
void *v61; // [xsp+C0h] [xbp+C0h]
unsigned __int64 v62[3]; // [xsp+C8h] [xbp+C8h] BYREF
__int64 v63; // [xsp+E0h] [xbp+E0h] BYREF
size_t v64; // [xsp+E8h] [xbp+E8h]
__int64 v65; // [xsp+F0h] [xbp+F0h]
size_t v66; // [xsp+F8h] [xbp+F8h] BYREF
unsigned __int64 v67; // [xsp+100h] [xbp+100h]
_BYTE *v68; // [xsp+108h] [xbp+108h]
_BYTE v69[504]; // [xsp+110h] [xbp+110h] BYREF
v5 = *((_DWORD *)this + 411);
if ( v5 > 0 && a2 - v5 > a3 )
{
v6 = (char *)this + 1592;
if ( (*((_BYTE *)this + 1592) & 1) != 0 )
v7 = *((_QWORD *)this + 200);
else
v7 = *((_BYTE *)this + 1592) >> 1;
if ( !v7 )
{
v8 = (char *)this + 1616;
v9 = *((_BYTE *)this + 1616) >> 1;
if ( (*((_BYTE *)this + 1616) & 1) != 0 )
v9 = *((_QWORD *)this + 203);
if ( !v9 )
goto LABEL_41;
}
GJGameLevel::ensureSessionLog(this);
v56 = nullptr;
v57 = nullptr;
v58 = 0;
GJGameLevel::dtExpandOrder((__int64)this + 1592, (__int64)&v56);
v10 = ((char *)v57 - (char *)v56) >> 2;
if ( !v10 )
{
v17 = 0;
goto LABEL_25;
}
v11 = ((v10 - 4) >> 2) + 1;
v12 = 4 * v11;
if ( v10 - 1 <= 3 )
{
v12 = 0;
v19 = 1;
if ( v56->n128_i32[0] > 0 )
v17 = v56->n128_u32[0];
else
v17 = 0;
if ( v10 <= 1 )
goto LABEL_25;
}
else
{
v13 = 0u;
v14 = v56;
v15 = 0;
do
{
v16 = *v14++;
++v15;
v13 = vmaxq_s32(v13, v16);
}
while ( v15 < v11 );
v17 = vmaxvq_s32(v13);
if ( v10 == v12 )
goto LABEL_25;
v18 = v56[v11].n128_i32[0];
v19 = v12 + 1;
if ( v17 < v18 )
v17 = v18;
if ( v19 >= v10 )
{
LABEL_25:
v24 = *((_DWORD *)this + 410);
v66 = 0;
v67 = 500;
v68 = v69;
fmt::BasicWriter::FormatInt,char>>(&v66, v24);
v25 = v66;
v26 = v66 + 1;
if ( v66 + 1 > v67 )
fmt::internal::Array::grow(&v66, v66 + 1);
v66 = v26;
v68[v25] = aGeneratorUncom[24];
if ( (*((_BYTE *)this + 1592) & 1) != 0 )
{
v27 = *((_QWORD *)this + 200);
v49 = *((const char **)this + 201);
if ( !v27 )
{
if ( !v49 )
{
v29 = v66;
if ( v67 >= v66 )
{
LABEL_33:
if ( v29 + 1 > v67 )
fmt::internal::Array::grow(&v66, v29 + 1);
v8 = (char *)this + 1616;
v66 = v29 + 1;
v68[v29] = aGeneratorUncom[24];
if ( (*((_BYTE *)this + 1616) & 1) != 0 )
{
v31 = *((_QWORD *)this + 203);
v48 = *((char **)this + 204);
if ( v31 )
{
LABEL_37:
v50 = v31;
v52 = v66;
v32 = v31 + v66;
if ( v67 >= v32 )
{
v66 = v32;
memmove(&v68[v52], v48, v50);
v52 = v66;
LABEL_60:
if ( v52 + 1 > v67 )
fmt::internal::Array::grow(&v66, v52 + 1);
v66 = v52 + 1;
v68[v52] = aGeneratorUncom[24];
fmt::BasicWriter::FormatInt,char>>(
&v66,
*((_DWORD *)this + 412));
v53 = v66;
v35 = v66 + 1;
if ( v66 + 1 > v67 )
fmt::internal::Array::grow(&v66, v66 + 1);
v66 = v35;
v68[v53] = aGeneratorUncom[24];
fmt::BasicWriter::FormatInt,char>>(
&v66,
v17);
v36 = v66;
if ( v67 < v66 + 1 )
fmt::internal::Array::grow(&v66, v66 + 1);
v68[v36] = 0;
v59 = 0;
v60 = 0;
v61 = nullptr;
v54 = v68;
v37 = strlen(v68);
std::string::__init(&v59, v54, v37);
v38 = *((_BYTE *)this + 1664);
v39 = v38 & 1;
v40 = v38 >> 1;
if ( (v38 & 1) != 0 )
v40 = *((_QWORD *)this + 209);
if ( v40 )
{
std::operator+("|", (__int64)&v59, v62);
if ( (*((_BYTE *)this + 1664) & 1) != 0 )
{
v44 = *((char **)this + 210);
v45 = *((_QWORD *)this + 209);
}
else
{
v44 = (char *)this + 1665;
v45 = *((_BYTE *)this + 1664) >> 1;
}
v46 = (__int64 *)std::string::append((__int64)v62, v44, v45);
v47 = v46[1];
v55 = 1;
v63 = *v46;
v64 = v47;
v65 = v46[2];
*v46 = 0;
v46[1] = 0;
v46[2] = 0;
v39 = *((_BYTE *)this + 1664) & 1;
}
else
{
v63 = 0;
v64 = 0;
v65 = 0;
if ( (v59 & 1) != 0 )
{
std::string::__init(&v63, v61, v60);
v55 = 0;
v39 = *((_BYTE *)this + 1664) & 1;
}
else
{
v65 = (__int64)v61;
v55 = 0;
v63 = v59;
v64 = v60;
}
}
if ( v39 )
{
**((_BYTE **)this + 210) = 0;
*((_QWORD *)this + 209) = 0;
}
else
{
*((_BYTE *)this + 1665) = 0;
*((_BYTE *)this + 1664) = 0;
}
std::string::reserve((__int64 *)this + 208, 0);
v41 = v64;
v42 = v65;
*((_QWORD *)this + 208) = v63;
*((_QWORD *)this + 209) = v41;
*((_QWORD *)this + 210) = v42;
if ( v55 && (v62[0] & 1) != 0 )
operator delete((void *)v62[2]);
v43 = v59;
*((_BYTE *)this + 1712) = 1;
if ( (v43 & 1) != 0 )
operator delete(v61);
if ( v68 != v69 && v68 )
operator delete[](v68);
if ( v56 )
{
if ( v56 != v57 )
v57 = (int32x4_t *)((char *)v57
+ 4
* ~((unsigned __int64)((char *)&v57[-1].n128_f64[1] + 4 - (char *)v56) >> 2));
operator delete(v56);
}
goto LABEL_41;
}
goto LABEL_95;
}
if ( !v48 )
{
v52 = v66;
if ( v67 >= v66 )
goto LABEL_60;
v32 = v66;
v50 = 0;
LABEL_95:
fmt::internal::Array::grow(&v66, v32);
LABEL_58:
v66 = v32;
if ( v50 )
{
memmove(&v68[v52], v48, v50);
v52 = v66;
}
else
{
v52 = v32;
}
goto LABEL_60;
}
}
else
{
v31 = *((_BYTE *)this + 1616) >> 1;
v48 = (char *)this + 1617;
if ( *((_BYTE *)this + 1616) >> 1 )
goto LABEL_37;
}
v50 = strlen(v48);
v32 = v50 + v66;
v52 = v66;
if ( v50 + v66 <= v67 )
goto LABEL_58;
goto LABEL_95;
}
v30 = v66;
v51 = 0;
goto LABEL_54;
}
LABEL_30:
v28 = strlen(v49);
v29 = v66;
v51 = v28;
v30 = v28 + v66;
if ( v28 + v66 <= v67 )
{
LABEL_31:
v66 = v30;
if ( !v51 )
{
v29 = v30;
goto LABEL_33;
}
v34 = &v68[v29];
goto LABEL_93;
}
LABEL_54:
fmt::internal::Array::grow(&v66, v30);
goto LABEL_31;
}
}
else
{
v27 = *((_BYTE *)this + 1592) >> 1;
v49 = (char *)this + 1593;
if ( !(*((_BYTE *)this + 1592) >> 1) )
goto LABEL_30;
}
v51 = v27;
v29 = v66;
v30 = v27 + v66;
if ( v67 >= v30 )
{
v66 = v30;
v34 = &v68[v29];
LABEL_93:
memmove(v34, v49, v51);
v29 = v66;
goto LABEL_33;
}
goto LABEL_54;
}
}
v20 = v56->n128_i32[v19];
v21 = v12 + 2;
if ( v17 < v20 )
v17 = v20;
if ( v21 < v10 )
{
v22 = v56->n128_i32[v21];
v23 = v12 + 3;
if ( v17 < v22 )
v17 = v22;
if ( v23 < v10 && v17 < (signed __int32)v56->n128_u32[v23] )
v17 = v56->n128_i32[v23];
}
goto LABEL_25;
}
if ( *((_DWORD *)this + 410) )
goto LABEL_46;
v8 = (char *)this + 1616;
v6 = (char *)this + 1592;
LABEL_41:
if ( (*((_BYTE *)this + 1592) & 1) != 0 )
{
**((_BYTE **)v6 + 2) = 0;
*((_QWORD *)v6 + 1) = 0;
}
else
{
*((_BYTE *)this + 1593) = 0;
*((_BYTE *)this + 1592) = 0;
}
if ( (*((_BYTE *)this + 1616) & 1) != 0 )
{
**((_BYTE **)v8 + 2) = 0;
*((_QWORD *)v8 + 1) = 0;
}
else
{
*((_BYTE *)this + 1617) = 0;
*((_BYTE *)this + 1616) = 0;
}
*((_DWORD *)this + 412) = 0;
*((_DWORD *)this + 410) = a2;
LABEL_46:
*((_DWORD *)this + 411) = a2;
return _stack_chk_guard;
}