请仔细阅读和分析下面函数,进行优化后,采用C/C++11标准,完整推导并重构可编译的全部代码
特别注意:
1.保持所有原始功能不变
2.提高执行效率,降低计算复杂度
3.已经给定的结构体名字和元素不要更改,详细的中文注释
4.自动添加中文注释说明功能逻辑
5.不使用 auto,使用显式 for 循环
6.结构体采用32位定义
7.不要使用小函数,保持原始的函数定义
void __cdecl HDDMDevice::readarch_pb(HDDMDevice *this, const std::string *a2, unsigned __int16 a3)
{
int v3; // edi
int v4; // esi
void *v5; // esi
int v6; // edx
std::string **v7; // eax
int v8; // edi
std::string *dword34; // edx
int v10; // eax
std::string *dword40; // eax
int v12; // eax
HDDMDevice *dword104; // esi
size_t v14; // ebp
_DWORD *s1; // eax
size_t v16; // edi
size_t n; // ecx
int v18; // eax
int v19; // edi
HDDMDevice *v20; // eax
int v21; // esi
_DWORD *dword4C; // eax
int v23; // eax
HDDMDevice *dword134; // esi
size_t v25; // ebp
_DWORD *dword10; // eax
size_t v27; // edi
size_t v28; // ecx
int v29; // eax
int v30; // edi
HDDMDevice *v31; // eax
int v32; // edx
HDDMTileType *v33; // esi
HDDMTileType **dword58; // eax
int v35; // eax
HDDMTileType **dword14C; // esi
size_t v37; // ebp
HDDMTileType *v38; // eax
size_t v39; // edi
size_t v40; // ecx
int v41; // eax
int v42; // edi
char *v43; // ebp
HDDMTileType *v44; // esi
HDDMTileType **dword64; // eax
int v46; // eax
HDDMTileType **dword11C; // esi
size_t v48; // ebp
HDDMTileType *v49; // eax
size_t v50; // edi
size_t v51; // ecx
int v52; // eax
int v53; // edi
char *v54; // ebp
HDDMTileType **v55; // eax
HDDMTileType **v56; // edi
int v57; // esi
int v58; // eax
HDDMTileType **v59; // eax
HDDMTileType **v60; // edi
int v61; // esi
int v62; // eax
HDDMTileType *v63; // eax
size_t v64; // ebp
_DWORD *v65; // edx
size_t v66; // edi
size_t v67; // ecx
unsigned int v68; // eax
unsigned int v69; // ebp
HDDMTileType *v70; // eax
size_t v71; // ebp
_DWORD *v72; // edx
size_t v73; // edi
size_t v74; // ecx
unsigned int v75; // eax
unsigned int v76; // ebp
int i; // esi
int v78; // eax
std::string *dwordD8; // eax
google::protobuf::Message *v80; // [esp+8h] [ebp-1F4h]
HDDMTileType **v81; // [esp+10h] [ebp-1ECh]
char *v82; // [esp+14h] [ebp-1E8h]
void *v83; // [esp+24h] [ebp-1D8h]
HDDMTileType *s2; // [esp+24h] [ebp-1D8h]
_DWORD *v85; // [esp+24h] [ebp-1D8h]
char *v86; // [esp+24h] [ebp-1D8h]
char *v87; // [esp+24h] [ebp-1D8h]
HDDMDevice *v88; // [esp+28h] [ebp-1D4h]
HDDMDevice *v89; // [esp+28h] [ebp-1D4h]
HDDMTileType **v90; // [esp+28h] [ebp-1D4h]
HDDMTileType **v91; // [esp+28h] [ebp-1D4h]
int j; // [esp+2Ch] [ebp-1D0h]
int k; // [esp+2Ch] [ebp-1D0h]
int m; // [esp+2Ch] [ebp-1D0h]
char *v95; // [esp+2Ch] [ebp-1D0h]
HDDMTileType *v96; // [esp+34h] [ebp-1C8h]
char *v97; // [esp+34h] [ebp-1C8h]
std::string *ii; // [esp+34h] [ebp-1C8h]
int v99; // [esp+40h] [ebp-1BCh]
int v100; // [esp+40h] [ebp-1BCh]
int v101; // [esp+40h] [ebp-1BCh]
int v102; // [esp+40h] [ebp-1BCh]
int v103; // [esp+44h] [ebp-1B8h]
HDDMDevice *v104; // [esp+54h] [ebp-1A8h] BYREF
HDDMTileType **v105; // [esp+58h] [ebp-1A4h] BYREF
int v106; // [esp+5Ch] [ebp-1A0h]
char v107; // [esp+6Eh] [ebp-18Eh] BYREF
char v108; // [esp+6Fh] [ebp-18Dh] BYREF
_DWORD v109[4]; // [esp+70h] [ebp-18Ch] BYREF
_DWORD v110[4]; // [esp+80h] [ebp-17Ch] BYREF
_DWORD v111[4]; // [esp+90h] [ebp-16Ch] BYREF
HDDMTileType *v112[2]; // [esp+A0h] [ebp-15Ch] BYREF
char v113[8]; // [esp+A8h] [ebp-154h] BYREF
_BYTE v114[8]; // [esp+B0h] [ebp-14Ch] BYREF
std::string *v115; // [esp+B8h] [ebp-144h]
int v116; // [esp+BCh] [ebp-140h]
int v117; // [esp+C0h] [ebp-13Ch]
int v118; // [esp+DCh] [ebp-120h]
void *v119; // [esp+E0h] [ebp-11Ch]
int v120; // [esp+FCh] [ebp-100h]
int v121; // [esp+100h] [ebp-FCh]
int v122; // [esp+11Ch] [ebp-E0h]
int v123; // [esp+120h] [ebp-DCh]
int v124; // [esp+124h] [ebp-D8h]
int v125; // [esp+128h] [ebp-D4h]
_BYTE v126[8]; // [esp+140h] [ebp-BCh] BYREF
_BYTE v127[180]; // [esp+148h] [ebp-B4h] BYREF
isl::iostreams::filtering_stream<boost::iostreams::input,char,std::char_traits<char>,std::allocator<char>,boost::iostreams::public_>::filtering_stream(
(int)v126,
*(_DWORD *)a2,
4,
0);
this->byte178 = a3 > 1u;
this->dword94 = a3;
std::istream::read((std::istream *)v127, v113, (int)&byte_8);
HDDMXng::Architecture::Architecture((HDDMXng::Architecture *)v114);
HDDMDevice::readMessage((HDDMDevice *)v127, (std::istream *)v114, v80);
this->word20 = v122;
std::string::assign((std::string *)&this->dword24, v115);
HDDMDevice::setupArchSpecific(this);
v3 = v117;
if ( v117 )
{
this->byteE0 = 1;
std::vector<std::string>::reserve((int)&this->charD4, v3);
if ( v3 > 0 )
{
for ( i = 0; i != v3; ++i )
{
dwordD8 = (std::string *)this->dwordD8;
if ( dwordD8 == (std::string *)this->dwordDC )
{
std::vector<std::string>::_M_emplace_back_aux<std::string const&>(
(int)&this->charD4,
*(std::string **)(v116 + 4 * i));
}
else
{
if ( dwordD8 )
{
std::string::string(dwordD8, *(const std::string **)(v116 + 4 * i));
v78 = this->dwordD8;
}
else
{
v78 = 0;
}
this->dwordD8 = v78 + 4;
}
}
}
}
v83 = v119;
if ( v119 )
{
v4 = (int)v119;
std::vector<std::string>::reserve((int)&this->char30, (int)v119);
if ( v4 > 0 )
{
v5 = 0;
do
{
v8 = 4 * (_DWORD)v5;
v7 = (std::string **)(4 * (_DWORD)v5 + v118);
dword34 = (std::string *)this->dword34;
if ( dword34 == (std::string *)this->dword38 )
{
std::vector<std::string>::_M_emplace_back_aux<std::string const&>((int)&this->char30, *v7);
v7 = (std::string **)(v8 + v118);
}
else
{
if ( dword34 )
{
std::string::string(dword34, *v7);
v6 = this->dword34;
v7 = (std::string **)(v8 + v118);
}
else
{
v6 = 0;
}
this->dword34 = v6 + 4;
}
*(_WORD *)std::map<std::string,unsigned short>::operator[]((int)(&this->dword158 + 1), (int)*v7) = (_WORD)v5;
v5 = (char *)v5 + 1;
}
while ( v5 != v83 );
}
}
v99 = v121;
std::vector<std::string>::reserve((int)&this->dword3C, v121);
if ( v99 )
{
v10 = 0;
for ( j = 0; j != v99; v10 = j )
{
std::string::string((std::string *)v112, *(const std::string **)(v120 + 4 * v10));
dword40 = (std::string *)this->dword40;
if ( dword40 == (std::string *)this->dword44 )
{
std::vector<std::string>::_M_emplace_back_aux<std::string const&>((int)&this->dword3C, (std::string *)v112);
}
else
{
if ( dword40 )
{
std::string::string(dword40, (const std::string *)v112);
v12 = this->dword40;
}
else
{
v12 = 0;
}
this->dword40 = v12 + 4;
}
dword104 = (HDDMDevice *)this->dword104;
if ( !dword104 )
goto LABEL_105;
s2 = v112[0];
v14 = *((_DWORD *)v112[0] - 3);
v88 = (HDDMDevice *)&this->char100;
do
{
while ( 1 )
{
s1 = (_DWORD *)dword104->dword10;
v16 = *(s1 - 3);
n = v16;
if ( v14 <= v16 )
n = v14;
v18 = memcmp(s1, s2, n);
v19 = v16 - v14;
if ( !v18 )
v18 = v19;
if ( v18 < 0 )
break;
v88 = dword104;
dword104 = *(HDDMDevice **)&dword104->word8;
if ( !dword104 )
goto LABEL_27;
}
dword104 = (HDDMDevice *)dword104->dwordC;
}
while ( dword104 );
LABEL_27:
if ( &this->char100 == (char *)v88
|| (int)std::string::compare((std::string *)v112, (const std::string *)&v88->dword10) < 0 )
{
LABEL_105:
v111[0] = v112;
v82 = &v107;
v81 = (HDDMTileType **)v111;
std::_Rb_tree<std::string,std::pair<std::string const,unsigned short>,std::_Select1st<std::pair<std::string const,unsigned short>>,std::less<std::string>,std::allocator<std::pair<std::string const,unsigned short>>>::_M_emplace_hint_unique<std::piecewise_construct_t const&,std::tuple<std::string const&>,std::tuple<>>((int)&v104);
s2 = v112[0];
v20 = v104;
}
else
{
v20 = v88;
}
LOWORD(v20->dword14) = j;
std::string::_Rep::_M_dispose((char *)s2 - 12, v111);
++j;
}
}
v103 = v123;
std::vector<HDDMBelDef *>::reserve((int)&this->dword48, v123);
if ( v103 > 0 )
{
for ( k = 0; k != v103; ++k )
{
if ( (unsigned __int16)this->word20 <= k )
{
v21 = operator new(0x40u);
HDDMBelDef::HDDMBelDef((HDDMBelDef *)v21);
*(_DWORD *)v21 = &`vtable for'HDDMRbelDef + 2;
*(_BYTE *)(v21 + 8) |= 2u;
}
else
{
v21 = operator new(0x40u);
HDDMBelDef::HDDMBelDef((HDDMBelDef *)v21);
*(_DWORD *)v21 = &`vtable for'HDDMLbelDef + 2;
}
v111[0] = v21;
dword4C = (_DWORD *)this->dword4C;
if ( dword4C == (_DWORD *)this->dword50 )
{
std::vector<HDDMBelDef *>::_M_emplace_back_aux<HDDMBelDef * const&>((int)&this->dword48, (int)v111);
v21 = v111[0];
}
else
{
if ( dword4C )
{
*dword4C = v21;
v23 = this->dword4C;
v21 = v111[0];
}
else
{
v23 = 0;
}
this->dword4C = v23 + 4;
}
*(_WORD *)(v21 + 10) = (16 * k) | *(_WORD *)(v21 + 10) & 0xF;
(*(void (__cdecl **)(int, _BYTE *, HDDMDevice *, _DWORD, HDDMTileType **, char *))(*(_DWORD *)v21 + 16))(
v21,
v127,
this,
a3,
v81,
v82);
v100 = v111[0];
v96 = (HDDMTileType *)(v111[0] + 12);
dword134 = (HDDMDevice *)this->dword134;
if ( !dword134 )
goto LABEL_104;
v85 = *(_DWORD **)(v111[0] + 12);
v25 = *(v85 - 3);
v89 = (HDDMDevice *)&this->char130;
do
{
while ( 1 )
{
dword10 = (_DWORD *)dword134->dword10;
v27 = *(dword10 - 3);
v28 = v27;
if ( v25 <= v27 )
v28 = v25;
v29 = memcmp(dword10, v85, v28);
v30 = v27 - v25;
if ( !v29 )
v29 = v30;
if ( v29 < 0 )
break;
v89 = dword134;
dword134 = *(HDDMDevice **)&dword134->word8;
if ( !dword134 )
goto LABEL_48;
}
dword134 = (HDDMDevice *)dword134->dwordC;
}
while ( dword134 );
LABEL_48:
if ( &this->char130 == (char *)v89 || (int)std::string::compare(v96, (const std::string *)&v89->dword10) < 0 )
{
LABEL_104:
v112[0] = v96;
v82 = &v108;
v81 = v112;
std::_Rb_tree<std::string,std::pair<std::string const,HDDMBelDef *>,std::_Select1st<std::pair<std::string const,HDDMBelDef *>>,std::less<std::string>,std::allocator<std::pair<std::string const,HDDMBelDef *>>>::_M_emplace_hint_unique<std::piecewise_construct_t const&,std::tuple<std::string const&>,std::tuple<>>((int)&v104);
v32 = v111[0];
v31 = v104;
}
else
{
v31 = v89;
v32 = v100;
}
v31->dword14 = v32;
}
}
v101 = v124;
std::vector<HDDMSiteType *>::reserve((int)&this->dword54, v124);
if ( v101 > 0 )
{
for ( m = 0; m != v101; ++m )
{
v33 = (HDDMTileType *)operator new(0xC0u);
HDDMSiteType::HDDMSiteType(v33);
v112[0] = v33;
dword58 = (HDDMTileType **)this->dword58;
if ( dword58 == (HDDMTileType **)this->dword5C )
{
std::vector<HDDMSiteType *>::_M_emplace_back_aux<HDDMSiteType * const&>((int)&this->dword54, (int)v112);
v33 = v112[0];
}
else
{
if ( dword58 )
{
*dword58 = v33;
v35 = this->dword58;
v33 = v112[0];
}
else
{
v35 = 0;
}
this->dword58 = v35 + 4;
}
*((_WORD *)v33 + 5) = ((_WORD)m << 6) | *((_WORD *)v33 + 5) & 0x3F;
HDDMSiteType::readme_pb(v33, (std::istream *)v127, this);
std::string::string((std::string *)v109, (HDDMTileType *)((char *)v112[0] + 24));
v97 = &this->char148;
dword14C = (HDDMTileType **)this->dword14C;
if ( !dword14C )
goto LABEL_98;
v86 = (char *)v109[0];
v37 = *(_DWORD *)(v109[0] - 12);
v90 = (HDDMTileType **)&this->char148;
do
{
while ( 1 )
{
v38 = dword14C[4];
v39 = *((_DWORD *)v38 - 3);
v40 = v37;
if ( v39 <= v37 )
v40 = *((_DWORD *)v38 - 3);
v41 = memcmp(v38, v86, v40);
v42 = v39 - v37;
if ( !v41 )
v41 = v42;
if ( v41 < 0 )
break;
v90 = dword14C;
dword14C = (HDDMTileType **)dword14C[2];
if ( !dword14C )
goto LABEL_67;
}
dword14C = (HDDMTileType **)dword14C[3];
}
while ( dword14C );
LABEL_67:
if ( v97 == (char *)v90 || (int)std::string::compare((std::string *)v109, (const std::string *)(v90 + 4)) < 0 )
{
LABEL_98:
v59 = (HDDMTileType **)operator new(0x18u);
v90 = v59;
if ( v59 )
{
*v59 = 0;
v59[1] = 0;
v59[2] = 0;
v59[3] = 0;
v59[4] = (HDDMTileType *)v109[0];
v109[0] = (char *)&std::string::_Rep::_S_empty_rep_storage + 12;
v59[5] = 0;
}
std::_Rb_tree<std::string,std::pair<std::string const,HDDMSiteType *>,std::_Select1st<std::pair<std::string const,HDDMSiteType *>>,std::less<std::string>,std::allocator<std::pair<std::string const,HDDMSiteType *>>>::_M_get_insert_hint_unique_pos((int)&v105);
v60 = v105;
v61 = v106;
if ( v106 )
{
v62 = 1;
if ( !v105 && v97 != (char *)v106 )
{
v70 = v90[4];
v71 = *((_DWORD *)v70 - 3);
v72 = *(_DWORD **)(v106 + 16);
v73 = *(v72 - 3);
v74 = v71;
if ( v73 <= v71 )
v74 = *(v72 - 3);
v75 = memcmp(v70, v72, v74);
v76 = v71 - v73;
if ( !v75 )
v75 = v76;
v62 = v75 >> 31;
}
std::_Rb_tree_insert_and_rebalance(v62, v90, v61, v97);
++this->dword158;
}
else
{
std::string::_Rep::_M_dispose((char *)v90[4] - 12, v111);
operator delete(v90);
v90 = v60;
}
v43 = (char *)v109[0];
}
else
{
v43 = v86;
}
v90[5] = v112[0];
std::string::_Rep::_M_dispose(v43 - 12, v111);
}
}
v102 = v125;
std::vector<HDDMTileType *>::reserve((int)&this->dword60, v125);
if ( v102 > 0 )
{
for ( ii = 0; ii != (std::string *)v102; ii = (std::string *)((char *)ii + 1) )
{
v44 = (HDDMTileType *)operator new(0x160u);
HDDMTileType::HDDMTileType(v44);
v112[0] = v44;
dword64 = (HDDMTileType **)this->dword64;
if ( dword64 == (HDDMTileType **)this->dword68 )
{
std::vector<HDDMTileType *>::_M_emplace_back_aux<HDDMTileType * const&>((int)&this->dword60, (int)v112);
v44 = v112[0];
}
else
{
if ( dword64 )
{
*dword64 = v44;
v46 = this->dword64;
v44 = v112[0];
}
else
{
v46 = 0;
}
this->dword64 = v46 + 4;
}
HDDMTileType::readme_pb(v44, (std::istream *)v127, this, a3);
HDDMTileType::getName((HDDMTileType *)v110);
v95 = &this->char118;
dword11C = (HDDMTileType **)this->dword11C;
if ( !dword11C )
goto LABEL_92;
v87 = (char *)v110[0];
v48 = *(_DWORD *)(v110[0] - 12);
v91 = (HDDMTileType **)&this->char118;
do
{
while ( 1 )
{
v49 = dword11C[4];
v50 = *((_DWORD *)v49 - 3);
v51 = v48;
if ( v50 <= v48 )
v51 = *((_DWORD *)v49 - 3);
v52 = memcmp(v49, v87, v51);
v53 = v50 - v48;
if ( !v52 )
v52 = v53;
if ( v52 < 0 )
break;
v91 = dword11C;
dword11C = (HDDMTileType **)dword11C[2];
if ( !dword11C )
goto LABEL_86;
}
dword11C = (HDDMTileType **)dword11C[3];
}
while ( dword11C );
LABEL_86:
if ( v91 == (HDDMTileType **)v95
|| (int)std::string::compare((std::string *)v110, (const std::string *)(v91 + 4)) < 0 )
{
LABEL_92:
v55 = (HDDMTileType **)operator new(0x18u);
v91 = v55;
if ( v55 )
{
*v55 = 0;
v55[1] = 0;
v55[2] = 0;
v55[3] = 0;
v55[4] = (HDDMTileType *)v110[0];
v110[0] = (char *)&std::string::_Rep::_S_empty_rep_storage + 12;
v55[5] = 0;
}
std::_Rb_tree<std::string,std::pair<std::string const,HDDMTileType *>,std::_Select1st<std::pair<std::string const,HDDMTileType *>>,std::less<std::string>,std::allocator<std::pair<std::string const,HDDMTileType *>>>::_M_get_insert_hint_unique_pos((int)&v105);
v56 = v105;
v57 = v106;
if ( v106 )
{
v58 = 1;
if ( !v105 && v95 != (char *)v106 )
{
v63 = v91[4];
v64 = *((_DWORD *)v63 - 3);
v65 = *(_DWORD **)(v106 + 16);
v66 = *(v65 - 3);
v67 = v64;
if ( v66 <= v64 )
v67 = *(v65 - 3);
v68 = memcmp(v63, v65, v67);
v69 = v64 - v66;
if ( !v68 )
v68 = v69;
v58 = v68 >> 31;
}
std::_Rb_tree_insert_and_rebalance(v58, v91, v57, v95);
++this->dword128;
}
else
{
std::string::_Rep::_M_dispose((char *)v91[4] - 12, v111);
operator delete(v91);
v91 = v56;
}
v54 = (char *)v110[0];
}
else
{
v54 = v87;
}
v91[5] = v112[0];
std::string::_Rep::_M_dispose(v54 - 12, v111);
}
}
HDDMXng::Architecture::~Architecture((HDDMXng::Architecture *)v114);
isl::iostreams::filtering_stream<boost::iostreams::input,char,std::char_traits<char>,std::allocator<char>,boost::iostreams::public_>::~filtering_stream((int)v126);
}
最新发布