请仔细阅读和分析下面函数,进行优化后,采用C/C++11标准,完整推导并重构可编译的全部代码
要求如下:
1.保持原始函数定义不变,不要拆分函数
2.保持所有原始逻辑功能不变
3.结构体采用32位定义
4.严格保持protobuf字段映射关系
5.提高执行效率,降低计算复杂度
6.已经给定的结构体名字和元素不要更改,详细的中文注释
7.自动添加中文注释说明功能逻辑
8.不使用 auto,使用显式 for 循环
特别注意:
1.函数中的 HDDMXng::BelDef::BelDef 映射为
message BelDef
{
optional bool optinv = 1;
optional bool rbel = 2;
optional string belname = 3;
optional uint32 numoutputpins = 4;
optional uint32 numinputpins = 5;
optional uint32 numpins = 6;
optional uint32 numsrcs = 7;
optional uint32 numprims = 8;
repeated uint32 srcgnds = 9 [packed = true];
repeated BelDefPip pips = 10;
optional bool hasusagedef = 11;
}
其中,依赖消息有:
message AttrSetting
{
optional string attrname = 1;
optional string attrvalue = 2;
}
message BelDefPip
{
optional uint32 pin1 = 1;
optional uint32 pin2 = 2;
repeated AttrSetting attrsettings = 3;
}
2.将函数中 _BYTE beldef_msg[16] 映射为 HDDMXng::BelDef beldef_msg
void __fastcall HDDMBelDef::HDDMBelDef(HDDMBelDef *this)
{
int v1; // eax
unsigned int v2; // eax
this->beldef_code &= 0xC000u;
this->beldef_code1 &= 0xF0u;
*(_DWORD *)&this->char40 = 0;
this->qword48 = 0;
this->qword60 = 0;
this->hddmPrimitive = 0;
this->qword0 = qword0;
v1 = *(_DWORD *)&this->beldef_code;
this->qword30 = 0;
this->qword20 = 0;
this->hddmBelPinDefArray = 0;
this->hddmBelUsageDef = 0;
v1 &= 0xF0003FFF;
*(_DWORD *)&this->beldef_code = v1;
this->? = HIBYTE(v1) & 0xCF;
v2 = *(_DWORD *)&this->beldef_code1 & 0xFFFC000F;
*(_DWORD *)&this->beldef_code1 = v2;
this->? = HIWORD(v2) | 0x3FFC;
this->belDef_name = (char *)&std::string::_Rep::_S_empty_rep_storage + 24;
this->qword50 = &this->char40;
this->qword58 = &this->char40;
}
void __fastcall HDDMBelDef::~HDDMBelDef(HDDMBelDef *this)
{
HDDMPrimitive *hddmPrimitive; // rbp
_QWORD *vtable; // rbx
_QWORD *vtable_2; // rax
void *vtable_1; // rdi
_QWORD *qword20; // rsi
unsigned __int16 v7; // ax
__int64 v8; // rbx
void *v9; // rdi
HDDMBelPinDef *hddmBelPinDefArray_1; // rdi
HDDMBelPinDef *hddmBelPinDefArray_3; // rbx
HDDMBelPinDef *v12; // rbx
HDDMBelPinDef *v13; // rdi
HDDMBelPinDef *hddmBelPinDefArray_2; // rbp
_QWORD *qword30; // rbx
HDDMBelUsageDef *hddmBelUsageDef; // rbx
HDDMBelDef *i; // r14
HDDMBelPinDef *hddmBelPinDefArray; // r13
char *pindef_name; // r8
char *v20; // r15
char *pindef_name_4; // rbx
_QWORD *v22; // r9
__int64 v23; // rdx
void *p__ZNSs4_Rep20_S_empty_rep_storageE; // rdi
void *pindef_name_1; // rdi
__int64 v26; // rdx
__int64 v27; // rdx
void *p__ZNSs4_Rep20_S_empty_rep_storageE_1; // rdi
int v29; // ecx
int v30; // ecx
char *pindef_name_3; // [rsp+10h] [rbp-58h]
char *pindef_name_2; // [rsp+10h] [rbp-58h]
char *pindef_name_5; // [rsp+10h] [rbp-58h]
char *pindef_name_6; // [rsp+10h] [rbp-58h]
_QWORD *v35; // [rsp+18h] [rbp-50h]
_QWORD *v36; // [rsp+18h] [rbp-50h]
_QWORD *v37; // [rsp+18h] [rbp-50h]
_QWORD *v38; // [rsp+18h] [rbp-50h]
_BYTE v39[57]; // [rsp+2Fh] [rbp-39h] BYREF
hddmPrimitive = this->hddmPrimitive;
this->qword0 = qword0;
if ( hddmPrimitive )
{
vtable = (_QWORD *)hddmPrimitive->vtable;
vtable_2 = *(_QWORD **)&hddmPrimitive->numPrimType;
if ( (_QWORD *)hddmPrimitive->vtable == vtable_2 )
{
vtable_1 = (void *)hddmPrimitive->vtable;
}
else
{
do
{
if ( *vtable )
{
(*(void (__fastcall **)(_QWORD))(*(_QWORD *)*vtable + 24LL))(*vtable);
hddmPrimitive = this->hddmPrimitive;
vtable_2 = *(_QWORD **)&hddmPrimitive->numPrimType;
}
++vtable;
}
while ( vtable != vtable_2 );
vtable_1 = (void *)hddmPrimitive->vtable;
}
if ( vtable_1 )
operator delete(vtable_1);
operator delete(hddmPrimitive);
this->hddmPrimitive = 0;
}
qword20 = (_QWORD *)this->qword20;
if ( qword20 )
{
v7 = (this->beldef_code >> 14) & 0x3FFF;
if ( !v7 )
goto LABEL_17;
v8 = 0;
do
{
v9 = (void *)qword20[v8];
if ( v9 )
{
operator delete[](v9);
*(_QWORD *)(this->qword20 + 8 * v8) = 0;
qword20 = (_QWORD *)this->qword20;
v7 = (this->beldef_code >> 14) & 0x3FFF;
}
++v8;
}
while ( v7 > (int)v8 );
if ( qword20 )
LABEL_17:
operator delete[](qword20);
this->qword20 = 0;
}
if ( this->qword60 )
{
for ( i = (HDDMBelDef *)this->qword50; i != (HDDMBelDef *)&this->char40; i = (HDDMBelDef *)std::_Rb_tree_increment(i) )
{
hddmBelPinDefArray = i->hddmBelPinDefArray;
if ( hddmBelPinDefArray )
{
pindef_name = (char *)hddmBelPinDefArray->pindef_name;
v20 = *(char **)&hddmBelPinDefArray->pindef_code;
if ( pindef_name == *(char **)&hddmBelPinDefArray->pindef_code )
{
pindef_name_1 = (void *)hddmBelPinDefArray->pindef_name;
}
else
{
pindef_name_4 = *(char **)&hddmBelPinDefArray->pindef_code;
v22 = v20 + 8;
if ( &_pthread_key_create )
{
do
{
v23 = *(_QWORD *)((char *)v22 + pindef_name_4 - v20);
if ( (_UNKNOWN *)(v23 - 24) != &std::string::_Rep::_S_empty_rep_storage
&& _InterlockedExchangeAdd((volatile signed __int32 *)(v23 - 8), 0xFFFFFFFF) <= 0 )
{
v36 = v22;
pindef_name_2 = pindef_name;
std::string::_Rep::_M_destroy(v23 - 24, v39);
v22 = v36;
pindef_name = pindef_name_2;
}
p__ZNSs4_Rep20_S_empty_rep_storageE = (void *)(*(_QWORD *)pindef_name_4 - 24LL);
if ( p__ZNSs4_Rep20_S_empty_rep_storageE != &std::string::_Rep::_S_empty_rep_storage
&& _InterlockedExchangeAdd((volatile signed __int32 *)(*(_QWORD *)pindef_name_4 - 8LL), 0xFFFFFFFF) <= 0 )
{
v35 = v22;
pindef_name_3 = pindef_name;
std::string::_Rep::_M_destroy(p__ZNSs4_Rep20_S_empty_rep_storageE, v39);
v22 = v35;
pindef_name = pindef_name_3;
}
pindef_name_4 += 16;
}
while ( pindef_name != pindef_name_4 );
}
else
{
do
{
v26 = *(_QWORD *)((char *)v22 + pindef_name_4 - v20);
if ( (_UNKNOWN *)(v26 - 24) != &std::string::_Rep::_S_empty_rep_storage )
{
v29 = *(_DWORD *)(v26 - 8);
*(_DWORD *)(v26 - 8) = v29 - 1;
if ( v29 <= 0 )
{
v37 = v22;
pindef_name_5 = pindef_name;
std::string::_Rep::_M_destroy(v26 - 24, v39);
v22 = v37;
pindef_name = pindef_name_5;
}
}
v27 = *(_QWORD *)pindef_name_4;
p__ZNSs4_Rep20_S_empty_rep_storageE_1 = (void *)(*(_QWORD *)pindef_name_4 - 24LL);
if ( p__ZNSs4_Rep20_S_empty_rep_storageE_1 != &std::string::_Rep::_S_empty_rep_storage )
{
v30 = *(_DWORD *)(v27 - 8);
*(_DWORD *)(v27 - 8) = v30 - 1;
if ( v30 <= 0 )
{
v38 = v22;
pindef_name_6 = pindef_name;
std::string::_Rep::_M_destroy(p__ZNSs4_Rep20_S_empty_rep_storageE_1, v39);
v22 = v38;
pindef_name = pindef_name_6;
}
}
pindef_name_4 += 16;
}
while ( pindef_name != pindef_name_4 );
}
pindef_name_1 = *(void **)&hddmBelPinDefArray->pindef_code;
}
if ( pindef_name_1 )
operator delete(pindef_name_1);
operator delete(hddmBelPinDefArray);
}
}
}
hddmBelPinDefArray_1 = this->hddmBelPinDefArray;
if ( hddmBelPinDefArray_1 )
{
hddmBelPinDefArray_3 = &hddmBelPinDefArray_1[hddmBelPinDefArray_1[-1].pindef_name];
if ( hddmBelPinDefArray_1 != hddmBelPinDefArray_3 )
{
v12 = hddmBelPinDefArray_3 - 1;
do
{
v13 = v12;
hddmBelPinDefArray_2 = v12--;
HDDMBelPinDef::~HDDMBelPinDef(v13);
hddmBelPinDefArray_1 = this->hddmBelPinDefArray;
}
while ( hddmBelPinDefArray_1 != hddmBelPinDefArray_2 );
}
operator delete[](&hddmBelPinDefArray_1[-1].pindef_name);
this->hddmBelPinDefArray = 0;
}
qword30 = (_QWORD *)this->qword30;
if ( qword30 )
{
std::_Rb_tree<std::string,std::pair<std::string const,HDDMBelPinDef *>,std::_Select1st<std::pair<std::string const,HDDMBelPinDef *>>,std::less<std::string>,std::allocator<std::pair<std::string const,HDDMBelPinDef *>>>::_M_erase(
this->qword30,
qword30[2]);
operator delete(qword30);
this->qword30 = 0;
}
hddmBelUsageDef = this->hddmBelUsageDef;
if ( hddmBelUsageDef )
{
HDDMBelUsageDef::~HDDMBelUsageDef(this->hddmBelUsageDef);
operator delete(hddmBelUsageDef);
}
this->hddmBelUsageDef = 0;
sub_21726B0(this);
std::_Rb_tree<std::pair<unsigned short,unsigned short>,std::pair<std::pair<unsigned short,unsigned short> const,std::vector<std::pair<std::string,std::string>> *>,std::_Select1st<std::pair<std::pair<unsigned short,unsigned short> const,std::vector<std::pair<std::string,std::string>> *>>,std::less<std::pair<unsigned short,unsigned short>>,std::allocator<std::pair<std::pair<unsigned short,unsigned short> const,std::vector<std::pair<std::string,std::string>> *>>>::_M_erase(
&this->field_38,
this->qword48);
std::string::_Rep::_M_dispose((char *)this->belDef_name - 24, v39);
}
void __fastcall HDDMBelDef::readme_pb(HDDMBelDef *this, std::istream *stream, HDDMDevice *hddmDevice)
{
google::protobuf::Message *v3; // rdx
char **p_belDef_name; // rbx
char byteB; // al
bool v6; // zf
unsigned __int16 v7; // r14
_QWORD *v8; // rax
__int64 v9; // rbx
HDDMBelPinDef *hddmBelPinDefArray; // r12
HDDMBelPinDef *v11; // rbp
__int64 index; // rbx
HDDMBelPinDef *hddmBelPinDef; // r12
int v14; // r13d
unsigned __int16 v15; // ax
int v16; // ebx
int v17; // ebp
__int64 qword20_1; // rax
__int64 qword20; // r12
__int64 v20; // r13
__int64 v21; // rbx
__int64 v22; // rax
__int64 v23; // r12
int v24; // ebp
unsigned __int64 v25; // rbx
_QWORD *v26; // r13
_QWORD *v27; // rax
int v28; // ebp
__int64 qword48; // rdx
char *p_char40_1; // rbx
__int64 insert_hint_unique_pos; // rax
__int64 p_char40_3; // rdx
__int64 v33; // rdi
unsigned __int64 v34; // rbx
__int64 v35; // rbp
__int64 v36; // rdi
__int64 v37; // rdi
__int64 v38; // rax
const std::string *v39; // rbp
unsigned __int16 v40; // ax
_QWORD *qword18_1; // rbx
unsigned __int64 n; // rbp
char *s; // rax
unsigned __int64 v44; // rbx
const char *v45; // rcx
__int64 v46; // rbp
void (__fastcall **v47)(__int64, std::istream *, HDDMDevice *); // rax
_QWORD *qword18; // rax
int v49; // eax
int v50; // eax
std::string *belDef_name; // rax
std::string *qword10_1; // rsi
std::string *qword10_2; // rdx
const char *OPTFF; // rcx
std::string *qword10_3; // rax
char v56; // di
std::string *qword10_4; // rdx
char *v58; // rcx
std::string *qword10_5; // rax
char v60; // di
int v61; // edx
int v62; // edx
__int64 v64; // [rsp+8h] [rbp-140h]
int v65; // [rsp+14h] [rbp-134h]
int v66; // [rsp+18h] [rbp-130h]
char *insert_hint_unique_pos_1; // [rsp+18h] [rbp-130h]
char *p_char40_2; // [rsp+30h] [rbp-118h]
char *p_char40; // [rsp+38h] [rbp-110h]
char v72; // [rsp+5Fh] [rbp-E9h] BYREF
char v73[8]; // [rsp+60h] [rbp-E8h] BYREF
__int64 v74; // [rsp+68h] [rbp-E0h] BYREF
_BYTE beldef_msg[16]; // [rsp+70h] [rbp-D8h] BYREF
std::string *v76; // [rsp+80h] [rbp-C8h]
__int16 v77; // [rsp+88h] [rbp-C0h]
char v78; // [rsp+8Ch] [rbp-BCh]
char v79; // [rsp+8Dh] [rbp-BBh]
char v80; // [rsp+8Eh] [rbp-BAh]
__int16 v81; // [rsp+90h] [rbp-B8h]
__int16 v82; // [rsp+94h] [rbp-B4h]
int v83; // [rsp+9Ch] [rbp-ACh]
__int64 v84; // [rsp+C8h] [rbp-80h]
int v85; // [rsp+D0h] [rbp-78h]
char v86; // [rsp+104h] [rbp-44h]
if ( HDDMDeviceDump::useXngMarks )
std::istream::read(stream, HDDMDeviceDump::markBuffer, 6);
HDDMXng::BelDef::BelDef((HDDMXng::BelDef *)beldef_msg);
HDDMDevice::readMessage((HDDMDevice *)stream, (std::istream *)beldef_msg, v3);
p_belDef_name = (char **)&this->belDef_name;
byteB = (16 * (v78 & 1)) | HIBYTE(this->beldef_code) & 0xEF;
HIBYTE(this->beldef_code) = byteB;
HIBYTE(this->beldef_code) = (32 * (v79 & 1)) | byteB & 0xDF;
std::string::assign((std::string *)&this->belDef_name, v76);
if ( (this->beldef_code & 0x30000000) != 0 )
goto LABEL_4;
if ( sub_21655B0(p_belDef_name, "IDDR") || sub_21655B0(p_belDef_name, "IPFF") || sub_21655B0(p_belDef_name, "OPFF") )
goto LABEL_67;
belDef_name = this->belDef_name;
qword10_1 = (std::string *)((char *)belDef_name + *((_QWORD *)belDef_name - 3));
if ( belDef_name == qword10_1 )
goto LABEL_4;
if ( *(_BYTE *)belDef_name == 79 )
{
qword10_2 = (std::string *)((char *)belDef_name + 1);
OPTFF = "OPTFF";
qword10_3 = (std::string *)((char *)belDef_name + 5);
while ( 1 )
{
++OPTFF;
if ( qword10_2 == qword10_1 )
break;
if ( qword10_2 == qword10_3 )
goto LABEL_67;
v56 = *(_BYTE *)qword10_2;
qword10_2 = (std::string *)((char *)qword10_2 + 1);
if ( v56 != *OPTFF )
goto LABEL_4;
}
if ( OPTFF != "" )
goto LABEL_4;
LABEL_67:
HIBYTE(this->beldef_code) |= 0x10u;
goto LABEL_4;
}
if ( *(_BYTE *)belDef_name == 84 )
{
qword10_4 = (std::string *)((char *)belDef_name + 1);
v58 = "TFF";
qword10_5 = (std::string *)((char *)belDef_name + 3);
while ( 1 )
{
++v58;
if ( qword10_4 == qword10_1 )
break;
if ( qword10_4 == qword10_5 )
goto LABEL_67;
v60 = *(_BYTE *)qword10_4;
qword10_4 = (std::string *)((char *)qword10_4 + 1);
if ( v60 != *v58 )
goto LABEL_4;
}
if ( v58 == "" )
goto LABEL_67;
}
LABEL_4:
this->beldef_code = ((v81 & 0x3FFF) << 14) | this->beldef_code & 0xF0003FFF;
this->beldef_code1 = (16 * (v77 & 0x3FFF)) | this->beldef_code1 & 0xFFFC000F;
v6 = HDDMDeviceDump::useXngMarks == 0;
LOWORD(this->beldef_code) = v82 & 0x3FFF | this->beldef_code & 0xC000;
if ( !v6 )
std::istream::read(stream, HDDMDeviceDump::markBuffer, 4);
v7 = this->beldef_code & 0x3FFF;
if ( v7 )
{
v8 = (_QWORD *)operator new[](16LL * v7 + 8);
v9 = v7 - 1LL;
hddmBelPinDefArray = (HDDMBelPinDef *)(v8 + 1);
*v8 = v7;
v11 = (HDDMBelPinDef *)(v8 + 1);
do
{
HDDMBelPinDef::HDDMBelPinDef(v11);
--v9;
++v11;
}
while ( v9 != -1 );
index = 0;
v6 = (this->beldef_code & 0x3FFF) == 0;
this->hddmBelPinDefArray = hddmBelPinDefArray;
if ( !v6 )
{
while ( 1 )
{
hddmBelPinDef = &hddmBelPinDefArray[index];
HDDMBelPinDef::readme_pb(hddmBelPinDef, stream, hddmDevice);
LOWORD(hddmBelPinDef->pindef_code1) = (16 * (HIWORD(this->beldef_code1) >> 2))
| hddmBelPinDef->pindef_code1 & 0xF;
hddmBelPinDef->pindef_code = ((index++ & 0x3FFF) << 6) | hddmBelPinDef->pindef_code & 0xFFF0003F;
if ( (this->beldef_code & 0x3FFF) <= (int)index )
break;
hddmBelPinDefArray = this->hddmBelPinDefArray;
}
}
HDDMBelDef::createpindefsmap(this);
}
if ( HDDMDeviceDump::useXngMarks )
std::istream::read(stream, HDDMDeviceDump::markBuffer, 5);
if ( v86 < 0 )
{
v14 = v83;
if ( v83 )
{
qword18_1 = (_QWORD *)operator new(0x18u);
*qword18_1 = 0;
qword18_1[1] = 0;
qword18_1[2] = 0;
if ( (unsigned __int64)v14 > 0x1FFFFFFFFFFFFFFFLL )
std::__throw_bad_alloc();
n = 8LL * v14;
s = (char *)operator new(n);
*qword18_1 = s;
qword18_1[1] = s;
qword18_1[2] = &s[n];
memset(s, 0, n);
qword18_1[1] = qword18_1[2];
this->qword18 = qword18_1;
if ( v14 > 0 )
{
v44 = 0;
do
{
std::istream::read(stream, v73, 2);
HDDMDeviceDump::dumpbinary((HDDMDeviceDump *)v73, (const char *)&dword_0 + 2, (int)"beldef:", v45);
v46 = HDDMPrimitive::create(*(unsigned __int16 *)v73);
v47 = *(void (__fastcall ***)(__int64, std::istream *, HDDMDevice *))v46;
*(_QWORD *)(v46 + 16) = this;
(*v47)(v46, stream, hddmDevice);
qword18 = (_QWORD *)this->qword18;
if ( v44 >= (__int64)(qword18[1] - *qword18) >> 3 )
std::__throw_out_of_range("vector::_M_range_check");
*(_QWORD *)(*qword18 + 8 * v44++) = v46;
}
while ( v14 > (int)v44 );
}
}
}
if ( v85 )
{
v15 = (this->beldef_code & 0x3FFF) - (((this->beldef_code >> 14) & 0x3FFF) + ((this->beldef_code1 >> 4) & 0x3FFF));
v16 = ((this->beldef_code >> 14) & 0x3FFF) + v15;
v17 = v15 + ((this->beldef_code1 >> 4) & 0x3FFF);
qword20_1 = operator new[](8LL * v16);
this->qword20 = qword20_1;
if ( v16 )
{
qword20 = qword20_1;
v20 = 8LL * (unsigned int)(v16 - 1) + 8;
v21 = 0;
while ( 1 )
{
*(_QWORD *)(v21 + qword20) = operator new[](v17);
v22 = 0;
if ( v17 )
{
do
*(_BYTE *)(*(_QWORD *)(this->qword20 + v21) + v22++) = 0;
while ( v17 > (int)v22 );
}
v21 += 8;
if ( v21 == v20 )
break;
qword20 = this->qword20;
}
}
if ( v85 > 0 )
{
v64 = 0;
v65 = 0;
p_char40_2 = (char *)&this->char40;
do
{
v23 = *(_QWORD *)(v84 + v64);
v24 = *(_DWORD *)(v23 + 20);
v66 = *(_DWORD *)(v23 + 16);
*(_BYTE *)(*(_QWORD *)(this->qword20 + 8LL * v66) + v24) = 1;
v25 = *(int *)(v23 + 32);
if ( (_DWORD)v25 )
{
v26 = (_QWORD *)operator new(0x18u);
*v26 = 0;
v26[1] = 0;
v26[2] = 0;
if ( v25 > 0xFFFFFFFFFFFFFFFLL )
std::__throw_bad_alloc();
v27 = (_QWORD *)operator new(16 * v25);
*v26 = v27;
v26[1] = v27;
v26[2] = &v27[2 * v25];
do
{
if ( v27 )
{
*v27 = (char *)&std::string::_Rep::_S_empty_rep_storage + 24;
v27[1] = (char *)&std::string::_Rep::_S_empty_rep_storage + 24;
}
v27 += 2;
--v25;
}
while ( v25 );
v26[1] = v26[2];
v28 = ((this->beldef_code >> 14) & 0x3FFF)
+ (unsigned __int16)((this->beldef_code & 0x3FFF)
- (((this->beldef_code1 >> 4) & 0x3FFF)
+ ((this->beldef_code >> 14) & 0x3FFF)))
+ v24;
qword48 = this->qword48;
p_char40_1 = (char *)&this->char40;
if ( !qword48 )
goto LABEL_45;
do
{
while ( (unsigned __int16)v66 <= *(_WORD *)(qword48 + 32)
&& ((unsigned __int16)v66 < *(_WORD *)(qword48 + 32)
|| (unsigned __int16)v28 <= *(_WORD *)(qword48 + 34)) )
{
p_char40_1 = (char *)qword48;
qword48 = *(_QWORD *)(qword48 + 16);
if ( !qword48 )
goto LABEL_41;
}
qword48 = *(_QWORD *)(qword48 + 24);
}
while ( qword48 );
LABEL_41:
if ( p_char40_2 == p_char40_1
|| (unsigned __int16)v66 < *((_WORD *)p_char40_1 + 16)
|| (unsigned __int16)v66 <= *((_WORD *)p_char40_1 + 16)
&& (unsigned __int16)v28 < *((_WORD *)p_char40_1 + 17) )
{
LABEL_45:
p_char40 = p_char40_1;
p_char40_1 = (char *)operator new(0x30u);
if ( p_char40_1 )
{
*(_DWORD *)p_char40_1 = 0;
*((_QWORD *)p_char40_1 + 1) = 0;
*((_QWORD *)p_char40_1 + 2) = 0;
*((_QWORD *)p_char40_1 + 3) = 0;
*((_WORD *)p_char40_1 + 17) = v28;
*((_QWORD *)p_char40_1 + 5) = 0;
*((_WORD *)p_char40_1 + 16) = v66;
}
insert_hint_unique_pos = std::_Rb_tree<std::pair<unsigned short,unsigned short>,std::pair<std::pair<unsigned short,unsigned short> const,std::vector<std::pair<std::string,std::string>> *>,std::_Select1st<std::pair<std::pair<unsigned short,unsigned short> const,std::vector<std::pair<std::string,std::string>> *>>,std::less<std::pair<unsigned short,unsigned short>>,std::allocator<std::pair<std::pair<unsigned short,unsigned short> const,std::vector<std::pair<std::string,std::string>> *>>>::_M_get_insert_hint_unique_pos(
&this->field_38,
p_char40,
p_char40_1 + 32);
if ( p_char40_3 )
{
v33 = 1;
if ( !insert_hint_unique_pos && p_char40_2 != (char *)p_char40_3 )
{
v40 = *(_WORD *)(p_char40_3 + 32);
if ( *((_WORD *)p_char40_1 + 16) >= v40
&& (*((_WORD *)p_char40_1 + 16) > v40 || *((_WORD *)p_char40_1 + 17) >= *(_WORD *)(p_char40_3 + 34)) )
{
v33 = 0;
}
}
std::_Rb_tree_insert_and_rebalance(v33, p_char40_1, p_char40_3, p_char40_2);
++this->qword60;
}
else
{
insert_hint_unique_pos_1 = (char *)insert_hint_unique_pos;
operator delete(p_char40_1);
p_char40_1 = insert_hint_unique_pos_1;
}
}
*((_QWORD *)p_char40_1 + 5) = v26;
if ( *(int *)(v23 + 32) > 0 )
{
v34 = 0;
do
{
v38 = *(_QWORD *)(*(_QWORD *)(v23 + 24) + 8 * v34);
v39 = *(const std::string **)(v38 + 24);
std::string::string((std::string *)v73, *(const std::string **)(v38 + 16));
std::string::string((std::string *)&v74, v39);
if ( v34 >= (__int64)(v26[1] - *v26) >> 4 )
std::__throw_out_of_range("vector::_M_range_check");
v35 = *v26 + 16 * v34;
std::string::swap((std::string *)v35, (std::string *)v73);
std::string::swap((std::string *)(v35 + 8), (std::string *)&v74);
v36 = v74 - 24;
if ( (_UNKNOWN *)(v74 - 24) != &std::string::_Rep::_S_empty_rep_storage )
{
if ( &_pthread_key_create )
{
v50 = _InterlockedExchangeAdd((volatile signed __int32 *)(v74 - 8), 0xFFFFFFFF);
}
else
{
v61 = *(_DWORD *)(v74 - 8);
*(_DWORD *)(v74 - 8) = v61 - 1;
v50 = v61;
}
if ( v50 <= 0 )
std::string::_Rep::_M_destroy(v36, &v72);
}
v37 = *(_QWORD *)v73 - 24LL;
if ( (_UNKNOWN *)(*(_QWORD *)v73 - 24LL) != &std::string::_Rep::_S_empty_rep_storage )
{
if ( &_pthread_key_create )
{
v49 = _InterlockedExchangeAdd((volatile signed __int32 *)(*(_QWORD *)v73 - 8LL), 0xFFFFFFFF);
}
else
{
v62 = *(_DWORD *)(*(_QWORD *)v73 - 8LL);
*(_DWORD *)(*(_QWORD *)v73 - 8LL) = v62 - 1;
v49 = v62;
}
if ( v49 <= 0 )
std::string::_Rep::_M_destroy(v37, &v72);
}
++v34;
}
while ( *(_DWORD *)(v23 + 32) > (int)v34 );
}
}
++v65;
v64 += 8;
}
while ( v65 < v85 );
}
}
if ( v80 )
{
HDDMBelDef::addusagedef(this);
HDDMBelUsageDef::readme_pb(this->hddmBelUsageDef, stream, hddmDevice);
HDDMBelUsageDef::setrecursivebelid(this->hddmBelUsageDef, (HIWORD(this->beldef_code1) >> 2) & 0xFFF);
}
HDDMXng::BelDef::~BelDef((HDDMXng::BelDef *)beldef_msg);
}
void __fastcall HDDMBelDef::writeme_pb(HDDMBelDef *this, std::ostream *stream)
{
char beldef_code_high; // dl
int v3; // eax
std::string *p__ZN6google8protobuf8internal12kEmptyStringE_3; // rdi
HDDMBelDef *HDDMBelDef_1; // rax
unsigned int beldef_code; // ecx
unsigned int beldef_code1; // edx
__int16 beldef_code_1; // ax
int v9; // eax
__int64 v10; // rdx
int v11; // eax
_DWORD *v12; // rbp
__int64 v13; // rax
int v14; // eax
unsigned __int16 v15; // cx
__int64 qword48; // rax
_QWORD *p_char40; // rdx
__int64 *v18; // r12
unsigned __int64 v19; // r14
unsigned __int64 i; // r13
__int64 v21; // rbx
__int64 v22; // rax
__int64 v23; // rdx
__int64 v24; // r15
std::string *p__ZN6google8protobuf8internal12kEmptyStringE_1; // rdi
const std::string *v26; // r15
__int64 v27; // rdx
std::string *p__ZN6google8protobuf8internal12kEmptyStringE_2; // rdi
const std::string *v29; // r13
__int64 v30; // rax
__int64 v31; // rdx
int v32; // esi
HDDMBelDef *HDDMBelDef_2; // rax
const google::protobuf::Message *qword18; // rdx
__int64 v35; // rax
__int64 v36; // rbx
__int64 *qword18_1; // rdx
__int64 v38; // rax
__int64 v39; // rdx
__int64 v40; // rbx
__int64 v41; // r13
_DWORD *v42; // rbp
const char *v43; // rcx
HDDMBelUsageDef *hddmBelUsageDef; // rdi
__int64 v45; // [rsp+8h] [rbp-140h]
int v47; // [rsp+2Ch] [rbp-11Ch]
__int64 v48; // [rsp+38h] [rbp-110h]
int v49; // [rsp+44h] [rbp-104h]
char v51[16]; // [rsp+60h] [rbp-E8h] BYREF
_BYTE v52[16]; // [rsp+70h] [rbp-D8h] BYREF
std::string *p__ZN6google8protobuf8internal12kEmptyStringE; // [rsp+80h] [rbp-C8h]
int v54; // [rsp+88h] [rbp-C0h]
char v55; // [rsp+8Ch] [rbp-BCh]
char v56; // [rsp+8Dh] [rbp-BBh]
char v57; // [rsp+8Eh] [rbp-BAh]
int v58; // [rsp+90h] [rbp-B8h]
int v59; // [rsp+94h] [rbp-B4h]
int v60; // [rsp+9Ch] [rbp-ACh]
__int64 v61; // [rsp+C8h] [rbp-80h] BYREF
int v62; // [rsp+D0h] [rbp-78h]
int v63; // [rsp+D4h] [rbp-74h]
int v64; // [rsp+D8h] [rbp-70h]
int v65; // [rsp+104h] [rbp-44h]
if ( HDDMDeviceDump::useXngMarks )
std::ostream::write(stream, "BELDEF", 6);
HDDMXng::BelDef::BelDef((HDDMXng::BelDef *)v52);
beldef_code_high = HIBYTE(this->beldef_code);
v3 = v65;
if ( (beldef_code_high & 0x20) != 0 )
{
v56 = 1;
v3 = v65 | 2;
}
if ( (beldef_code_high & 0x10) != 0 )
{
v55 = 1;
v3 |= 1u;
}
p__ZN6google8protobuf8internal12kEmptyStringE_3 = p__ZN6google8protobuf8internal12kEmptyStringE;
v65 = v3 | 4;
if ( p__ZN6google8protobuf8internal12kEmptyStringE == (std::string *)&google::protobuf::internal::kEmptyString )
{
p__ZN6google8protobuf8internal12kEmptyStringE_3 = (std::string *)operator new(8u);
*(_QWORD *)p__ZN6google8protobuf8internal12kEmptyStringE_3 = (char *)&std::string::_Rep::_S_empty_rep_storage + 24;
p__ZN6google8protobuf8internal12kEmptyStringE = p__ZN6google8protobuf8internal12kEmptyStringE_3;
}
std::string::assign(p__ZN6google8protobuf8internal12kEmptyStringE_3, (const std::string *)&this->belDef_name);
HDDMBelDef_1 = this;
beldef_code = this->beldef_code;
if ( (beldef_code & 0xFFFC000) != 0 )
{
v65 |= 0x10u;
v58 = (beldef_code >> 14) & 0x3FFF;
HDDMBelDef_1 = this;
}
beldef_code1 = HDDMBelDef_1->beldef_code1;
if ( (beldef_code1 & 0x3FFF0) != 0 )
{
v65 |= 8u;
v54 = (beldef_code1 >> 4) & 0x3FFF;
HDDMBelDef_1 = this;
}
beldef_code_1 = HDDMBelDef_1->beldef_code;
if ( (beldef_code_1 & 0x3FFF) != 0 )
{
v65 |= 0x20u;
v59 = beldef_code_1 & 0x3FFF;
}
if ( this->qword20 )
{
v9 = (unsigned __int16)((beldef_code_1 & 0x3FFF) - (((beldef_code >> 14) & 0x3FFF) + ((beldef_code1 >> 4) & 0x3FFF)));
v47 = v9 + ((beldef_code1 >> 4) & 0x3FFF);
v49 = v9 + ((beldef_code >> 14) & 0x3FFF);
if ( v49 )
{
v48 = 0;
do
{
if ( v47 )
{
v45 = 0;
do
{
if ( *(_BYTE *)(*(_QWORD *)(this->qword20 + 8 * v48) + v45) )
{
v10 = v62;
v11 = v63;
if ( v62 < v63 )
{
++v62;
v12 = *(_DWORD **)(v61 + 8 * v10);
}
else
{
if ( v63 == v64 )
{
google::protobuf::internal::RepeatedPtrFieldBase::Reserve(
(google::protobuf::internal::RepeatedPtrFieldBase *)&v61,
v63 + 1);
v11 = v63;
}
v63 = v11 + 1;
v12 = (_DWORD *)operator new(0x58u);
HDDMXng::BelDefPip::BelDefPip((HDDMXng::BelDefPip *)v12);
v13 = v62++;
*(_QWORD *)(v61 + 8 * v13) = v12;
}
v14 = v12[21] | 3;
v12[4] = v48;
v12[21] = v14;
v12[5] = v45;
v15 = v49 + v45;
qword48 = this->qword48;
if ( qword48 )
{
p_char40 = &this->char40;
do
{
while ( (unsigned __int16)v48 <= *(_WORD *)(qword48 + 32)
&& ((unsigned __int16)v48 < *(_WORD *)(qword48 + 32) || *(_WORD *)(qword48 + 34) >= v15) )
{
p_char40 = (_QWORD *)qword48;
qword48 = *(_QWORD *)(qword48 + 16);
if ( !qword48 )
goto LABEL_33;
}
qword48 = *(_QWORD *)(qword48 + 24);
}
while ( qword48 );
LABEL_33:
if ( &this->char40 != p_char40
&& (unsigned __int16)v48 >= *((_WORD *)p_char40 + 16)
&& ((unsigned __int16)v48 > *((_WORD *)p_char40 + 16) || *((_WORD *)p_char40 + 17) <= v15) )
{
v18 = (__int64 *)p_char40[5];
if ( (v18[1] - *v18) >> 4 )
{
v19 = 1;
for ( i = 0; ; i = v19++ )
{
v30 = (int)v12[8];
v32 = v12[9];
if ( (int)v30 >= v32 )
{
if ( v32 == v12[10] )
{
google::protobuf::internal::RepeatedPtrFieldBase::Reserve(
(google::protobuf::internal::RepeatedPtrFieldBase *)(v12 + 6),
v32 + 1);
v32 = v12[9];
}
v12[9] = v32 + 1;
v21 = operator new(0x28u);
HDDMXng::AttrSetting::AttrSetting((HDDMXng::AttrSetting *)v21);
v22 = (int)v12[8];
v23 = *((_QWORD *)v12 + 3);
v12[8] = v22 + 1;
*(_QWORD *)(v23 + 8 * v22) = v21;
}
else
{
v31 = *((_QWORD *)v12 + 3);
v12[8] = v30 + 1;
v21 = *(_QWORD *)(v31 + 8 * v30);
}
v24 = *v18;
if ( (v18[1] - *v18) >> 4 <= i )
std::__throw_out_of_range("vector::_M_range_check");
*(_DWORD *)(v21 + 36) |= 1u;
p__ZN6google8protobuf8internal12kEmptyStringE_1 = *(std::string **)(v21 + 16);
v26 = (const std::string *)(16 * i + v24);
if ( p__ZN6google8protobuf8internal12kEmptyStringE_1 == (std::string *)&google::protobuf::internal::kEmptyString )
{
p__ZN6google8protobuf8internal12kEmptyStringE_1 = (std::string *)operator new(8u);
*(_QWORD *)p__ZN6google8protobuf8internal12kEmptyStringE_1 = (char *)&std::string::_Rep::_S_empty_rep_storage
+ 24;
*(_QWORD *)(v21 + 16) = p__ZN6google8protobuf8internal12kEmptyStringE_1;
}
std::string::assign(p__ZN6google8protobuf8internal12kEmptyStringE_1, v26);
v27 = *v18;
if ( (v18[1] - *v18) >> 4 <= i )
std::__throw_out_of_range("vector::_M_range_check");
*(_DWORD *)(v21 + 36) |= 2u;
p__ZN6google8protobuf8internal12kEmptyStringE_2 = *(std::string **)(v21 + 24);
v29 = (const std::string *)(v27 + 16 * i + 8);
if ( p__ZN6google8protobuf8internal12kEmptyStringE_2 == (std::string *)&google::protobuf::internal::kEmptyString )
{
p__ZN6google8protobuf8internal12kEmptyStringE_2 = (std::string *)operator new(8u);
*(_QWORD *)p__ZN6google8protobuf8internal12kEmptyStringE_2 = (char *)&std::string::_Rep::_S_empty_rep_storage
+ 24;
*(_QWORD *)(v21 + 24) = p__ZN6google8protobuf8internal12kEmptyStringE_2;
}
std::string::assign(p__ZN6google8protobuf8internal12kEmptyStringE_2, v29);
if ( (v18[1] - *v18) >> 4 <= v19 )
break;
}
}
}
}
}
++v45;
}
while ( v47 > (int)v45 );
}
++v48;
}
while ( v49 > (int)v48 );
}
}
HDDMBelDef_2 = this;
qword18 = (const google::protobuf::Message *)this->qword18;
if ( qword18 )
{
v35 = *((_QWORD *)qword18 + 1) - *(_QWORD *)qword18;
v65 |= 0x80u;
v60 = v35 >> 3;
HDDMBelDef_2 = this;
}
if ( HDDMBelDef_2->hddmBelUsageDef )
{
v65 |= 0x400u;
v57 = 1;
}
HDDMDevice::writeMessage((HDDMDevice *)stream, (std::ostream *)v52, qword18);
if ( HDDMDeviceDump::useXngMarks )
std::ostream::write(stream, "PINS", 4);
v36 = 0;
if ( (this->beldef_code & 0x3FFF) != 0 )
{
do
HDDMBelPinDef::writeme_pb(&this->hddmBelPinDefArray[v36++], stream);
while ( (this->beldef_code & 0x3FFF) > (int)v36 );
}
if ( HDDMDeviceDump::useXngMarks )
std::ostream::write(stream, "PRIMS", 5);
qword18_1 = (__int64 *)this->qword18;
if ( qword18_1 )
{
v38 = *qword18_1;
v39 = (qword18_1[1] - *qword18_1) >> 3;
if ( (int)v39 > 0 )
{
v40 = 0;
v41 = 8LL * (unsigned int)(v39 - 1) + 8;
while ( 1 )
{
v42 = *(_DWORD **)(v38 + v40);
*(_WORD *)v51 = v42[2];
std::ostream::write(stream, v51, 2);
HDDMDeviceDump::dumpbinary((HDDMDeviceDump *)v51, (const char *)&dword_0 + 2, (int)"beldef:", v43);
(*(void (__fastcall **)(_DWORD *, std::ostream *))(*(_QWORD *)v42 + 8LL))(v42, stream);
v40 += 8;
if ( v40 == v41 )
break;
v38 = *(_QWORD *)this->qword18;
}
}
}
hddmBelUsageDef = this->hddmBelUsageDef;
if ( hddmBelUsageDef )
HDDMBelUsageDef::writeme_pb(hddmBelUsageDef, stream);
HDDMXng::BelDef::~BelDef((HDDMXng::BelDef *)v52);
}
void __fastcall HDDMBelDef::print(HDDMBelDef *this, std::ostream *stream, const std::string *fileName)
{
__int64 v4; // rbp
__int64 v5; // rax
__int64 v6; // r12
__int64 v7; // rax
__int64 v8; // rbp
__int64 v9; // r12
__int64 v10; // r14
__int64 v11; // rbp
__int64 v12; // rbp
__int64 v13; // rax
__int64 v14; // r12
__int64 v15; // rbp
__int64 v16; // r14
__int64 v17; // r12
__int64 v18; // r12
__int64 v19; // rax
__int64 *qword18; // rdx
__int64 v21; // rax
__int64 v22; // rdx
__int64 v23; // r12
__int64 v24; // r14
char v25; // al
std::ostream *v26; // rax
std::ostream *v27; // rbp
__int64 v28; // rax
__int64 v29; // rdx
__int16 beldef_code; // ax
__int64 v31; // r14
int v32; // ebp
__int64 v33; // rax
_BYTE *v34; // r12
char v35; // al
std::ostream *v36; // rax
__int64 v37; // rbp
int v38; // eax
__int64 v39; // rbp
__int64 v40; // rax
__int64 v41; // r14
std::ostream *v42; // r14
__int64 v43; // rax
char v44; // al
std::ostream *v45; // rax
__int64 v46; // rbp
HDDMBelUsageDef *hddmBelUsageDef; // rdi
__int64 v48; // rax
__int64 v49; // rax
unsigned __int16 v50; // [rsp+0h] [rbp-58h]
unsigned __int16 v51; // [rsp+0h] [rbp-58h]
__int64 v52; // [rsp+0h] [rbp-58h]
int v53; // [rsp+0h] [rbp-58h]
unsigned int v54; // [rsp+8h] [rbp-50h]
__int64 v55; // [rsp+8h] [rbp-50h]
__int64 v56; // [rsp+10h] [rbp-48h]
int v57; // [rsp+1Ch] [rbp-3Ch]
v4 = std::__ostream_insert<char,std::char_traits<char>>(
stream,
*(_QWORD *)fileName,
*(_QWORD *)(*(_QWORD *)fileName - 24LL));
std::__ostream_insert<char,std::char_traits<char>>(v4, "BELDEF ", 7);
v5 = std::__ostream_insert<char,std::char_traits<char>>(v4, this->belDef_name, *((_QWORD *)this->belDef_name - 3));
std::endl<char,std::char_traits<char>>(v5);
LOBYTE(v4) = this->beldef_code1 & 0xF;
v6 = std::__ostream_insert<char,std::char_traits<char>>(
stream,
*(_QWORD *)fileName,
*(_QWORD *)(*(_QWORD *)fileName - 24LL));
std::__ostream_insert<char,std::char_traits<char>>(v6, " m_deviceid : ", 14);
v7 = std::ostream::_M_insert<unsigned long>(v6, (unsigned __int8)v4);
std::endl<char,std::char_traits<char>>(v7);
v8 = HIBYTE(this->beldef_code) >> 5;
v50 = (this->beldef_code >> 14) & 0x3FFF;
v9 = this->beldef_code & 0x3FFF;
v10 = std::__ostream_insert<char,std::char_traits<char>>(
stream,
*(_QWORD *)fileName,
*(_QWORD *)(*(_QWORD *)fileName - 24LL));
std::__ostream_insert<char,std::char_traits<char>>(v10, "m_rbel : ", 9);
v11 = std::ostream::_M_insert<unsigned long>(v10, v8 & 1);
std::__ostream_insert<char,std::char_traits<char>>(v11, " m_numpins: ", 12);
v12 = std::ostream::_M_insert<unsigned long>(v11, (unsigned __int16)v9);
std::__ostream_insert<char,std::char_traits<char>>(v12, " m_numinputpins : ", 18);
v13 = std::ostream::_M_insert<unsigned long>(v12, v50);
std::endl<char,std::char_traits<char>>(v13);
v14 = HIBYTE(this->beldef_code) >> 4;
v51 = (this->beldef_code1 >> 4) & 0x3FFF;
v15 = HIWORD(this->beldef_code1) >> 2;
v16 = std::__ostream_insert<char,std::char_traits<char>>(
stream,
*(_QWORD *)fileName,
*(_QWORD *)(*(_QWORD *)fileName - 24LL));
std::__ostream_insert<char,std::char_traits<char>>(v16, "m_optinv : ", 11);
v17 = std::ostream::_M_insert<unsigned long>(v16, v14 & 1);
std::__ostream_insert<char,std::char_traits<char>>(v17, " m_numoutputpins : ", 19);
v18 = std::ostream::_M_insert<unsigned long>(v17, v51);
std::__ostream_insert<char,std::char_traits<char>>(v18, " m_index : ", 11);
v19 = std::ostream::_M_insert<unsigned long>(v18, v15 & 0xFFF);
std::endl<char,std::char_traits<char>>(v19);
qword18 = (__int64 *)this->qword18;
if ( qword18 )
{
v21 = *qword18;
v22 = (qword18[1] - *qword18) >> 3;
if ( (int)v22 > 0 )
{
v23 = 0;
v24 = 8LL * (unsigned int)(v22 - 1) + 8;
while ( 1 )
{
(*(void (__fastcall **)(_QWORD, std::ostream *, const std::string *))(**(_QWORD **)(v21 + v23) + 32LL))(
*(_QWORD *)(v21 + v23),
stream,
fileName);
v27 = (std::ostream *)std::__ostream_insert<char,std::char_traits<char>>(
stream,
*(_QWORD *)fileName,
*(_QWORD *)(*(_QWORD *)fileName - 24LL));
std::__ostream_insert<char,std::char_traits<char>>(v27, ";", 1);
v28 = *(_QWORD *)(*(_QWORD *)v27 - 24LL);
v29 = *(_QWORD *)((char *)v27 + v28 + 240);
if ( !v29 )
break;
if ( *(_BYTE *)(v29 + 56) )
{
v25 = *(_BYTE *)(v29 + 67);
}
else
{
v52 = *(_QWORD *)((char *)v27 + v28 + 240);
std::ctype<char>::_M_widen_init(v52);
v25 = (*(__int64 (__fastcall **)(__int64, __int64))(*(_QWORD *)v52 + 48LL))(v52, 10);
}
v23 += 8;
v26 = (std::ostream *)std::ostream::put(v27, v25);
std::ostream::flush(v26);
if ( v23 == v24 )
goto LABEL_10;
v21 = *(_QWORD *)this->qword18;
}
LABEL_38:
std::__throw_bad_cast();
}
}
LABEL_10:
beldef_code = this->beldef_code;
if ( (beldef_code & 0x3FFF) != 0 )
{
v48 = std::__ostream_insert<char,std::char_traits<char>>(
stream,
*(_QWORD *)fileName,
*(_QWORD *)(*(_QWORD *)fileName - 24LL));
v49 = std::operator<<<std::char_traits<char>>(v48, "PINS : ");
std::endl<char,std::char_traits<char>>(v49);
beldef_code = this->beldef_code;
}
v31 = 0;
v32 = 0;
while ( v32 < (beldef_code & 0x3FFF) )
{
++v32;
HDDMBelPinDef::print(&this->hddmBelPinDefArray[v31], stream, fileName);
if ( v32 == (this->beldef_code & 0x3FFF) )
{
std::__ostream_insert<char,std::char_traits<char>>(stream, ";", 1);
std::endl<char,std::char_traits<char>>(stream);
}
else
{
std::__ostream_insert<char,std::char_traits<char>>(stream, ",", 1);
v33 = *(_QWORD *)(*(_QWORD *)stream - 24LL);
v34 = *(_BYTE **)((char *)stream + v33 + 240);
if ( !v34 )
goto LABEL_38;
if ( v34[56] )
{
v35 = v34[67];
}
else
{
std::ctype<char>::_M_widen_init(*(_QWORD *)((char *)stream + v33 + 240));
v35 = (*(__int64 (__fastcall **)(_BYTE *, __int64))(*(_QWORD *)v34 + 48LL))(v34, 10);
}
v36 = (std::ostream *)std::ostream::put(stream, v35);
std::ostream::flush(v36);
}
beldef_code = this->beldef_code;
++v31;
}
if ( this->qword20 )
{
v37 = std::__ostream_insert<char,std::char_traits<char>>(
stream,
*(_QWORD *)fileName,
*(_QWORD *)(*(_QWORD *)fileName - 24LL));
std::__ostream_insert<char,std::char_traits<char>>(v37, "PIPS:", 5);
std::endl<char,std::char_traits<char>>(v37);
v38 = (unsigned __int16)((this->beldef_code & 0x3FFF)
- (((this->beldef_code1 >> 4) & 0x3FFF)
+ ((this->beldef_code >> 14) & 0x3FFF)));
v53 = v38 + ((this->beldef_code1 >> 4) & 0x3FFF);
v57 = v38 + ((this->beldef_code >> 14) & 0x3FFF);
if ( v57 )
{
v56 = 0;
while ( !v53 )
{
LABEL_33:
if ( v57 <= (int)++v56 )
goto LABEL_34;
}
v39 = 0;
while ( 1 )
{
while ( !*(_BYTE *)(*(_QWORD *)(this->qword20 + 8 * v56) + v39) )
{
if ( v53 <= (int)++v39 )
goto LABEL_33;
}
v54 = ((this->beldef_code >> 14) & 0x3FFF) + v39;
v40 = std::__ostream_insert<char,std::char_traits<char>>(
stream,
*(_QWORD *)fileName,
*(_QWORD *)(*(_QWORD *)fileName - 24LL));
v41 = std::ostream::operator<<(v40, (unsigned int)v56);
std::__ostream_insert<char,std::char_traits<char>>(v41, " : ", 3);
v42 = (std::ostream *)std::ostream::operator<<(v41, v54);
std::__ostream_insert<char,std::char_traits<char>>(v42, ",", 1);
v43 = *(_QWORD *)((char *)v42 + *(_QWORD *)(*(_QWORD *)v42 - 24LL) + 240);
if ( !v43 )
goto LABEL_38;
if ( *(_BYTE *)(v43 + 56) )
{
v44 = *(_BYTE *)(v43 + 67);
}
else
{
v55 = *(_QWORD *)((char *)v42 + *(_QWORD *)(*(_QWORD *)v42 - 24LL) + 240);
std::ctype<char>::_M_widen_init(v55);
v44 = (*(__int64 (__fastcall **)(__int64, __int64))(*(_QWORD *)v55 + 48LL))(v55, 10);
}
++v39;
v45 = (std::ostream *)std::ostream::put(v42, v44);
std::ostream::flush(v45);
if ( v53 <= (int)v39 )
goto LABEL_33;
}
}
LABEL_34:
v46 = std::__ostream_insert<char,std::char_traits<char>>(
stream,
*(_QWORD *)fileName,
*(_QWORD *)(*(_QWORD *)fileName - 24LL));
std::__ostream_insert<char,std::char_traits<char>>(v46, ";", 1);
std::endl<char,std::char_traits<char>>(v46);
}
hddmBelUsageDef = this->hddmBelUsageDef;
if ( hddmBelUsageDef )
HDDMBelUsageDef::print(hddmBelUsageDef, stream, fileName);
}
void HDDMBelDef::allocatepindefs(HDDMBelDef *this, unsigned __int16 count)
{
__int64 v2; // rbx
_QWORD *v3; // rax
HDDMBelPinDef *hddmBelPinDefArray; // r14
HDDMBelPinDef *v5; // rbp
__int16 beldef_code; // ax
v2 = count - 1LL;
v3 = (_QWORD *)operator new[](16LL * count + 8);
hddmBelPinDefArray = (HDDMBelPinDef *)(v3 + 1);
*v3 = count;
v5 = (HDDMBelPinDef *)(v3 + 1);
if ( count )
{
do
{
HDDMBelPinDef::HDDMBelPinDef(v5);
--v2;
++v5;
}
while ( v2 != -1 );
}
beldef_code = this->beldef_code;
this->hddmBelPinDefArray = hddmBelPinDefArray;
LOWORD(this->beldef_code) = count & 0x3FFF | beldef_code & 0xC000;
}
void __fastcall HDDMBelDef::createpindefsmap(HDDMBelDef *this)
{
__int64 qword30_1; // rax
HDDMBelPinDef *v2; // r12
_QWORD *v3; // r14
_QWORD *pindef_name; // rbx
__int64 v5; // rbp
size_t n_3; // r13
int v7; // eax
_QWORD *s1; // rdi
size_t n_2; // r15
size_t n; // rdx
_QWORD *s2; // rsi
size_t n_1; // rdx
int v13; // eax
unsigned __int16 v14; // [rsp+6h] [rbp-82h]
__int64 v15; // [rsp+8h] [rbp-80h]
size_t n_4; // [rsp+8h] [rbp-80h]
__int64 qword30; // [rsp+10h] [rbp-78h]
char v19; // [rsp+3Fh] [rbp-49h] BYREF
_QWORD *p_pindef_name; // [rsp+40h] [rbp-48h] BYREF
qword30_1 = operator new(0x30u);
*(_DWORD *)(qword30_1 + 8) = 0;
*(_QWORD *)(qword30_1 + 16) = 0;
*(_QWORD *)(qword30_1 + 40) = 0;
qword30 = qword30_1;
*(_QWORD *)(qword30_1 + 24) = qword30_1 + 8;
*(_QWORD *)(qword30_1 + 32) = qword30_1 + 8;
this->qword30 = qword30_1;
v15 = qword30_1 + 8;
v14 = 0;
if ( (this->beldef_code & 0x3FFF) == 0 )
return;
while ( 2 )
{
v2 = &this->hddmBelPinDefArray[v14];
v3 = *(_QWORD **)(qword30 + 16);
if ( !v3 )
{
v5 = v15;
goto LABEL_24;
}
pindef_name = (_QWORD *)v2->pindef_name;
v5 = v15;
n_3 = *(pindef_name - 3);
do
{
while ( 1 )
{
s1 = (_QWORD *)v3[4];
n_2 = *(s1 - 3);
n = n_2;
if ( n_3 <= n_2 )
n = n_3;
v7 = memcmp(s1, pindef_name, n);
if ( !v7 )
break;
LABEL_5:
if ( v7 < 0 )
goto LABEL_12;
LABEL_6:
v5 = (__int64)v3;
v3 = (_QWORD *)v3[2];
if ( !v3 )
goto LABEL_13;
}
if ( (__int64)(n_2 - n_3) > 0x7FFFFFFF )
goto LABEL_6;
if ( (__int64)(n_2 - n_3) >= (__int64)0xFFFFFFFF80000000LL )
{
v7 = n_2 - n_3;
goto LABEL_5;
}
LABEL_12:
v3 = (_QWORD *)v3[3];
}
while ( v3 );
LABEL_13:
if ( v15 == v5 )
goto LABEL_24;
s2 = *(_QWORD **)(v5 + 32);
n_1 = *(s2 - 3);
n_4 = n_1;
if ( n_3 <= n_1 )
n_1 = n_3;
v13 = memcmp(pindef_name, s2, n_1);
if ( v13 )
{
LABEL_20:
if ( v13 < 0 )
goto LABEL_24;
}
else if ( (__int64)(n_3 - n_4) <= 0x7FFFFFFF )
{
if ( (__int64)(n_3 - n_4) >= (__int64)0xFFFFFFFF80000000LL )
{
v13 = n_3 - n_4;
goto LABEL_20;
}
LABEL_24:
p_pindef_name = &v2->pindef_name;
v5 = std::_Rb_tree<std::string,std::pair<std::string const,HDDMBelPinDef *>,std::_Select1st<std::pair<std::string const,HDDMBelPinDef *>>,std::less<std::string>,std::allocator<std::pair<std::string const,HDDMBelPinDef *>>>::_M_emplace_hint_unique<std::piecewise_construct_t const&,std::tuple<std::string const&>,std::tuple<>>(
qword30,
v5,
&unk_7B5CA99,
&p_pindef_name,
&v19);
}
*(_QWORD *)(v5 + 40) = v2;
if ( ++v14 < (this->beldef_code & 0x3FFF) )
{
qword30 = this->qword30;
v15 = qword30 + 8;
continue;
}
break;
}
}
void __fastcall HDDMBelDef::addpindefs(HDDMBelDef *this, __int16 index)
{
HDDMBelPinDef *hddmBelPinDefArray; // rbx
unsigned __int16 v3; // r12
__int64 v4; // r14
__int64 v5; // r12
char *v6; // rax
char *v7; // rdx
char v8; // cl
char v9; // cl
char v10; // cl
char v11; // cl
char v12; // cl
char v13; // cl
char v14; // cl
char v15; // cl
char v16; // cl
char v17; // cl
char v18; // cl
char v19; // cl
char v20; // cl
const std::string *v21; // rsi
HDDMBelPinDef *i; // rbp
hddmBelPinDefArray = this->hddmBelPinDefArray;
v3 = this->beldef_code & 0x3FFF;
HDDMBelDef::allocatepindefs(this, v3 + index);
if ( v3 )
{
v4 = 0;
v5 = 16 * ((unsigned int)v3 - 1 + 1LL);
do
{
v6 = (char *)this->hddmBelPinDefArray + v4;
v7 = (char *)hddmBelPinDefArray + v4;
v8 = *((_BYTE *)hddmBelPinDefArray + v4) & 1 | *v6 & 0xFE;
*v6 = v8;
v9 = *((_BYTE *)hddmBelPinDefArray + v4) & 2 | v8 & 0xFD;
*v6 = v9;
v10 = *((_BYTE *)hddmBelPinDefArray + v4) & 4 | v9 & 0xFB;
*v6 = v10;
v11 = *((_BYTE *)hddmBelPinDefArray + v4) & 8 | v10 & 0xF7;
*v6 = v11;
v12 = *((_BYTE *)hddmBelPinDefArray + v4) & 0x10 | v11 & 0xEF;
*v6 = v12;
*v6 = *((_BYTE *)hddmBelPinDefArray + v4) & 0x20 | v12 & 0xDF;
*(_DWORD *)v6 = *(_DWORD *)((_BYTE *)hddmBelPinDefArray + v4) & 0xFFFC0 | *(_DWORD *)v6 & 0xFFF0003F;
v6[2] = *((_BYTE *)hddmBelPinDefArray + v4 + 2) & 0xF0 | v6[2] & 0xF;
v13 = *((_BYTE *)hddmBelPinDefArray + v4 + 3) & 1 | v6[3] & 0xFE;
v6[3] = v13;
v14 = *((_BYTE *)hddmBelPinDefArray + v4 + 3) & 2 | v13 & 0xFD;
v6[3] = v14;
v15 = *((_BYTE *)hddmBelPinDefArray + v4 + 3) & 4 | v14 & 0xFB;
v6[3] = v15;
v16 = *((_BYTE *)hddmBelPinDefArray + v4 + 3) & 8 | v15 & 0xF7;
v6[3] = v16;
v17 = *((_BYTE *)hddmBelPinDefArray + v4 + 3) & 0x10 | v16 & 0xEF;
v6[3] = v17;
v18 = *((_BYTE *)hddmBelPinDefArray + v4 + 3) & 0x20 | v17 & 0xDF;
v6[3] = v18;
v19 = *((_BYTE *)hddmBelPinDefArray + v4 + 3) & 0x40 | v18 & 0xBF;
v6[3] = v19;
v6[3] = *((_BYTE *)hddmBelPinDefArray + v4 + 3) & 0x80 | v19 & 0x7F;
v6[4] = *((_BYTE *)hddmBelPinDefArray + v4 + 4) & 0xF | v6[4] & 0xF0;
*((_WORD *)v6 + 2) = *(_WORD *)((_BYTE *)hddmBelPinDefArray + v4 + 4) & 0xFFF0 | *((_WORD *)v6 + 2) & 0xF;
*((_WORD *)v6 + 3) = *(_WORD *)((_BYTE *)hddmBelPinDefArray + v4 + 6) & 0x3FF | *((_WORD *)v6 + 3) & 0xFC00;
v20 = *((_BYTE *)hddmBelPinDefArray + v4 + 7) & 0x3C | v6[7] & 0xC3;
v21 = (HDDMBelPinDef *)((char *)hddmBelPinDefArray + v4 + 8);
v4 += 16;
v6[7] = v20;
v6[7] = v7[7] & 0xC0 | v20 & 0x3F;
std::string::assign((std::string *)(v6 + 8), v21);
}
while ( v4 != v5 );
}
if ( hddmBelPinDefArray )
{
for ( i = (HDDMBelPinDef *)((char *)hddmBelPinDefArray + 16 * *((_QWORD *)hddmBelPinDefArray - 1));
hddmBelPinDefArray != i;
HDDMBelPinDef::~HDDMBelPinDef(i) )
{
i = (HDDMBelPinDef *)((char *)i - 16);
}
operator delete[]((char *)hddmBelPinDefArray - 8);
}
}
void HDDMBelDef::allocatepindefs(HDDMBelDef *this, unsigned __int16 count)
{
__int64 v2; // rbx
_QWORD *v3; // rax
HDDMBelPinDef *hddmBelPinDefArray; // r14
HDDMBelPinDef *v5; // rbp
__int16 beldef_code; // ax
v2 = count - 1LL;
v3 = (_QWORD *)operator new[](16LL * count + 8);
hddmBelPinDefArray = (HDDMBelPinDef *)(v3 + 1);
*v3 = count;
v5 = (HDDMBelPinDef *)(v3 + 1);
if ( count )
{
do
{
HDDMBelPinDef::HDDMBelPinDef(v5);
--v2;
++v5;
}
while ( v2 != -1 );
}
beldef_code = this->beldef_code;
this->hddmBelPinDefArray = hddmBelPinDefArray;
LOWORD(this->beldef_code) = count & 0x3FFF | beldef_code & 0xC000;
}
void __fastcall HDDMBelDef::addprimitive(HDDMBelDef *this, HDDMPrimitive *Primitive)
{
HDDMPrimitive *hddmPrimitive; // rdi
HDDMPrimitive **hddmBelDef; // rdx
__int64 v5; // rdx
__int64 qword18_1; // rax
HDDMPrimitive *p_Primitive; // [rsp+8h] [rbp-10h] BYREF
hddmPrimitive = this->hddmPrimitive;
p_Primitive = Primitive;
if ( !hddmPrimitive )
{
qword18_1 = operator new(0x18u);
*(_QWORD *)qword18_1 = 0;
*(_QWORD *)(qword18_1 + 8) = 0;
hddmPrimitive = (HDDMPrimitive *)qword18_1;
*(_QWORD *)(qword18_1 + 16) = 0;
this->hddmPrimitive = (HDDMPrimitive *)qword18_1;
}
hddmBelDef = *(HDDMPrimitive ***)&hddmPrimitive->numPrimType;
if ( hddmBelDef == (HDDMPrimitive **)hddmPrimitive->hddmBelDef )
{
std::vector<HDDMPrimitive *>::_M_emplace_back_aux<HDDMPrimitive * const&>(hddmPrimitive, &p_Primitive);
}
else
{
if ( hddmBelDef )
{
*hddmBelDef = p_Primitive;
v5 = *(_QWORD *)&hddmPrimitive->numPrimType;
}
else
{
v5 = 0;
}
*(_QWORD *)&hddmPrimitive->numPrimType = v5 + 8;
}
}
void __fastcall HDDMBelDef::addusagedef(HDDMBelDef *this)
{
HDDMBelUsageDef *hddmBelUsageDef; // rbx
hddmBelUsageDef = (HDDMBelUsageDef *)operator new(0x58u);
HDDMBelUsageDef::HDDMBelUsageDef(hddmBelUsageDef);
this->hddmBelUsageDef = hddmBelUsageDef;
hddmBelUsageDef->qword50 = this;
}
void __fastcall HDDMBelDef::allocatepips(HDDMBelDef *this)
{
int v1; // ebx
__int64 qword20_1; // rax
unsigned int beldef_code1; // edx
unsigned int beldef_code; // ecx
int qword20_2; // r14d
__int64 qword20; // r15
__int64 v7; // rbp
__int64 v8; // rbx
__int64 qword20_3; // rax
v1 = (unsigned __int16)((this->beldef_code & 0x3FFF)
- (((this->beldef_code1 >> 4) & 0x3FFF)
+ ((this->beldef_code >> 14) & 0x3FFF)))
+ ((this->beldef_code >> 14) & 0x3FFF);
qword20_1 = operator new[](8LL * v1);
beldef_code1 = this->beldef_code1;
beldef_code = this->beldef_code;
this->qword20 = qword20_1;
qword20_2 = (unsigned __int16)((this->beldef_code & 0x3FFF)
- (((beldef_code >> 14) & 0x3FFF)
+ ((beldef_code1 >> 4) & 0x3FFF)))
+ ((beldef_code1 >> 4) & 0x3FFF);
if ( v1 )
{
qword20 = qword20_1;
v7 = 8LL * (unsigned int)(v1 - 1) + 8;
v8 = 0;
while ( 1 )
{
*(_QWORD *)(v8 + qword20) = operator new[](qword20_2);
qword20_3 = 0;
if ( qword20_2 )
{
do
*(_BYTE *)(*(_QWORD *)(this->qword20 + v8) + qword20_3++) = 0;
while ( qword20_2 > (int)qword20_3 );
}
v8 += 8;
if ( v8 == v7 )
break;
qword20 = this->qword20;
}
}
}
_QWORD *__fastcall HDDMBelDef::buildReservedBelTypes(HDDMBelDef *this, HDDMDevice *a2)
{
_QWORD *v2; // rax
__int64 v3; // rax
__int64 Site; // rbx
int i; // ebp
HDDMElement *Element; // rax
__int64 BelDef; // rax
_WORD *v8; // rax
_QWORD *v10; // [rsp+8h] [rbp-90h]
char v11; // [rsp+2Fh] [rbp-69h] BYREF
HDDMSite v12; // [rsp+30h] [rbp-68h] BYREF
_QWORD v13[9]; // [rsp+50h] [rbp-48h] BYREF
v2 = (_QWORD *)operator new(0x18u);
*v2 = 0;
v2[1] = 0;
v2[2] = 0;
v10 = v2;
v3 = (__int64)(*((_QWORD *)this + 16) - *((_QWORD *)this + 15)) >> 3;
if ( (_WORD)v3 )
std::vector<unsigned char>::_M_fill_insert(v10, 0, (unsigned __int16)v3, &unk_7B5CA98);
std::string::string(v13, "CFG_IO_ACCESS", &v12);
sub_2165630(this, v10, v13, 2);
std::string::_Rep::_M_dispose(v13[0] - 24LL, &v12.qword10);
std::string::string(v13, "USR_ACCESS", &v12);
sub_2165630(this, v10, v13, 3);
std::string::_Rep::_M_dispose(v13[0] - 24LL, &v12.qword10);
std::string::string(v13, "EFUSE_USR", &v12);
sub_2165630(this, v10, v13, 3);
std::string::_Rep::_M_dispose(v13[0] - 24LL, &v12.qword10);
std::string::string(v13, "DCIRESET", &v12);
sub_2165630(this, v10, v13, 3);
std::string::_Rep::_M_dispose(v13[0] - 24LL, &v12.qword10);
std::string::string(v13, "ICAP_TOP", &v12);
sub_2165630(this, v10, v13, 4);
std::string::_Rep::_M_dispose(v13[0] - 24LL, &v12.qword10);
std::string::string(v13, "ICAP_BOT", &v12);
sub_2165630(this, v10, v13, 4);
std::string::_Rep::_M_dispose(v13[0] - 24LL, &v12.qword10);
std::string::string(v13, "STARTUP", &v12);
sub_2165630(this, v10, v13, 4);
std::string::_Rep::_M_dispose(v13[0] - 24LL, &v12.qword10);
std::string::string(v13, "FRAME_ECC", &v12);
sub_2165630(this, v10, v13, 4);
std::string::_Rep::_M_dispose(v13[0] - 24LL, &v12.qword10);
std::string::string(v13, "PS8_X0Y0", &v12);
Site = HDDMDevice::getSite((HDDMDevice *)this, (const std::string *)v13);
std::string::_Rep::_M_dispose(v13[0] - 24LL, &v12.qword10);
if ( Site )
{
for ( i = 0; ; ++i )
{
v8 = (_WORD *)(*(_QWORD *)(HDDMDeviceCache::m_devcache[(*(_BYTE *)(Site + 8) >> 2) & 0xF] + 240LL)
+ 48LL * ((*(_DWORD *)Site >> 2) & 0x3FFFFF));
if ( i >= ((*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(HDDMDeviceCache::m_devcache[(*v8 >> 6) & 0xF]
+ 168LL)
+ 8LL * (v8[2] & 0x3FF))
+ 120LL)
+ 8LL * *(unsigned __int8 *)(Site + 3))
+ 12LL) >> 6)
& 0x1FFF) )
break;
HDDMSite::getBel(&v12, Site);
if ( (unsigned __int8)HDDMBel::isBad((HDDMBel *)&v12) )
{
HDDMBel::~HDDMBel((HDDMBel *)&v12);
}
else
{
Element = (HDDMElement *)HDDMBel::getElement((HDDMBel *)&v12);
BelDef = HDDMElement::getBelDef(Element);
std::string::string((std::string *)&v12.qword10, (const std::string *)(BelDef + 16));
if ( !strcmp((const char *)v12.qword10, "PSS_ALTO_CORE")
|| !strcmp((const char *)v12.qword10, "PSS_ALTO_CORE_PAD_CLK") )
{
std::string::_Rep::_M_dispose(v12.qword10 - 24LL, v13);
HDDMBel::~HDDMBel((HDDMBel *)&v12);
}
else
{
std::string::string((std::string *)v13, (const std::string *)&v12.qword10);
sub_2165630(this, v10, v13, 1);
std::string::_Rep::_M_dispose(v13[0] - 24LL, &v11);
std::string::_Rep::_M_dispose(v12.qword10 - 24LL, v13);
HDDMBel::~HDDMBel((HDDMBel *)&v12);
}
}
}
}
return v10;
}
void __fastcall HDDMBelDef::createpindefsmap(HDDMBelDef *this)
{
__int64 qword30_1; // rax
HDDMBelPinDef *v2; // r12
_QWORD *v3; // r14
_QWORD *pindef_name; // rbx
__int64 v5; // rbp
size_t n_3; // r13
int v7; // eax
_QWORD *s1; // rdi
size_t n_2; // r15
size_t n; // rdx
_QWORD *s2; // rsi
size_t n_1; // rdx
int v13; // eax
unsigned __int16 v14; // [rsp+6h] [rbp-82h]
__int64 v15; // [rsp+8h] [rbp-80h]
size_t n_4; // [rsp+8h] [rbp-80h]
__int64 qword30; // [rsp+10h] [rbp-78h]
char v19; // [rsp+3Fh] [rbp-49h] BYREF
_QWORD *p_pindef_name; // [rsp+40h] [rbp-48h] BYREF
qword30_1 = operator new(0x30u);
*(_DWORD *)(qword30_1 + 8) = 0;
*(_QWORD *)(qword30_1 + 16) = 0;
*(_QWORD *)(qword30_1 + 40) = 0;
qword30 = qword30_1;
*(_QWORD *)(qword30_1 + 24) = qword30_1 + 8;
*(_QWORD *)(qword30_1 + 32) = qword30_1 + 8;
this->qword30 = qword30_1;
v15 = qword30_1 + 8;
v14 = 0;
if ( (this->beldef_code & 0x3FFF) == 0 )
return;
while ( 2 )
{
v2 = &this->hddmBelPinDefArray[v14];
v3 = *(_QWORD **)(qword30 + 16);
if ( !v3 )
{
v5 = v15;
goto LABEL_24;
}
pindef_name = (_QWORD *)v2->pindef_name;
v5 = v15;
n_3 = *(pindef_name - 3);
do
{
while ( 1 )
{
s1 = (_QWORD *)v3[4];
n_2 = *(s1 - 3);
n = n_2;
if ( n_3 <= n_2 )
n = n_3;
v7 = memcmp(s1, pindef_name, n);
if ( !v7 )
break;
LABEL_5:
if ( v7 < 0 )
goto LABEL_12;
LABEL_6:
v5 = (__int64)v3;
v3 = (_QWORD *)v3[2];
if ( !v3 )
goto LABEL_13;
}
if ( (__int64)(n_2 - n_3) > 0x7FFFFFFF )
goto LABEL_6;
if ( (__int64)(n_2 - n_3) >= (__int64)0xFFFFFFFF80000000LL )
{
v7 = n_2 - n_3;
goto LABEL_5;
}
LABEL_12:
v3 = (_QWORD *)v3[3];
}
while ( v3 );
LABEL_13:
if ( v15 == v5 )
goto LABEL_24;
s2 = *(_QWORD **)(v5 + 32);
n_1 = *(s2 - 3);
n_4 = n_1;
if ( n_3 <= n_1 )
n_1 = n_3;
v13 = memcmp(pindef_name, s2, n_1);
if ( v13 )
{
LABEL_20:
if ( v13 < 0 )
goto LABEL_24;
}
else if ( (__int64)(n_3 - n_4) <= 0x7FFFFFFF )
{
if ( (__int64)(n_3 - n_4) >= (__int64)0xFFFFFFFF80000000LL )
{
v13 = n_3 - n_4;
goto LABEL_20;
}
LABEL_24:
p_pindef_name = &v2->pindef_name;
v5 = std::_Rb_tree<std::string,std::pair<std::string const,HDDMBelPinDef *>,std::_Select1st<std::pair<std::string const,HDDMBelPinDef *>>,std::less<std::string>,std::allocator<std::pair<std::string const,HDDMBelPinDef *>>>::_M_emplace_hint_unique<std::piecewise_construct_t const&,std::tuple<std::string const&>,std::tuple<>>(
qword30,
v5,
&unk_7B5CA99,
&p_pindef_name,
&v19);
}
*(_QWORD *)(v5 + 40) = v2;
if ( ++v14 < (this->beldef_code & 0x3FFF) )
{
qword30 = this->qword30;
v15 = qword30 + 8;
continue;
}
break;
}
}
__int64 __fastcall HDDMBelDef::getNumArcs(HDDMBelDef *this, __int16 nIndex)
{
int v2; // eax
int NumFwdArcs; // r12d
v2 = *(_BYTE *)(HDDMBelDef::getPinDef(this, nIndex) + 7) & 0xC0;
if ( !v2 )
return HDDMBelDef::getNumFwdArcs(this, nIndex);
if ( (_BYTE)v2 == 0x80 )
return HDDMBelDef::getNumReverseArcs(this, nIndex);
NumFwdArcs = HDDMBelDef::getNumFwdArcs(this, nIndex);
return NumFwdArcs + (unsigned int)HDDMBelDef::getNumReverseArcs(this, nIndex);
}
__int64 __fastcall HDDMBelDef::getNumFwdArcs(HDDMBelDef *this, unsigned __int16 nIndex)
{
__int64 qword20; // rcx
unsigned __int16 v3; // r9
int v4; // eax
int v5; // edi
__int64 v6; // rdx
__int64 result; // rax
__int64 v8; // rsi
qword20 = this->qword20;
if ( !qword20 )
return 0;
v3 = (this->beldef_code1 >> 4) & 0x3FFF;
v4 = (unsigned __int16)((this->beldef_code & 0x3FFF) - (((this->beldef_code >> 14) & 0x3FFF) + v3));
v5 = v4 + ((this->beldef_code1 >> 4) & 0x3FFF);
if ( !(v4 + v3) )
return 0;
v6 = 0;
result = 0;
v8 = *(_QWORD *)(qword20 + 8LL * nIndex);
do
{
if ( *(_BYTE *)(v8 + v6) )
result = (unsigned int)(result + 1);
++v6;
}
while ( v5 > (int)v6 );
return result;
}
__int64 __fastcall HDDMBelDef::setrecursivedeviceid(HDDMBelDef *this, unsigned __int16 a2)
{
__int64 v2; // rdx
int v3; // r9d
int v4; // ecx
__int64 result; // rax
char v6; // r9
bool v7; // zf
HDDMBelUsageDef *hddmBelUsageDef; // rdi
v2 = 0;
v3 = a2 & 0xF;
v4 = 0;
result = v3 | this->beldef_code1 & 0xF0u;
v6 = 16 * v3;
v7 = (this->beldef_code & 0x3FFF) == 0;
LOBYTE(this->beldef_code1) = result;
if ( !v7 )
{
do
{
++v4;
BYTE2(this->hddmBelPinDefArray[v2].pindef_code) = v6 | BYTE2(this->hddmBelPinDefArray[v2].pindef_code) & 0xF;
++v2;
result = this->beldef_code & 0x3FFF;
}
while ( (int)result > v4 );
}
hddmBelUsageDef = this->hddmBelUsageDef;
if ( hddmBelUsageDef )
return HDDMBelUsageDef::setrecursivedeviceid(hddmBelUsageDef, a2);
return result;
}