int __thiscall sub_531270(void *this, int a2)
{
int v2; // ebx@1
void *v3; // ebp@1
int v4; // eax@2
int v5; // eax@2
int v6; // eax@2
int v7; // eax@3
int v8; // esi@3
int v9; // eax@3
int v10; // edx@11
char v11; // al@11
int v12; // eax@12
int v13; // edx@12
int v14; // eax@12
int v15; // eax@12
int v16; // eax@13
char v17; // cf@13
const CHAR *v18; // esi@14
int v19; // eax@16
int v20; // eax@16
char v21; // cf@16
int v22; // eax@17
int v23; // edx@19
int v24; // eax@19
int v25; // eax@19
int v26; // eax@20
int v27; // edx@20
int v28; // eax@20
int v29; // eax@20
int v30; // eax@22
int v31; // eax@22
int v32; // eax@22
int v33; // eax@24
int v34; // eax@24
int v35; // eax@24
int v36; // eax@26
int v37; // eax@26
int v38; // eax@26
int v39; // esi@27
int v40; // edi@28
int v41; // esi@28
int v42; // eax@34
int v43; // edx@35
int v44; // eax@35
int v45; // eax@35
int v46; // edx@36
int v47; // eax@36
int v48; // eax@36
int v49; // edx@37
int v50; // edx@37
int v51; // eax@37
int v52; // eax@37
int v53; // edx@38
int v54; // edx@38
int v55; // eax@38
int v56; // eax@38
int v57; // eax@39
int v58; // edx@39
int v59; // eax@39
int v60; // eax@39
int v61; // edx@41
int v62; // eax@41
int v63; // eax@41
unsigned __int8 v64; // bl@43
int v65; // edi@43
int v66; // esi@43
int v67; // edx@45
int v68; // eax@47
int v69; // eax@48
int v70; // eax@48
int v71; // eax@48
int v72; // eax@50
int v73; // eax@50
int v74; // eax@50
int v75; // edx@51
int v76; // eax@51
int v77; // eax@51
int v78; // eax@51
char v80; // [sp-988h] [bp-2C2Ch]@26
int v81; // [sp-10h] [bp-22B4h]@37
int v82; // [sp-Ch] [bp-22B0h]@35
int v83; // [sp-8h] [bp-22ACh]@2
int v84; // [sp-4h] [bp-22A8h]@2
char v85; // [sp+10h] [bp-2294h]@1
unsigned __int8 v86; // [sp+12h] [bp-2292h]@2
char v87; // [sp+13h] [bp-2291h]@7
int TargetValue; // [sp+14h] [bp-2290h]@21
char v89[4]; // [sp+18h] [bp-228Ch]@27
int v90; // [sp+1Ch] [bp-2288h]@27
int v91; // [sp+20h] [bp-2284h]@28
int v92; // [sp+24h] [bp-2280h]@27
int v93; // [sp+28h] [bp-227Ch]@1
int v94; // [sp+2Ch] [bp-2278h]@28
int v95; // [sp+30h] [bp-2274h]@27
char v96[4]; // [sp+34h] [bp-2270h]@42
char v97[4]; // [sp+38h] [bp-226Ch]@27
int v98; // [sp+3Ch] [bp-2268h]@27
char v99[4]; // [sp+40h] [bp-2264h]@42
int v100; // [sp+44h] [bp-2260h]@42
char v101; // [sp+48h] [bp-225Ch]@13
char v102; // [sp+64h] [bp-2240h]@13
int (__thiscall **v103)(void *, char); // [sp+B8h] [bp-21ECh]@19
int v104; // [sp+ECh] [bp-21B8h]@2
int v105; // [sp+8F4h] [bp-19B0h]@16
int v106; // [sp+18F8h] [bp-9ACh]@11
char v107; // [sp+18FCh] [bp-9A8h]@11
SQLUSMALLINT ipar[2]; // [sp+2284h] [bp-20h]@11
int v109; // [sp+2288h] [bp-1Ch]@11
unsigned int v110; // [sp+2294h] [bp-10h]@1
int v111; // [sp+22A0h] [bp-4h]@11
v2 = 0;
v3 = this;
v110 = (unsigned int)&v85 ^ dword_644EEC;
v93 = 0;
if ( *((_DWORD *)this + 294) )
{
v84 = *((_DWORD *)this + 294);
v4 = *(_DWORD *)this;
v83 = (int)"[E_RECYCLE] INIT Error (%d)";
v5 = (*(int (**)(void))(v4 + 44))();
v6 = sub_4013A0((int)&v104, 1, v5, "[E_RECYCLE] INIT Error (%d)", v84);
sub_401850(&v86, v6);
}
else
{
v9 = (*(int (**)(void))(*(_DWORD *)this + 44))();
v7 = sub_4F9DA0(v9);
v8 = v7;
if ( v7 )
{
if ( (unsigned __int8)sub_531D40(v7) )
{
v87 = 0;
if ( (unsigned __int8)sub_531DA0(*(_DWORD *)(v8 + 12), &v87) )
{
if ( v87 == 1 )
{
*((_DWORD *)v3 + 294) = 32;
}
else
{
v106 = sub_40CE60(dword_666324);
sub_403530(&v107);
ipar[0] = 0;
v109 = -1;
v10 = *(_DWORD *)v3;
v111 = 0;
v11 = (*(int (__thiscall **)(void *))(v10 + 44))(v3);
if ( (unsigned __int8)sub_404720((int)&v106, "dbo.USP_ITEM_RECYCLE (%d, ?)", v11) )
{
sub_41F290(3, 1);
LOBYTE(v111) = 2;
sub_531F30(&v102);
v16 = sub_4209B0(&v101);
v17 = *(_DWORD *)(v16 + 24) < 0x10u;
LOBYTE(v111) = 3;
if ( v17 )
v18 = (const CHAR *)(v16 + 4);
else
v18 = *(const CHAR **)(v16 + 4);
v20 = lstrlenA(v18);
sub_531CB0(v18, v20);
++ipar[0];
sub_404110(ipar[0], 1, 12, (int)&v105);
LOBYTE(v111) = 2;
sub_408C20(&v101);
v19 = sub_4209B0(&v101);
v21 = *(_DWORD *)(v19 + 24) < 0x10u;
LOBYTE(v111) = 4;
if ( v21 )
v22 = v19 + 4;
else
v22 = *(_DWORD *)(v19 + 4);
v23 = *(_DWORD *)v3;
v84 = v22;
v83 = (int)"[N_RECYCLE] XML : %s";
v24 = (*(int (__thiscall **)(void *))(v23 + 44))(v3);
v25 = sub_4013A0((int)&v104, 1, v24, "[N_RECYCLE] XML : %s", v84);
sub_401850(&v86, v25);
sub_408C20(&v101);
LOBYTE(v111) = 0;
sub_41CF70(&v103);
v103 = &off_5E8140;
std__ios_base___ios_base(&v103);
if ( (unsigned __int8)sub_4042F0(&v107) )
{
TargetValue = 0;
sub_404010(1u, -16, &TargetValue, 4);
if ( (unsigned __int16)sub_404340(&v107) )
{
v84 = sub_403620(&v107);
v30 = *(_DWORD *)v3;
v83 = (int)"[E_RECYCLE] DB : Query spHelper Fetch Failed : QUERY(%s)";
v31 = (*(int (__thiscall **)(void *))(v30 + 44))(v3);
v32 = sub_4013A0((int)&v104, 1, v31, "[E_RECYCLE] DB : Query spHelper Fetch Failed : QUERY(%s)", v84);
sub_401850(&v86, v32);
*((_DWORD *)v3 + 294) = 1002;
v111 = 6;
}
else
{
if ( TargetValue )
{
sub_4035E0(&v107);
if ( (unsigned __int16)sub_404380(&v107) )
{
v36 = *(_DWORD *)v3;
memcpy(&v80, &v107, 0x988u);
v37 = (*(int (__thiscall **)(void *))(v36 + 44))(v3);
v38 = sub_4013A0(
(int)&v104,
1,
v37,
"[E_RECYCLE] Query spHelper Next ResultSet Failed : QUERY(%s)",
v80);
sub_401850(&v86, v38);
*((_DWORD *)v3 + 294) = 1003;
v111 = 8;
}
else
{
*(_DWORD *)v89 = 0;
v95 = 0;
*(_DWORD *)v97 = 0;
v98 = 0;
v92 = 0;
v90 = 0;
sub_404010(1u, -16, v89, 4);
sub_404010(2u, -16, &v95, 4);
sub_404010(3u, -25, v97, 8);
sub_404010(4u, -16, &v92, 4);
sub_404010(5u, -15, &v90, 2);
v39 = 0;
TargetValue = 0;
if ( (unsigned __int16)sub_404340(&v107) )
{
LABEL_34:
v42 = *((_DWORD *)v3 + 299);
if ( v39 == v42 )
{
sub_4035E0(&v107);
if ( (unsigned __int16)sub_404380(&v107) )
{
v61 = *(_DWORD *)v3;
memcpy(&v80, &v107, 0x988u);
v62 = (*(int (__thiscall **)(void *))(v61 + 44))(v3);
v63 = sub_4013A0(
(int)&v104,
1,
v62,
"[E_RECYCLE] Query spHelper Next ResultSet Failed : QUERY(%s)",
v80);
sub_401850(&v86, v63);
*((_DWORD *)v3 + 294) = 1003;
v111 = 14;
}
else
{
*(_DWORD *)v96 = 0;
*(_DWORD *)v99 = 0;
v100 = 0;
v91 = 0;
v94 = 0;
sub_404010(1u, -16, v96, 4);
sub_404010(2u, -25, v99, 8);
sub_404010(3u, -16, &v91, 4);
sub_404010(4u, -15, &v94, 2);
TargetValue = 0;
if ( (unsigned __int16)sub_404340(&v107) )
{
LABEL_47:
v68 = *((_DWORD *)v3 + 302);
if ( v2 == v68 )
{
*((_DWORD *)v3 + 294) = 1;
v111 = 18;
sub_403550(&v107);
v111 = -1;
sub_403940(&v107);
return sub_5B35EF();
}
v84 = v2;
v83 = v68;
v69 = *(_DWORD *)v3;
v82 = (int)"[E_RECYCLE] Different Product Count(%d != %d)";
v70 = (*(int (__thiscall **)(void *))(v69 + 44))(v3);
v71 = sub_4013A0((int)&v105, 1, v70, "[E_RECYCLE] Different Product Count(%d != %d)", v83);
sub_401850(&v86, v71);
*((_DWORD *)v3 + 294) = 43;
v111 = 17;
}
else
{
while ( 1 )
{
v66 = *(_DWORD *)v99;
v64 = v94;
v65 = *(_DWORD *)v96;
v93 = *(_DWORD *)v96;
v92 = v91;
sub_531CF0(&v90, &v93);
if ( *((_DWORD *)v3 + 301) == v90 )
{
v72 = *(_DWORD *)v3;
v84 = v65;
v83 = v66;
v82 = (int)"[E_RECYCLE] Not Found Product Item(%d,%d)";
v73 = (*(int (__thiscall **)(void *))(v72 + 44))(v3);
v74 = sub_4013A0((int)&v104, 1, v73, "[E_RECYCLE] Not Found Product Item(%d,%d)", v66);
sub_401850(&v86, v74);
*((_DWORD *)v3 + 294) = 40;
v111 = 15;
goto LABEL_49;
}
if ( *(_BYTE *)(v90 + 32) != v64 )
break;
v67 = v92;
++TargetValue;
*(_DWORD *)(v90 + 24) = v66;
*(_DWORD *)(v90 + 28) = v67;
if ( (unsigned __int16)sub_404340(&v107) )
{
v2 = TargetValue;
goto LABEL_47;
}
}
v75 = *(_BYTE *)(v90 + 32);
v76 = *(_DWORD *)v3;
v84 = v64;
v83 = v75;
v82 = v65;
v81 = (int)"[E_RECYCLE] Different Product Item - PARTS(%d, %d != %d)";
v77 = (*(int (__thiscall **)(void *))(v76 + 44))(v3);
v78 = sub_4013A0(
(int)&v104,
1,
v77,
"[E_RECYCLE] Different Product Item - PARTS(%d, %d != %d)",
v65);
sub_401850(&v86, v78);
*((_DWORD *)v3 + 294) = 42;
v111 = 16;
}
}
}
else
{
v43 = *(_DWORD *)v3;
v84 = v39;
v83 = v42;
v82 = (int)"[E_RECYCLE] Different Material Count(%d != %d)";
v44 = (*(int (__thiscall **)(void *))(v43 + 44))(v3);
v45 = sub_4013A0((int)&v104, 1, v44, "[E_RECYCLE] Different Material Count(%d != %d)", v83);
sub_401850(&v86, v45);
*((_DWORD *)v3 + 294) = 39;
v111 = 13;
}
}
else
{
while ( 1 )
{
v41 = v95;
v40 = *(_DWORD *)v97;
v91 = v92;
v86 = v90;
v94 = *(_DWORD *)v89;
sub_531CF0(&v93, &v94);
if ( *((_DWORD *)v3 + 298) == v93 )
{
v46 = *(_DWORD *)v3;
v84 = v41;
v83 = v40;
v82 = (int)"[E_RECYCLE] Not Found Material Item(%d,%d)";
v47 = (*(int (__thiscall **)(void *))(v46 + 44))(v3);
v48 = sub_4013A0((int)&v104, 1, v47, "[E_RECYCLE] Not Found Material Item(%d,%d)", v40);
sub_401850(&v86, v48);
*((_DWORD *)v3 + 294) = 34;
v111 = 9;
goto LABEL_49;
}
if ( *(_DWORD *)(v93 + 20) != v41 )
{
v49 = *(_DWORD *)(v93 + 20);
v84 = v41;
v83 = v49;
v50 = *(_DWORD *)v3;
v82 = *(_DWORD *)v89;
v81 = (int)"[E_RECYCLE] Different Material Item - TID(%d, %d != %d)";
v51 = (*(int (__thiscall **)(void *))(v50 + 44))(v3);
v52 = sub_4013A0(
(int)&v104,
1,
v51,
"[E_RECYCLE] Different Material Item - TID(%d, %d != %d)",
v82);
sub_401850(&v86, v52);
*((_DWORD *)v3 + 294) = 35;
v111 = 10;
goto LABEL_49;
}
if ( *(_DWORD *)(v93 + 24) != v40 )
{
v53 = *(_DWORD *)(v93 + 24);
v84 = v40;
v83 = v53;
v54 = *(_DWORD *)v3;
v82 = *(_DWORD *)v89;
v81 = (int)"[E_RECYCLE] Different Material Item - ITEMID(%d, %d != %d)";
v55 = (*(int (__thiscall **)(void *))(v54 + 44))(v3);
v56 = sub_4013A0(
(int)&v104,
1,
v55,
"[E_RECYCLE] Different Material Item - ITEMID(%d, %d != %d)",
v82);
sub_401850(&v86, v56);
*((_DWORD *)v3 + 294) = 36;
v111 = 11;
goto LABEL_49;
}
if ( *(_BYTE *)(v93 + 32) != v86 )
break;
++TargetValue;
*(_DWORD *)(v93 + 28) = v91;
if ( (unsigned __int16)sub_404340(&v107) )
{
v39 = TargetValue;
goto LABEL_34;
}
}
v57 = *(_BYTE *)(v93 + 32);
v84 = v86;
v58 = *(_DWORD *)v3;
v83 = v57;
v82 = *(_DWORD *)v89;
v81 = (int)"[E_RECYCLE] Different Material Item - COUND(%d, %d != %d)";
v59 = (*(int (__thiscall **)(void *))(v58 + 44))(v3);
v60 = sub_4013A0(
(int)&v104,
1,
v59,
"[E_RECYCLE] Different Material Item - COUND(%d, %d != %d)",
v82);
sub_401850(&v86, v60);
*((_DWORD *)v3 + 294) = 38;
v111 = 12;
}
}
}
else
{
v33 = *(_DWORD *)v3;
v84 = 0;
v83 = (int)"[E_RECYCLE] RETURN : ERROR(%s)";
v34 = (*(int (__thiscall **)(void *))(v33 + 44))(v3);
v35 = sub_4013A0((int)&v104, 1, v34, "[E_RECYCLE] RETURN : ERROR(%s)", 0);
sub_401850(&v86, v35);
*((_DWORD *)v3 + 294) = 33;
v111 = 7;
}
}
}
else
{
v26 = sub_403620(&v107);
v27 = *(_DWORD *)v3;
v84 = v26;
v83 = (int)"[E_RECYCLE] DB : Query spHelper Execute Failed : QUERY(%s)";
v28 = (*(int (__thiscall **)(void *))(v27 + 44))(v3);
v29 = sub_4013A0((int)&v104, 1, v28, "[E_RECYCLE] DB : Query spHelper Execute Failed : QUERY(%s)", v84);
sub_401850(&v86, v29);
*((_DWORD *)v3 + 294) = 1001;
v111 = 5;
}
LABEL_49:
sub_403550(&v107);
v111 = -1;
sub_403940(&v107);
}
else
{
v12 = sub_403620(&v107);
v13 = *(_DWORD *)v3;
v84 = v12;
v83 = (int)"[E_RECYCLE] DB : Query spHelper Prepare Failed : QUERY(%s)";
v14 = (*(int (__thiscall **)(void *))(v13 + 44))(v3);
v15 = sub_4013A0((int)&v104, 1, v14, "[E_RECYCLE] DB : Query spHelper Prepare Failed : QUERY(%s)", v84);
sub_401850(&v86, v15);
*((_DWORD *)v3 + 294) = 1000;
v111 = 1;
sub_403550(&v107);
v111 = -1;
sub_403940(&v107);
}
}
}
else
{
*((_DWORD *)v3 + 294) = 1001;
}
}
else
{
*((_DWORD *)v3 + 294) = 31;
}
}
else
{
*((_DWORD *)v3 + 294) = 30;
}
}
return sub_5B35EF();
}