//
// tzset_from_environment_nolock from 0x18013cd2c to 0x18013cfbf (659 bytes)
//
// 2 xrefs:
// > tzset_nolock @ 0x18013d217
// > ??> @ 0x180203a4c
//
// 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 tzset_from_environment_nolock(wchar_t *Source)
{
void **v2; // r15
__int64 v3; // rax
void **v4; // r12
wchar_t *v5; // rax
int v6; // r8d
int v7; // edx
__int64 v8; // rdi
__int64 v9; // rcx
void *v10; // rbx
void *v11; // rcx
__int64 v12; // rax
wchar_t v13; // r14
const wchar_t *v14; // rdi
int v15; // esi
int v16; // ecx
wchar_t v17; // ax
wchar_t v18; // cx
int v19; // eax
bool v20; // zf
int v21; // edi
int v22; // [rsp+78h] [rbp+48h] BYREF
BOOL v23; // [rsp+80h] [rbp+50h] BYREF
wchar_t *EndPtr; // [rsp+88h] [rbp+58h] BYREF
v2 = (void **)sub_18013C6BC();
v3 = sub_18013C6C4();
v22 = 0;
v4 = (void **)v3;
v23 = 0;
if ( (unsigned int)sub_18013C72C(&v22) || (unsigned int)sub_18013C6CC(&v23) )
goto LABEL_41;
if ( !qword_1801F5650 )
goto LABEL_8;
v5 = Source;
do
{
v6 = *(wchar_t *)((char *)v5 + (_BYTE *)qword_1801F5650 - (_BYTE *)Source);
v7 = *v5 - v6;
if ( v7 )
break;
++v5;
}
while ( v6 );
if ( v7 )
{
LABEL_8:
v8 = -1;
v9 = -1;
do
++v9;
while ( Source[v9] );
v10 = malloc_base(2 * v9 + 2);
if ( !v10 )
{
LABEL_39:
free_base(v10);
return;
}
free_base(qword_1801F5650);
v11 = v10;
v10 = nullptr;
qword_1801F5650 = v11;
do
++v8;
while ( Source[v8] );
if ( !wcscpy_s((wchar_t *)v11, v8 + 1, Source) )
{
memset(*v4, 0, 0x80u);
memset(v4[1], 0, 0x80u);
memset(*v2, 0, 0x40u);
memset(v2[1], 0, 0x40u);
tzset_env_copy_to_tzname(Source, (wchar_t *const)*v4, (char *const)*v2, 3u);
v12 = 3;
do
{
if ( *Source )
++Source;
--v12;
}
while ( v12 );
v13 = *Source;
v14 = Source + 1;
if ( *Source != 45 )
v14 = Source;
v15 = 3600 * wcstol(v14, &EndPtr, 10);
v22 = v15;
while ( *v14 == 43 || (unsigned __int16)(*v14 - 48) <= 9u )
++v14;
if ( *v14 == 58 )
{
v16 = 60 * wcstol(++v14, &EndPtr, 10);
v17 = *v14;
v15 = v16 + v22;
v22 += v16;
if ( v17 >= 0x30u )
{
v18 = v17;
do
{
v17 = v18;
if ( v18 > 0x39u )
break;
v17 = *++v14;
v18 = *v14;
}
while ( *v14 >= 0x30u );
}
if ( v17 == 58 )
{
v19 = wcstol(++v14, &EndPtr, 10);
v15 = v19 + v22;
v22 += v19;
while ( *v14 >= 0x30u && *v14 <= 0x39u )
++v14;
}
}
if ( v13 == 45 )
{
v15 = -v15;
v22 = v15;
}
v20 = *v14 == 0;
v23 = *v14 != 0;
if ( !v20 )
{
tzset_env_copy_to_tzname(v14, (wchar_t *const)v4[1], (char *const)v2[1], 3u);
v15 = v22;
}
*sub_18013C6B4() = v15;
v21 = v23;
*sub_18013C6A4() = v21;
goto LABEL_39;
}
LABEL_41:
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
}