//
// SMIME_crlf_copy from 0xadae34 to 0xadb040 (524 bytes)
//
// 4 xrefs:
// > i2d_ASN1_bio_stream @ 0xadb088
// > SMIME_write_ASN1 @ 0xadb4c8
// > SMIME_write_ASN1 @ 0xadb778
// > ??> @ 0x852dc
//
// 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:09:31 +0000
//
int __fastcall SMIME_crlf_copy(_DWORD *a1, int a2, int a3)
{
_BYTE *v3; // r5
void *v7; // r0
_DWORD *v8; // r0
_DWORD *v10; // r0
_DWORD *v11; // r6
int v12; // r7
int v13; // r0
int v14; // r4
_BYTE *v15; // r3
int v16; // r11
int v17; // r2
int v18; // t1
int v19; // r2
unsigned int v20; // r2
unsigned int v21; // t1
int i; // r10
int v23; // [sp+0h] [bp-414h]
_DWORD *v24; // [sp+4h] [bp-410h]
__int16 *v25; // [sp+Ch] [bp-408h]
_BYTE v26[1028]; // [sp+10h] [bp-404h] BYREF
v7 = BIO_f_buffer();
v8 = BIO_new((int)v7);
v24 = v8;
if ( !v8 )
return 0;
v10 = BIO_push(v8, a2);
if ( (a3 & 0x80) != 0 )
v3 = v26;
v11 = v10;
if ( (a3 & 0x80) == 0 )
{
if ( (a3 & 1) != 0 )
BIO_printf((int)v10, "Content-Type: text/plain\r\n\r\n");
v23 = a3 & 0x80000;
v12 = 0;
v25 = &word_BF5394;
while ( 1 )
{
while ( 1 )
{
LABEL_9:
v13 = BIO_gets(a1, (int)v26, 1024);
v14 = v13;
if ( v13 <= 0 )
goto LABEL_20;
v15 = &v26[v13];
if ( v23 )
break;
v16 = 0;
do
{
while ( 1 )
{
v18 = (unsigned __int8)*--v15;
v17 = v18;
if ( v18 != 10 )
break;
--v14;
v16 = 1;
if ( !v14 )
goto LABEL_16;
}
if ( v17 != 13 )
goto LABEL_31;
--v14;
}
while ( v14 );
LABEL_16:
if ( v16 )
BIO_write((int)v11, (int)v25, 2);
}
v16 = 0;
while ( 1 )
{
while ( 1 )
{
v21 = (unsigned __int8)*--v15;
v20 = v21;
if ( v21 != 10 )
break;
--v14;
v16 = 1;
if ( !v14 )
{
LABEL_35:
++v12;
goto LABEL_9;
}
}
if ( !v16 )
{
if ( v20 != 13 )
goto LABEL_26;
goto LABEL_34;
}
v16 = 1;
if ( v20 > 0x20 )
break;
LABEL_34:
if ( !--v14 )
goto LABEL_35;
}
v16 = 1;
LABEL_26:
if ( v12 )
{
for ( i = 0; i != v12; ++i )
BIO_write((int)v11, (int)&word_BF5394, 2);
}
v12 = 0;
LABEL_31:
BIO_write((int)v11, (int)v26, v14);
if ( v16 )
BIO_write((int)v11, (int)&word_BF5394, 2);
}
}
while ( 1 )
{
v19 = BIO_read((int)a1, (int)v3, 1024);
if ( v19 <= 0 )
break;
BIO_write((int)v11, (int)v3, v19);
}
LABEL_20:
BIO_ctrl(v11, 11, 0, 0);
BIO_pop(v11);
BIO_free(v24);
return 1;
}