//
// RAND_write_file from 0x82a264 to 0x82a350 (236 bytes)
//
// 1 xrefs:
// > ??> @ 0x660ac
//
// 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 RAND_write_file(const char *a1)
{
int v3; // r0
FILE *v4; // r4
int v5; // r6
signed int v6; // r7
_WORD v7[52]; // [sp+0h] [bp-46Ch] BYREF
_BYTE v8[1028]; // [sp+68h] [bp-404h] BYREF
if ( stat(a1, (struct stat *)v7) != -1 && (v7[8] & 0xB000) == 0x2000 )
return 1;
v3 = open(a1, 65, 384);
if ( v3 == -1 || (v4 = fdopen(v3, "wb")) == nullptr )
{
v4 = openssl_fopen(a1, "wb");
if ( !v4 )
return 0;
}
chmod(a1, 0x180u);
v5 = RAND_bytes((int)v8, 1024);
v6 = fwrite(v8, 1u, 0x400u, v4);
fclose(v4);
OPENSSL_cleanse(v8, 0x400u);
if ( v5 <= 0 )
return -1;
else
return v6 & ~(v6 >> 31);
}