//
// sub_6276B0 from 0x6276b0 to 0x6278ea (570 bytes)
//
// 2 xrefs:
// > sub_627C48 @ 0x627ede
// > sub_627C48 @ 0x62839a
//
// 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
//
void *__fastcall sub_6276B0(size_t a1, int *a2)
{
void *result; // r0
int v4; // r4
unsigned __int8 *v5; // r3
int v6; // r6
const char *v7; // r4
size_t v8; // r7
int v9; // r4
unsigned int v10; // r6
size_t v11; // r10
int v12; // r1
_BYTE *v13; // r0
int v14; // r1
size_t v15; // r4
const char *v16; // r4
_DWORD *v17; // r0
_DWORD *v18; // r0
_BYTE v20[128]; // [sp+28h] [bp-80h] BYREF
_DWORD v21[32]; // [sp+A8h] [bp+0h] BYREF
_BYTE v22[2]; // [sp+128h] [bp+80h] BYREF
unsigned __int8 v23[2050]; // [sp+12Ah] [bp+82h] BYREF
memset(v20, 0, sizeof(v20));
v21[0] = 0;
result = memset(&v21[1], 0, 0x7Cu);
v4 = *(_DWORD *)(a1 + 332);
v5 = *(unsigned __int8 **)(v4 + 7856);
if ( *(_BYTE *)(a1 + 912) )
{
result = (void *)sub_6273A8(a1, 0x3Cu, (unsigned __int8 *)(v4 + 7344), *(_DWORD *)(v4 + 7860) - (_DWORD)v5 + 2);
v5 = *(unsigned __int8 **)(v4 + 7856);
}
*(_DWORD *)(v4 + 7856) = v5 + 1;
v6 = *v5;
if ( v6 == 35 )
{
v16 = (const char *)(v4 + 7208);
v8 = strlen(v16);
sub_624640(v22, 2048, "%c%c%c%c%s%c%c", 255, 250, 35, 0, v16, 255, 240);
result = (void *)send(*a2, v22, v8 + 6, 0x4000);
if ( (int)result >= 0 )
{
LABEL_9:
if ( *(_BYTE *)(a1 + 912) )
return (void *)sub_6273A8(a1, 0x3Eu, v23, v8 + 4);
return result;
}
LABEL_8:
v18 = (_DWORD *)_errno();
result = (void *)sub_6180F8(a1, "Sending data failed (%d)", *v18);
goto LABEL_9;
}
if ( v6 != 39 )
{
if ( v6 != 24 )
return result;
v7 = (const char *)(v4 + 7176);
v8 = strlen(v7);
sub_624640(v22, 2048, "%c%c%c%c%s%c%c", 255, 250, 24, 0, v7, 255, 240);
result = (void *)send(*a2, v22, v8 + 6, 0x4000);
if ( (int)result >= 0 )
goto LABEL_9;
goto LABEL_8;
}
sub_624640(v22, 2048, "%c%c%c%c", 255, 250, 39, 0);
v9 = *(_DWORD *)(v4 + 7340);
if ( v9 )
{
v10 = 4;
do
{
while ( 1 )
{
v11 = strlen(*(const char **)v9) + v10 + 1;
if ( v11 <= 0x7F9 )
{
if ( sscanf(*(const char **)v9, "%127[^,],%127s", v20, v21) )
break;
}
v9 = *(_DWORD *)(v9 + 4);
if ( !v9 )
goto LABEL_17;
}
v12 = 2048 - v10;
v13 = &v22[v10];
v10 = v11;
sub_624640(v13, v12, "%c%s%c%s", 0, v20, 1, v21);
v9 = *(_DWORD *)(v9 + 4);
}
while ( v9 );
LABEL_17:
v14 = 2048 - v10;
v15 = v10 + 2;
}
else
{
v15 = 6;
v14 = 2044;
v10 = 4;
}
sub_624640(&v22[v10], v14, "%c%c", 255, 240);
result = (void *)send(*a2, v22, v15, 0x4000);
if ( (int)result < 0 )
{
v17 = (_DWORD *)_errno();
result = (void *)sub_6180F8(a1, "Sending data failed (%d)", *v17);
}
if ( *(_BYTE *)(a1 + 912) )
return (void *)sub_6273A8(a1, 0x3Eu, v23, v10);
return result;
}