//
// sub_614AFC from 0x614afc to 0x614d5e (610 bytes)
//
// 2 xrefs:
// > sub_616E88 @ 0x617f84
// > sub_63BAD8 @ 0x63c148
//
// 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_614AFC(_DWORD *a1, int a2, const char *a3)
{
int v3; // r7
const char *v5; // r10
_DWORD *v6; // r4
int v7; // r11
int i; // r3
int v9; // r2
bool v10; // zf
int v11; // t1
bool v12; // zf
int v13; // r2
int v14; // t1
int v16; // t1
int v17; // r2
const char *v18; // r2
int v19; // t1
int v20; // r1
int v21; // r2
char *v22; // r0
const char *v24; // [sp+4h] [bp-18h]
v3 = *a1;
v5 = a3;
if ( a2 )
{
v6 = (_DWORD *)(*a1 + 34808);
v7 = *a1 + 34584;
}
else
{
v6 = (_DWORD *)(*a1 + 34812);
v7 = *a1 + 34568;
}
i = *(unsigned __int8 *)a3;
while ( 1 )
{
if ( !i )
return 0;
if ( sub_62AC7C("NTLM", v5, 4) )
break;
if ( !sub_62AC7C("Digest", v5, 6) )
{
if ( sub_62AC7C("Basic", v5, 5) )
{
*v6 |= 1u;
v21 = *(_DWORD *)(v7 + 4);
*(_DWORD *)(v7 + 8) |= 1u;
if ( v21 == 1 )
{
*(_DWORD *)(v7 + 8) = 0;
sub_61807C(v3, "Authentication problem. Ignoring this.\n");
*(_BYTE *)(v3 + 34600) = 1;
i = *(unsigned __int8 *)v5;
goto LABEL_11;
}
}
goto LABEL_10;
}
if ( (*(_DWORD *)(v7 + 8) & 2) != 0 )
{
sub_61807C(v3, "Ignoring duplicate digest auth header.\n");
i = *(unsigned __int8 *)v5;
goto LABEL_11;
}
if ( sub_6402D0() )
{
*v6 |= 2u;
*(_DWORD *)(v7 + 8) |= 2u;
if ( sub_631E44(a1, a2, v5) )
goto LABEL_47;
}
LABEL_10:
for ( i = *(unsigned __int8 *)v5; ; i = v11 )
{
LABEL_11:
v12 = i == 44;
if ( i != 44 )
v12 = i == 0;
if ( v12 )
break;
v11 = *(unsigned __int8 *)++v5;
}
if ( i == 44 )
i = *(unsigned __int8 *)++v5;
LABEL_17:
if ( !i )
return 0;
v13 = ctype_ + i;
while ( (*(_BYTE *)(v13 + 1) & 8) != 0 )
{
v14 = *(unsigned __int8 *)++v5;
i = v14;
v13 = ctype_ + v14;
if ( !v14 )
return 0;
}
}
if ( (*(_DWORD *)(v7 + 8) & 0x28) == 0 && !sub_640FE8() )
goto LABEL_10;
*v6 |= 8u;
v9 = *(_DWORD *)(v7 + 4);
v10 = v9 == 8;
if ( v9 != 8 )
v10 = v9 == 32;
*(_DWORD *)(v7 + 8) |= 8u;
if ( !v10 )
goto LABEL_10;
if ( sub_63C460(a1, a2, v5) )
{
LABEL_47:
sub_61807C(v3, "Authentication problem. Ignoring this.\n");
*(_BYTE *)(v3 + 34600) = 1;
goto LABEL_10;
}
*(_BYTE *)(v3 + 34600) = 0;
if ( *(_DWORD *)(v7 + 4) != 32 )
goto LABEL_10;
*v6 &= ~8u;
*(_DWORD *)(v7 + 8) &= ~8u;
*v6 |= 0x20u;
*(_DWORD *)(v7 + 8) |= 0x20u;
if ( *v5 && (*(_BYTE *)(*(unsigned __int8 *)v5 + ctype_ + 1) & 8) != 0 )
{
do
{
v16 = *(unsigned __int8 *)++v5;
v17 = ctype_ + v16;
}
while ( v16 && (*(_BYTE *)(v17 + 1) & 8) != 0 );
}
if ( !sub_62AC7C("NTLM", v5, 4) )
goto LABEL_10;
v18 = v5 + 4;
if ( !v5[4] )
goto LABEL_40;
if ( (*(_BYTE *)(*((unsigned __int8 *)v5 + 4) + ctype_ + 1) & 8) != 0 )
{
while ( 1 )
{
v19 = *(unsigned __int8 *)++v18;
v20 = ctype_ + v19;
if ( !v19 )
break;
if ( (*(_BYTE *)(v20 + 1) & 8) == 0 )
goto LABEL_49;
}
LABEL_40:
v5 = v18;
i = 0;
goto LABEL_17;
}
LABEL_49:
v24 = v18;
v5 = v18;
v22 = off_ABAEB8(v18);
a1[203] = v22;
if ( v22 )
{
i = *(unsigned __int8 *)v24;
goto LABEL_11;
}
return 27;
}