//
// sub_6470B0 from 0x6470b0 to 0x64722c (380 bytes)
//
// 1 xrefs:
// > lws_service_fd @ 0x64752c
//
// 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
//
int __fastcall sub_6470B0(int a1, int a2)
{
int v3; // r3
int v5; // r0
_BOOL4 v6; // r6
const char *v7; // r0
int v8; // r3
int v9; // r2
int v11; // r3
int v12; // r0
int v13; // r2
int v14; // [sp+8h] [bp-8h] BYREF
const char *v15; // [sp+Ch] [bp-4h]
if ( *(_DWORD *)(a1 + 256) )
return sub_647B0C(a1, *(_DWORD *)(a1 + 200) + *(_DWORD *)(a1 + 252)) >> 31;
v3 = *(unsigned __int8 *)(a1 + 264);
if ( v3 == 9 )
return -1;
if ( v3 != 5 )
{
if ( v3 != 7 )
goto LABEL_5;
if ( (*(_BYTE *)(a1 + 178) & 0x40) == 0 )
goto LABEL_14;
v11 = 4;
LABEL_25:
if ( lws_write(a1, a1 + 44, *(unsigned __int8 *)(a1 + 169), v11) >= 0 )
{
v12 = *(_BYTE *)(a1 + 178) & 0x7F;
*(_BYTE *)(a1 + 178) = v12;
return v12 << 25 >> 31;
}
return -1;
}
v13 = *(unsigned __int8 *)(a1 + 178);
if ( (v13 & 0xFFFFFF80) != 0 )
{
if ( (v13 & 0x40) != 0 )
v11 = 4;
else
v11 = 6;
goto LABEL_25;
}
if ( (*(_BYTE *)(a1 + 179) & 0x80) != 0 )
return lws_write(a1, v13 & 0x80, v13 & 0x80, 2) >> 31;
LABEL_5:
sub_64C6B0(a1, 20, 0, 0);
if ( (*(_BYTE *)(a1 + 260) & 0x20) != 0 )
{
while ( 1 )
{
while ( 1 )
{
v14 = 0;
v15 = nullptr;
v5 = sub_64C6B0(a1, 12, &v14, 0);
v6 = v5 != 0;
if ( v5 < 0 )
{
lws_log(1, "ext reports fatal error\n");
return -1;
}
if ( v15 )
break;
if ( !v5 )
goto LABEL_13;
}
v7 = (const char *)sub_647B0C(a1, v14);
if ( (int)v7 < 0 )
return -1;
if ( v15 != v7 )
break;
if ( !v6 )
{
LABEL_13:
*(_BYTE *)(a1 + 260) &= ~0x20u;
goto LABEL_14;
}
if ( lws_send_pipe_choked(a1) )
return 0;
}
lws_log(1, "Unable to spill ext %d vs %s\n", v15, v7);
return -1;
}
LABEL_14:
if ( a2 && sub_647814(a1, 4, 0) )
return 1;
v8 = *(unsigned __int8 *)(a1 + 263);
if ( v8 == 3 )
{
v9 = 11;
}
else if ( v8 == 4 )
{
v9 = 10;
}
else
{
v9 = 16;
}
return sub_646660(
*(int (__fastcall **)(int, int, int, int, int))(*(_DWORD *)(a1 + 188) + 4),
a1,
v9,
*(_DWORD *)(a1 + 192),
0,
0);
}