//
// OCSP_REQ_CTX_nbio from 0xe637ac to 0xe63d64 (1464 bytes)
//
// 2 xrefs:
// > OCSP_REQ_CTX_nbio_d2i @ 0xe63d84
// > ??> @ 0x39d50
//
// 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
//
__int64 __fastcall OCSP_REQ_CTX_nbio(__int64 a1)
{
int v1; // w2
unsigned int v3; // w20
int v4; // w0
int v5; // w0
__int64 v6; // x2
signed int v7; // w26
int v8; // w2
int v9; // w20
int v10; // w0
char *v11; // x2
int v12; // w0
char *v13; // x2
int v14; // w4
bool v15; // zf
int v16; // w0
_BYTE *v17; // x1
int v18; // w2
__int64 v20; // x0
int v21; // s8
int v22; // w0
const char *v23; // x27
int v24; // t1
char *v25; // x28
const char *v26; // x20
int v27; // w0
int v28; // w0
int v29; // t1
int v30; // w0
const char *v31; // x27
int v32; // t1
int v33; // t1
int v34; // w2
char *v35; // x0
__int64 v36; // x4
unsigned __int64 v37; // x1
__int64 v38; // x1
void *v39; // [xsp+70h] [xbp+70h] BYREF
char *v40; // [xsp+78h] [xbp+78h] BYREF
v1 = *(_DWORD *)a1;
LABEL_2:
v3 = v1 & 0x1000;
if ( (v1 & 0x1000) == 0 )
goto LABEL_16;
while ( 1 )
{
do
{
if ( v1 == 4101 )
goto LABEL_11;
if ( v1 > 4101 )
{
if ( v1 == 4103 )
goto LABEL_45;
if ( v1 >= 4103 )
{
if ( v1 == 4104 )
return 1;
if ( v1 != 4105 )
return 0;
if ( (unsigned int)BIO_write(*(_QWORD *)(a1 + 32), (__int64)&word_F203D8, 2u) != 2 )
goto LABEL_60;
*(_DWORD *)a1 = 4101;
LABEL_11:
*(_QWORD *)(a1 + 40) = BIO_ctrl(*(_QWORD *)(a1 + 32), 3u, 0, 0);
*(_DWORD *)a1 = 4102;
}
v4 = BIO_ctrl(*(_QWORD *)(a1 + 32), 3u, 0, (__int64)&v39);
v5 = BIO_write(*(_QWORD *)(a1 + 24), (__int64)v39 + v4 - *(_QWORD *)(a1 + 40), *(_QWORD *)(a1 + 40));
if ( v5 <= 0 )
goto LABEL_88;
v6 = *(_QWORD *)(a1 + 40) - v5;
*(_QWORD *)(a1 + 40) = v6;
if ( !v6 )
{
v20 = *(_QWORD *)(a1 + 32);
*(_DWORD *)a1 = 4103;
BIO_ctrl(v20, 1u, 0, 0);
LABEL_45:
if ( (int)BIO_ctrl(*(_QWORD *)(a1 + 24), 0xBu, 0, 0) <= 0 )
{
LABEL_88:
v3 = -1;
if ( !(unsigned int)BIO_test_flags(*(_QWORD *)(a1 + 24), 8u) )
{
LABEL_60:
v3 = 0;
*(_DWORD *)a1 = 4096;
return v3;
}
return v3;
}
*(_DWORD *)a1 = 1;
v1 = 1;
goto LABEL_2;
}
goto LABEL_14;
}
if ( v1 == 3 )
{
LABEL_36:
v16 = BIO_ctrl(*(_QWORD *)(a1 + 32), 3u, 0, (__int64)&v39);
if ( v16 > 1 )
{
v17 = v39;
v39 = (char *)v39 + 1;
if ( *v17 != 48 )
goto LABEL_60;
v18 = (unsigned __int8)v17[1];
if ( (v18 & 0x80) != 0 )
{
if ( v16 <= 5 )
goto LABEL_14;
v34 = v18 & 0x7F;
if ( (unsigned __int8)(v34 - 1) > 3u )
goto LABEL_60;
v35 = v17 + 3;
v36 = (__int64)&v17[v34 - 1 + 4];
v37 = 0;
do
{
v39 = v35++;
v38 = v37 << 8;
*(_QWORD *)(a1 + 40) = v38;
v37 = (unsigned __int8)*(v35 - 2) | (unsigned __int64)v38;
*(_QWORD *)(a1 + 40) = v37;
}
while ( v35 != (char *)v36 );
if ( *(_QWORD *)(a1 + 48) < v37 )
goto LABEL_60;
*(_QWORD *)(a1 + 40) = v37 + v34 + 2;
}
else
{
*(_QWORD *)(a1 + 40) = v18 + 2;
}
*(_DWORD *)a1 = 4;
goto LABEL_41;
}
LABEL_14:
v1 = *(_DWORD *)a1;
goto LABEL_15;
}
if ( v1 > 3 )
{
if ( v1 != 4 )
return 0;
LABEL_41:
if ( (int)BIO_ctrl(*(_QWORD *)(a1 + 32), 3u, 0, 0) >= (int)*(_QWORD *)(a1 + 40) )
{
v3 = 1;
*(_DWORD *)a1 = 4104;
return v3;
}
goto LABEL_14;
}
if ( v1 < 1 )
return 0;
while ( 1 )
{
LABEL_22:
v8 = BIO_ctrl(*(_QWORD *)(a1 + 32), 3u, 0, (__int64)&v39);
v9 = v8;
if ( v8 <= 0 || !memchr(v39, 10, v8) )
{
if ( *(_DWORD *)(a1 + 16) <= v9 )
goto LABEL_60;
v1 = *(_DWORD *)a1;
goto LABEL_15;
}
v10 = BIO_gets(*(_QWORD *)(a1 + 32), *(_QWORD *)(a1 + 8), *(_DWORD *)(a1 + 16));
if ( v10 <= 0 )
break;
if ( *(_DWORD *)(a1 + 16) == v10 )
goto LABEL_60;
if ( *(_DWORD *)a1 == 1 )
{
v26 = *(const char **)(a1 + 8);
v27 = *(unsigned __int8 *)v26;
if ( !*v26 )
{
LABEL_73:
v3 = 0;
ERR_put_error(39, 118, 115, (__int64)"crypto/ocsp/ocsp_ht.c", 215);
*(_DWORD *)a1 = 4096;
return v3;
}
while ( !isspace(v27) )
{
v33 = *(unsigned __int8 *)++v26;
v27 = v33;
if ( !v33 )
goto LABEL_73;
}
v28 = *(unsigned __int8 *)v26;
if ( !*v26 )
{
LABEL_75:
v3 = 0;
ERR_put_error(39, 118, 115, (__int64)"crypto/ocsp/ocsp_ht.c", 224);
*(_DWORD *)a1 = 4096;
return v3;
}
while ( isspace(v28) )
{
v29 = *(unsigned __int8 *)++v26;
v28 = v29;
if ( !v29 )
goto LABEL_75;
}
v30 = *(unsigned __int8 *)v26;
if ( !*v26 )
{
LABEL_71:
v3 = 0;
ERR_put_error(39, 118, 115, (__int64)"crypto/ocsp/ocsp_ht.c", 233);
*(_DWORD *)a1 = 4096;
return v3;
}
v31 = v26;
while ( !isspace(v30) )
{
v32 = *(unsigned __int8 *)++v31;
v30 = v32;
if ( !v32 )
goto LABEL_71;
}
*v31 = 0;
v21 = strtoul(v26, &v40, 10);
if ( *v40 )
goto LABEL_60;
v22 = *((unsigned __int8 *)v31 + 1);
v23 = v31 + 1;
if ( v22 )
{
while ( isspace(v22) )
{
v24 = *(unsigned __int8 *)++v23;
v22 = v24;
if ( !v24 )
goto LABEL_57;
}
v25 = (char *)&v23[strlen(v23) - 1];
v40 = v25;
while ( isspace((unsigned __int8)*v25) )
{
*v25 = 0;
v25 = --v40;
}
}
LABEL_57:
if ( v21 != 200 )
{
ERR_put_error(39, 118, 114, (__int64)"crypto/ocsp/ocsp_ht.c", 260);
if ( *v23 )
ERR_add_error_data(4, "Code=", v26, ",Reason=", v23);
else
ERR_add_error_data(2, "Code=", v26);
goto LABEL_60;
}
*(_DWORD *)a1 = 2;
}
else
{
v11 = *(char **)(a1 + 8);
v39 = v11;
v12 = (unsigned __int8)*v11;
if ( !*v11 )
goto LABEL_35;
if ( v12 == 10 || v12 == 13 )
{
v13 = v11 + 1;
while ( 1 )
{
v39 = v13++;
v14 = (unsigned __int8)*(v13 - 1);
v15 = v14 == 10;
if ( !*(v13 - 1) )
break;
while ( !v15 )
{
if ( v14 != 13 )
goto LABEL_22;
v39 = v13++;
v14 = (unsigned __int8)*(v13 - 1);
v15 = v14 == 10;
if ( !*(v13 - 1) )
goto LABEL_35;
}
}
LABEL_35:
*(_DWORD *)a1 = 3;
goto LABEL_36;
}
}
}
if ( !(unsigned int)BIO_test_flags(*(_QWORD *)(a1 + 32), 8u) )
goto LABEL_60;
v1 = *(_DWORD *)a1;
LABEL_15:
v3 = v1 & 0x1000;
}
while ( (v1 & 0x1000) != 0 );
LABEL_16:
v7 = BIO_read(*(_QWORD *)(a1 + 24), *(_QWORD *)(a1 + 8), *(_DWORD *)(a1 + 16));
if ( v7 <= 0 )
break;
if ( (unsigned int)BIO_write(*(_QWORD *)(a1 + 32), *(_QWORD *)(a1 + 8), v7) != v7 )
return v3;
v1 = *(_DWORD *)a1;
}
if ( (unsigned int)BIO_test_flags(*(_QWORD *)(a1 + 24), 8u) )
return (unsigned int)-1;
else
return 0;
}