//
// EmotePickerPopup::onBuildWindowContent from 0xcba770 to 0xcbac74 (1284 bytes)
//
// 2 xrefs:
// > ??> @ 0xa8a60
// > ??> @ 0x14fa388
//
// 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:06:14 +0000
//
__int64 __fastcall EmotePickerPopup::onBuildWindowContent(EmotePickerPopup *this)
{
__int64 v2; // x2
__int64 v3; // x1
GameManager *v4; // x0
__int64 v5; // x0
int v6; // w2
__int64 v7; // x23
__int64 v8; // x19
_BYTE *v9; // x25
__int64 v10; // x27
__int64 v11; // x21
unsigned __int64 v12; // x20
__int64 v13; // x26
size_t v14; // x3
unsigned __int64 v15; // x2
__int64 i; // x1
size_t v17; // x2
void *v18; // x1
int v19; // w1
size_t v20; // x2
__int64 *v21; // x0
char v22; // w1
size_t v23; // x3
char v24; // w1
__int64 v25; // x2
unsigned __int64 v26; // x0
_BYTE *v27; // x3
_BYTE *v28; // x0
__int64 v29; // x0
__int64 v30; // x20
unsigned __int64 j; // x19
__int64 v32; // x0
__int64 v33; // x26
EmoteSprite *v34; // x0
__int64 v35; // x0
__int64 v36; // x0
__int64 *v37; // x1
unsigned int v38; // w19
__int64 v39; // x1
EmoteSprite *v40; // x19
EmoteSprite *v41; // x0
__int64 v43; // x19
_BYTE *v44; // x21
std::logic_error *exception; // x20
__int64 v46; // [xsp+60h] [xbp+60h] BYREF
EmoteSprite *v47; // [xsp+68h] [xbp+68h] BYREF
EmoteSprite *v48; // [xsp+70h] [xbp+70h]
EmoteSprite *v49; // [xsp+78h] [xbp+78h]
__int64 v50; // [xsp+80h] [xbp+80h] BYREF
size_t v51; // [xsp+88h] [xbp+88h]
void *v52; // [xsp+90h] [xbp+90h]
v2 = *((_QWORD *)this + 152);
v3 = *((_QWORD *)this + 153);
v4 = (GameManager *)_stack_chk_guard;
if ( v2 != v3 )
{
v4 = (GameManager *)(v3 + 8 * ~((unsigned __int64)(v3 - 8 - v2) >> 3));
*((_QWORD *)this + 153) = v4;
}
v47 = nullptr;
v48 = nullptr;
v49 = nullptr;
v5 = GameManager::sharedState(v4);
v6 = *(unsigned __int8 *)(v5 + 1664);
v7 = v5 + 1664;
if ( (v6 & 1) == 0 )
{
LODWORD(v10) = v6 >> 1;
if ( !(v6 >> 1) )
goto LABEL_5;
v9 = (_BYTE *)(v5 + 1665);
v43 = v5 + 1665 + (int)v10;
if ( v5 + 1665 == v43 )
{
v11 = -1;
goto LABEL_70;
}
LABEL_72:
v44 = v9;
if ( *v9 == 44 )
{
v11 = 0;
}
else
{
do
{
if ( (_BYTE *)v43 == ++v44 )
{
v11 = -1;
goto LABEL_77;
}
}
while ( *v44 != 44 );
v11 = v44 - v9;
}
LABEL_77:
LODWORD(v10) = v6 >> 1;
if ( (v6 & 1) != 0 )
goto LABEL_78;
LABEL_70:
v10 = (int)v10;
goto LABEL_6;
}
v8 = *(_QWORD *)(v5 + 1672);
v9 = *(_BYTE **)(v5 + 1680);
if ( v8 )
{
v43 = (__int64)&v9[v8];
v11 = -1;
if ( (_BYTE *)v43 == v9 )
{
LABEL_78:
v10 = *(_QWORD *)(v5 + 1672);
goto LABEL_6;
}
goto LABEL_72;
}
LABEL_5:
v10 = 0;
v11 = -1;
LABEL_6:
v50 = 0;
v51 = 0;
v12 = 0;
v52 = nullptr;
v13 = v5 + 1665;
v14 = v11;
if ( (v6 & 1) == 0 )
goto LABEL_27;
LABEL_7:
v15 = *(_QWORD *)(v7 + 8);
if ( v12 > v15 )
{
LABEL_79:
exception = (std::logic_error *)_cxa_allocate_exception(0x10u);
std::logic_error::logic_error(exception, "basic_string");
*(_QWORD *)exception = off_1536D68;
_cxa_throw(
exception,
(struct type_info *)&`typeinfo for'std::out_of_range,
(void (*)(void *))std::logic_error::~logic_error);
}
for ( i = *(_QWORD *)(v7 + 16); ; i = v13 )
{
v17 = v15 - v12;
v18 = (void *)(i + v12);
if ( v17 > v14 )
v17 = v14;
std::string::__init(&v50, v18, v17);
v19 = v50 & 1;
v20 = (unsigned __int8)v50 >> 1;
if ( (v50 & 1) != 0 )
v20 = v51;
if ( v20 || v12 != v10 )
break;
LABEL_20:
if ( v11 == -1 )
goto LABEL_42;
LABEL_21:
v12 = v11 + 1;
if ( (*(_BYTE *)v7 & 1) != 0 )
{
v25 = *(_QWORD *)(v7 + 16);
v26 = *(_QWORD *)(v7 + 8);
}
else
{
v25 = v13;
v26 = *(_BYTE *)v7 >> 1;
}
v11 = -1;
if ( v12 >= v26 || (v27 = (_BYTE *)(v25 + v12), v28 = (_BYTE *)(v25 + v26), (_BYTE *)(v25 + v12) == v28) )
{
if ( !v19 )
goto LABEL_25;
}
else if ( *(_BYTE *)(v25 + v12) == 44 )
{
LABEL_38:
v11 = (__int64)&v27[-v25];
if ( !v19 )
goto LABEL_25;
}
else
{
while ( v28 != ++v27 )
{
if ( *v27 == 44 )
goto LABEL_38;
}
v11 = -1;
if ( !v19 )
{
LABEL_25:
LOBYTE(v6) = *(_BYTE *)v7;
goto LABEL_26;
}
}
operator delete(v52);
LOBYTE(v6) = *(_BYTE *)v7;
LABEL_26:
v50 = 0;
v14 = v11 - v12;
v51 = 0;
v52 = nullptr;
if ( (v6 & 1) != 0 )
goto LABEL_7;
LABEL_27:
v15 = (unsigned __int8)v6 >> 1;
if ( v12 > v15 )
goto LABEL_79;
}
v21 = (__int64 *)v48;
if ( v48 != v49 )
{
if ( v48 )
{
*(_QWORD *)v48 = 0;
v21[1] = 0;
v22 = v50;
v21[2] = 0;
if ( (v22 & 1) != 0 )
{
std::string::__init(v21, v52, v51);
v21 = (__int64 *)v48;
v19 = v50 & 1;
}
else
{
v23 = v51;
*v21 = v50;
v21[1] = v23;
v24 = v50;
v21[2] = (__int64)v52;
v19 = v24 & 1;
v21 = (__int64 *)v48;
}
}
v48 = (EmoteSprite *)(v21 + 3);
goto LABEL_20;
}
std::vector::__push_back_slow_path((__int64 *)&v47, &v50);
v19 = v50 & 1;
if ( v11 != -1 )
goto LABEL_21;
LABEL_42:
if ( v19 )
operator delete(v52);
v29 = (__int64)v47;
v30 = 0;
for ( j = 0; j < 0xAAAAAAAAAAAAAAABLL * ((v48 - v47) >> 3); v30 += 24 )
{
v32 = EmoteSprite::defForName((char *)(v29 + v30));
v33 = v32;
if ( v32 )
{
v34 = (EmoteSprite *)*(unsigned __int8 *)(v32 + 27);
if ( !(_DWORD)v34 )
{
v35 = EmoteSprite::defAtIndex(v34);
v36 = EmotePickerPopup::addCell((__int64)this, v33, -1431655765 * (unsigned int)((v33 - v35) >> 4) + 100000);
v46 = v36;
if ( v36 )
{
v37 = *((__int64 **)this + 153);
if ( v37 == *((__int64 **)this + 154) )
{
std::vector::__push_back_slow_path((__int64)this + 1216, &v46);
}
else
{
if ( v37 )
{
*v37 = v36;
v37 = *((__int64 **)this + 153);
}
*((_QWORD *)this + 153) = v37 + 1;
}
}
}
}
v29 = (__int64)v47;
++j;
}
v38 = 0;
while ( (int)v38 < (int)EmoteSprite::defCount((EmoteSprite *)v29) )
{
v39 = EmoteSprite::defAtIndex((EmoteSprite *)v38);
v29 = *(_QWORD *)v39;
if ( *(_QWORD *)v39 && (v29 = *(unsigned __int8 *)(v39 + 27), !*(_BYTE *)(v39 + 27)) )
v29 = EmotePickerPopup::addCell((__int64)this, v39, v38++);
else
++v38;
}
EmotePickerPopup::layoutEmoteGrid(this);
v40 = v47;
if ( v47 )
{
v41 = v48;
if ( v47 != v48 )
{
do
{
v48 = (EmoteSprite *)((char *)v41 - 24);
std::string::~string((__int64)v41 - 24);
v41 = v48;
}
while ( v40 != v48 );
v41 = v47;
}
operator delete(v41);
}
return _stack_chk_guard;
}