//
// CRYPTO_ccm128_setiv from 0x810eb0 to 0x810f18 (104 bytes)
//
// 4 xrefs:
// > sub_7FD39C @ 0x7fd438
// > sub_7FD39C @ 0x7fd534
// > sub_7FD39C @ 0x7fd7d8
// > ??> @ 0x62c2c
//
// 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 CRYPTO_ccm128_setiv(char *a1, const void *a2, size_t a3, int a4)
{
char v4; // lr
size_t v5; // r12
v4 = *a1;
v5 = 14 - (*a1 & 7);
if ( v5 > a3 )
return -1;
*((_QWORD *)a1 + 1) = 0;
a1[15] = a4;
a1[12] = HIBYTE(a4);
a1[13] = BYTE2(a4);
a1[14] = BYTE1(a4);
*a1 = v4 & 0xBF;
memcpy(a1 + 1, a2, v5);
return 0;
}