//
// sub_82042C from 0x82042c to 0x820590 (356 bytes)
//
// 2 xrefs:
// > sub_83168C @ 0x8332ce
// > sub_83168C @ 0x833332
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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:01:50 +0000
//
int __fastcall sub_82042C(int *a1, const char *a2, int a3, const char **a4, int a5)
{
int v5; // r4
unsigned int v6; // r0
unsigned int v8; // r0
__int64 v9; // r0
signed int v10; // r0
int v11; // [sp+4h] [bp-50h]
char v16; // [sp+1Fh] [bp-35h]
int v17; // [sp+20h] [bp-34h]
int seconds; // [sp+24h] [bp-30h]
__time_t v19[2]; // [sp+28h] [bp-2Ch] BYREF
_DWORD v20[4]; // [sp+30h] [bp-24h] BYREF
_DWORD v21[2]; // [sp+40h] [bp-14h] BYREF
int v22; // [sp+48h] [bp-Ch]
int v23; // [sp+4Ch] [bp-8h]
v11 = *a1;
v16 = 0;
*a4 = nullptr;
seconds = 0;
if ( a5 < 0 )
return -2;
if ( *(_BYTE *)(v11 + 932) )
v17 = 0;
else
v17 = a5;
if ( v17 )
{
if ( v17 < 1000 )
{
sub_828178(v11, "remaining timeout of %ld too small to resolve via SIGALRM method", v17);
return -2;
}
if ( sigsetjmp() )
{
v5 = -1;
sub_828178(v11, "name lookup timed out");
v6 = 0;
}
else
{
sigaction(14, nullptr, (struct sigaction *)v21);
v16 = 1;
v20[0] = v21[0];
v20[1] = v21[1];
v20[2] = v22;
v20[3] = v23;
v21[0] = sub_81FF88;
v22 &= ~0x10000000u;
sigaction(14, (const struct sigaction *)v21, nullptr);
v8 = nullsub_2(v17 / 1000);
seconds = alarm(v8);
v5 = sub_8202A4(a1, a2, a3, a4);
v6 = seconds;
if ( seconds )
{
LABEL_16:
sigaction(14, (const struct sigaction *)v20, nullptr);
if ( seconds )
{
sub_81FA10(v19);
v9 = 274877907LL * (unsigned int)sub_81FA58(v19[0], v19[1], a1[102], a1[103]);
v10 = seconds - (HIDWORD(v9) >> 6);
if ( seconds == HIDWORD(v9) >> 6 || v10 < 0 && seconds >= 0 )
{
alarm(1u);
sub_828178(v11, "Previous alarm fired off!");
return -2;
}
alarm(v10);
}
return v5;
}
}
alarm(v6);
if ( !v16 )
return v5;
goto LABEL_16;
}
return sub_8202A4(a1, a2, a3, a4);
}