//
// sub_800638 from 0x800638 to 0x80073c (260 bytes)
//
// 1 xrefs:
// > ??> @ 0xa31df4
//
// 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_800638(int a1, int a2, int a3, int a4)
{
unsigned int v7; // r4
char v8; // r3
int cipher_data; // r8
int v10; // r11
int v11; // r10
int v12; // r9
int v13; // r0
char v16[4]; // [sp+28h] [bp-Ch] BYREF
_BYTE v17[8]; // [sp+2Ch] [bp-8h] BYREF
if ( !EVP_CIPHER_CTX_test_flags(a1, 0x2000) )
a4 *= 8;
if ( a4 )
{
v7 = 0;
do
{
if ( (((int)*(unsigned __int8 *)(a3 + (v7 >> 3)) >> (~(_BYTE)v7 & 7)) & 1) != 0 )
v8 = 0x80;
else
v8 = 0;
v16[0] = v8;
cipher_data = EVP_CIPHER_CTX_get_cipher_data(a1);
v10 = EVP_CIPHER_CTX_get_cipher_data(a1);
v11 = EVP_CIPHER_CTX_get_cipher_data(a1);
v12 = EVP_CIPHER_CTX_iv_noconst(a1);
v13 = EVP_CIPHER_CTX_encrypting(a1);
DES_ede3_cfb_encrypt(v16, v17, 1, 1, cipher_data, v10 + 128, v11 + 256, v12, v13);
*(_BYTE *)(a2 + (v7 >> 3)) = *(_BYTE *)(a2 + (v7 >> 3)) & ~(128 >> (v7 & 7)) | ((v17[0] & 0x80) >> (v7 & 7));
++v7;
}
while ( v7 != a4 );
}
return 1;
}