//
// sub_6151CC from 0x6151cc to 0x6153b2 (486 bytes)
//
// 3 xrefs:
// > sub_6154B8 @ 0x61651a
// > sub_63AC60 @ 0x63b0e2
// > sub_63BAD8 @ 0x63bc9a
//
// 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_6151CC(int *a1, int a2, char **a3)
{
int v4; // r5
int v5; // r11
int i; // r8
const char **j; // r7
const char *v8; // r6
char *v9; // r0
int v10; // r3
char *v11; // r0
int v12; // t1
int v13; // r1
int result; // r0
char *v15; // r0
char *v16; // r2
int v17; // t1
int v18; // r1
int v19; // r3
_DWORD v21[3]; // [sp+20h] [bp-Ch]
v4 = *a1;
if ( a2 )
{
if ( *(_BYTE *)(v4 + 588) )
{
v5 = 1;
v21[0] = *(_DWORD *)(v4 + 580);
goto LABEL_4;
}
}
else if ( *((_BYTE *)a1 + 618) && !*((_BYTE *)a1 + 629) )
{
v5 = 1;
v19 = *(unsigned __int8 *)(v4 + 588);
v21[0] = *(_DWORD *)(v4 + 576);
if ( v19 )
{
v5 = 2;
v21[1] = *(_DWORD *)(v4 + 580);
}
goto LABEL_4;
}
v5 = 1;
v21[0] = *(_DWORD *)(v4 + 576);
LABEL_4:
for ( i = 0; i != v5; ++i )
{
for ( j = (const char **)v21[i]; j; j = (const char **)j[1] )
{
while ( 1 )
{
while ( 1 )
{
v8 = *j;
v9 = strchr(*j, 58);
if ( v9 )
break;
v15 = strchr(v8, 59);
if ( !v15 )
goto LABEL_12;
v16 = v15 + 1;
if ( v15[1] )
{
if ( (*(_BYTE *)((unsigned __int8)v15[1] + ctype_ + 1) & 8) == 0 )
goto LABEL_12;
while ( 1 )
{
v17 = (unsigned __int8)*++v16;
v18 = ctype_ + v17;
if ( !v17 )
break;
if ( (*(_BYTE *)(v18 + 1) & 8) == 0 )
goto LABEL_12;
}
}
if ( *(v16 - 1) != 59 )
goto LABEL_12;
*(v16 - 1) = 58;
result = sub_614F6C(a3, (int)"%s\r\n", *j);
if ( result )
return result;
j = (const char **)j[1];
if ( !j )
goto LABEL_13;
}
v10 = (unsigned __int8)v9[1];
v11 = v9 + 1;
if ( v10 )
break;
LABEL_12:
j = (const char **)j[1];
if ( !j )
goto LABEL_13;
}
if ( (*(_BYTE *)(v10 + ctype_ + 1) & 8) != 0 )
{
do
{
v12 = (unsigned __int8)*++v11;
v13 = ctype_ + v12;
if ( !v12 )
goto LABEL_12;
}
while ( (*(_BYTE *)(v13 + 1) & 8) != 0 );
}
if ( a1[177] )
{
if ( sub_62AC7C("Host:", v8, 5) )
goto LABEL_12;
v8 = *j;
}
if ( *(_DWORD *)(v4 + 636) == 3 )
{
if ( sub_62AC7C("Content-Type:", v8, 13) )
goto LABEL_12;
v8 = *j;
}
if ( *((_BYTE *)a1 + 630) )
{
if ( sub_62AC7C("Content-Length", v8, 14) )
goto LABEL_12;
v8 = *j;
}
if ( a1[180] )
{
if ( sub_62AC7C("Connection", v8, 10) )
goto LABEL_12;
v8 = *j;
}
if ( a1[98] == 20 )
{
if ( !sub_62AC7C("Transfer-Encoding:", v8, 18) )
{
v8 = *j;
goto LABEL_25;
}
goto LABEL_12;
}
LABEL_25:
result = sub_614F6C(a3, (int)"%s\r\n", v8);
if ( result )
return result;
}
LABEL_13:
;
}
return 0;
}