//
// sub_62D6F0 from 0x62d6f0 to 0x62d99e (686 bytes)
//
// 2 xrefs:
// > sub_621424 @ 0x6214c4
// > sub_62D9B8 @ 0x62dc18
//
// 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_62D6F0(int result, int a2)
{
int v2; // r5
int v4; // r4
int v5; // r6
int v6; // r7
int *v7; // r8
int v8; // r1
int v9; // r3
int v10; // r6
int v11; // r5
int v12; // r0
int v13; // r2
int v14; // r6
int v15; // r5
int v16; // r0
int v17; // r3
int v18; // r5
int v19; // r0
int v20; // r1
int v21; // r2
int v22; // r6
int v23; // lr
int v24; // r6
const char *v25; // r0
int v26; // r6
const char *v27; // r0
int v28; // r6
const char *v29; // r0
int v30; // r3
int *v31; // r2
int v32; // lr
int v33; // r7
int v34; // r0
int v35; // r1
int v36; // r2
int v37; // r1
int sa_family; // r0
bool v39; // zf
int v40; // r6
const char *v41; // r0
socklen_t v42; // [sp+4h] [bp-108h] BYREF
struct sockaddr cp; // [sp+8h] [bp-104h] BYREF
struct sockaddr af[8]; // [sp+88h] [bp-84h] BYREF
v2 = *(_DWORD *)result;
if ( *(_DWORD *)(result + 140) != 2 )
{
v4 = result;
if ( *(_BYTE *)(result + 614) || *(_BYTE *)(result + 642) )
{
v5 = result + 274;
v6 = result + 324;
v7 = (int *)(result + 306);
goto LABEL_5;
}
v42 = 128;
if ( getpeername(a2, &cp, &v42) )
{
v26 = *(_DWORD *)_errno();
v27 = (const char *)sub_6325A4(v4, v26);
return sub_6180F8(v2, "getpeername() failed with errno %d: %s", v26, v27);
}
v42 = 128;
memset(af, 0, sizeof(af));
if ( getsockname(a2, af, &v42) )
{
v24 = *(_DWORD *)_errno();
v25 = (const char *)sub_6325A4(v4, v24);
return sub_6180F8(v2, "getsockname() failed with errno %d: %s", v24, v25);
}
v5 = v4 + 274;
switch ( cp.sa_family )
{
case 2u:
if ( !inet_ntop(2, &cp.sa_data[2], (char *)(v4 + 274), 46) )
goto LABEL_18;
break;
case 0xAu:
if ( !inet_ntop(10, &cp.sa_data[6], (char *)(v4 + 274), 46) )
goto LABEL_18;
break;
case 1u:
sub_624640((_BYTE *)(v4 + 274), 46, "%s", cp.sa_data);
*(_DWORD *)(v4 + 320) = 0;
LABEL_21:
v30 = v4 + 88;
v7 = (int *)(v4 + 306);
v31 = (int *)(v4 + 274);
do
{
v32 = *v31;
v31 += 4;
v33 = *(v31 - 3);
v30 += 16;
v34 = *(v31 - 2);
v35 = *(v31 - 1);
*(_DWORD *)(v30 - 16) = v32;
*(_DWORD *)(v30 - 12) = v33;
*(_DWORD *)(v30 - 8) = v34;
*(_DWORD *)(v30 - 4) = v35;
}
while ( v31 != v7 );
v6 = v4 + 324;
v36 = *(_DWORD *)(v4 + 314);
v37 = *(_DWORD *)(v4 + 310);
*(_DWORD *)v30 = *v7;
*(_DWORD *)(v30 + 8) = v36;
*(_DWORD *)(v30 + 4) = v37;
sa_family = af[0].sa_family;
v39 = af[0].sa_family == 2;
*(_WORD *)(v30 + 12) = *(_WORD *)(v4 + 318);
if ( v39 )
{
if ( !inet_ntop(sa_family, &af[0].sa_data[2], (char *)(v4 + 324), 46) )
goto LABEL_26;
}
else
{
if ( sa_family != 10 )
{
if ( sa_family != 1 )
{
LABEL_26:
*(_BYTE *)(v4 + 324) = 0;
*(_DWORD *)(v4 + 372) = 0;
v40 = *(_DWORD *)_errno();
v41 = (const char *)sub_6325A4(v4, v40);
return sub_6180F8(v2, "ssloc inet_ntop() failed with errno %d: %s", v40, v41);
}
sub_624640((_BYTE *)(v4 + 324), 46, "%s", af[0].sa_data);
*(_DWORD *)(v4 + 372) = 0;
LABEL_31:
v2 = *(_DWORD *)v4;
LABEL_5:
v8 = v5;
v9 = v2 + 34828;
do
{
v10 = *(_DWORD *)v8;
v8 += 16;
v11 = *(_DWORD *)(v8 - 12);
v9 += 16;
v12 = *(_DWORD *)(v8 - 8);
v13 = *(_DWORD *)(v8 - 4);
*(_DWORD *)(v9 - 16) = v10;
*(_DWORD *)(v9 - 12) = v11;
*(_DWORD *)(v9 - 8) = v12;
*(_DWORD *)(v9 - 4) = v13;
}
while ( (int *)v8 != v7 );
v14 = v6 + 32;
v15 = *(_DWORD *)v8;
v16 = *(_DWORD *)(v8 + 4);
*(_DWORD *)(v9 + 8) = *(_DWORD *)(v8 + 8);
*(_DWORD *)v9 = v15;
*(_DWORD *)(v9 + 4) = v16;
*(_WORD *)(v9 + 12) = *(_WORD *)(v8 + 12);
v17 = *(_DWORD *)v4 + 34880;
do
{
v18 = *(_DWORD *)v6;
v6 += 16;
v19 = *(_DWORD *)(v6 - 12);
v17 += 16;
v20 = *(_DWORD *)(v6 - 8);
v21 = *(_DWORD *)(v6 - 4);
*(_DWORD *)(v17 - 16) = v18;
*(_DWORD *)(v17 - 12) = v19;
*(_DWORD *)(v17 - 8) = v20;
*(_DWORD *)(v17 - 4) = v21;
}
while ( v6 != v14 );
v22 = *(_DWORD *)(v6 + 8);
v23 = *(_DWORD *)(v6 + 4);
*(_DWORD *)v17 = *(_DWORD *)v6;
*(_DWORD *)(v17 + 8) = v22;
*(_DWORD *)(v17 + 4) = v23;
*(_WORD *)(v17 + 12) = *(_WORD *)(v6 + 12);
*(_DWORD *)(*(_DWORD *)v4 + 34932) = **(_DWORD **)(v4 + 664);
*(_DWORD *)(*(_DWORD *)v4 + 34936) = *(_DWORD *)(*(_DWORD *)(v4 + 664) + 60);
result = *(_DWORD *)(v4 + 320);
*(_DWORD *)(*(_DWORD *)v4 + 34876) = result;
*(_DWORD *)(*(_DWORD *)v4 + 34928) = *(_DWORD *)(v4 + 372);
return result;
}
if ( !inet_ntop(10, &af[0].sa_data[6], (char *)(v4 + 324), 46) )
goto LABEL_26;
}
*(_DWORD *)(v4 + 372) = (unsigned __int16)__rev16(*(unsigned __int16 *)af[0].sa_data);
goto LABEL_31;
default:
LABEL_18:
*(_BYTE *)(v4 + 274) = 0;
*(_DWORD *)(v4 + 320) = 0;
v28 = *(_DWORD *)_errno();
v29 = (const char *)sub_6325A4(v4, v28);
return sub_6180F8(v2, "ssrem inet_ntop() failed with errno %d: %s", v28, v29);
}
*(_DWORD *)(v4 + 320) = (unsigned __int16)__rev16(*(unsigned __int16 *)cp.sa_data);
goto LABEL_21;
}
return result;
}