//
// pqueue_insert from 0xd5e830 to 0xd5e8ec (188 bytes)
//
// 5 xrefs:
// > dtls1_buffer_record @ 0xd30654
// > sub_D4C920 @ 0xd4cbdc
// > dtls1_buffer_message @ 0xd4d3c4
// > dtls_get_message @ 0xd4dfd8
// > ??> @ 0xbe4d0
//
// 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
//
void *__fastcall pqueue_insert(_QWORD **a1, void *a2)
{
_QWORD *v2; // x19
_QWORD *v5; // x21
int v6; // w0
v2 = *a1;
v5 = nullptr;
if ( *a1 )
{
while ( 1 )
{
v6 = memcmp(v2, a2, 8u);
if ( v6 > 0 )
break;
if ( !v6 )
return nullptr;
v5 = v2;
if ( !v2[2] )
{
*((_QWORD *)a2 + 2) = 0;
v2[2] = a2;
return a2;
}
v2 = (_QWORD *)v2[2];
}
*((_QWORD *)a2 + 2) = v2;
if ( !v5 )
goto LABEL_11;
v5[2] = a2;
return a2;
}
else
{
LABEL_11:
*a1 = a2;
return a2;
}
}