original_code:
ULONG FILE_ThsMin5ToMin30( FILE_THS_MIN5_ENTRY_S *pstMin5, FILE_WHOLE_DATA_S *pstWhole)
{
    ULONG i,k;
    ULONG ulMaxPrice, ulMinPrice, ulMin30Vol;
    ULONG ulPrevMin;
    ULONG ulMin5Date;
    PRICE_S *pstMin30Price;
    ((void) sizeof ((((void *)0) != pstMin5) ? 1 : 0), __extension__ ({ if (((void *)0) != pstMin5) ; else __assert_fail ("NULL != pstMin5", "common/file.c", 237, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((((void *)0) != pstWhole) ? 1 : 0), __extension__ ({ if (((void *)0) != pstWhole) ; else __assert_fail ("NULL != pstWhole", "common/file.c", 238, __extension__ __PRETTY_FUNCTION__); }));
    ulMin5Date = FILE_ThsMin2Date(pstMin5->ulMin);
    ((void) sizeof ((ulMin5Date == pstWhole->ulDate) ? 1 : 0), __extension__ ({ if (ulMin5Date == pstWhole->ulDate) ; else __assert_fail ("ulMin5Date == pstWhole->ulDate", "common/file.c", 241, __extension__ __PRETTY_FUNCTION__); }));
    pstMin30Price=pstWhole->astMin30Price;
    ulPrevMin = pstMin5->ulMin;
    ulMaxPrice = 0;
    ulMinPrice = 0xFFFFFFFF;
    ulMin30Vol = 0;
    for (i=0,k=0;i<48;i++,pstMin5++) {
        if ((pstMin5->ulMin-ulPrevMin) > 720)
            break;
        k++;
        if (ulMaxPrice < pstMin5->ulHighWithCheck) {
            ulMaxPrice = pstMin5->ulHighWithCheck;
        }
        if (ulMinPrice > pstMin5->ulLowWithCheck) {
            ulMinPrice = pstMin5->ulLowWithCheck;
        }
        ulMin30Vol += FILE_GetVol(pstMin5->ulVolWithCheck);
        if (1 == k) {
            pstMin30Price->ulBegin = pstMin5->ulBeginWithCheck - (0xB0000000);
        }
        if (6 == k) {
            pstMin30Price->ulHigh = ulMaxPrice - (0xB0000000);
            pstMin30Price->ulLow = ulMinPrice - (0xB0000000);
            pstMin30Price->ulEnd = pstMin5->ulEndWithCheck - (0xB0000000);
            pstMin30Price->ulVol = ulMin30Vol+3;
            pstMin30Price->ulFlag = 0xCCCCCCCC;
            pstMin30Price++;
            ulMin30Vol = 0;
            k = 0;
            ulMaxPrice = 0;
            ulMinPrice = 0xFFFFFFFF;
        }
        ulPrevMin = pstMin5->ulMin;
    }
    return i;
}

canonical_original_code:
unsigned long FILE_ThsMin5ToMin30(struct tagFile5MinuteData *pstMin5, struct tagWholeData *pstWhole)
{
    unsigned long i; unsigned long k;
    unsigned long ulMaxPrice; unsigned long ulMinPrice; unsigned long ulMin30Vol;
    unsigned long ulPrevMin;
    unsigned long ulMin5Date;
    struct tagPrice *pstMin30Price;
    ((void) sizeof ((((void *)0) != pstMin5) ? 1 : 0), __extension__ ({ if (((void *)0) != pstMin5) ; else __assert_fail ("NULL != pstMin5", "common/file.c", 237, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((((void *)0) != pstWhole) ? 1 : 0), __extension__ ({ if (((void *)0) != pstWhole) ; else __assert_fail ("NULL != pstWhole", "common/file.c", 238, __extension__ __PRETTY_FUNCTION__); }));
    ulMin5Date = FILE_ThsMin2Date(pstMin5->ulMin);
    ((void) sizeof ((ulMin5Date == pstWhole->ulDate) ? 1 : 0), __extension__ ({ if (ulMin5Date == pstWhole->ulDate) ; else __assert_fail ("ulMin5Date == pstWhole->ulDate", "common/file.c", 241, __extension__ __PRETTY_FUNCTION__); }));
    pstMin30Price=pstWhole->astMin30Price;
    ulPrevMin = pstMin5->ulMin;
    ulMaxPrice = 0;
    ulMinPrice = 0xFFFFFFFF;
    ulMin30Vol = 0;
    for (i=0,k=0;i<48;i++,pstMin5++) {
        if ((pstMin5->ulMin-ulPrevMin) > 720)
            break;
        k++;
        if (ulMaxPrice < pstMin5->ulHighWithCheck) {
            ulMaxPrice = pstMin5->ulHighWithCheck;
        }
        if (ulMinPrice > pstMin5->ulLowWithCheck) {
            ulMinPrice = pstMin5->ulLowWithCheck;
        }
        ulMin30Vol += FILE_GetVol(pstMin5->ulVolWithCheck);
        if (1 == k) {
            pstMin30Price->ulBegin = pstMin5->ulBeginWithCheck - (0xB0000000);
        }
        if (6 == k) {
            pstMin30Price->ulHigh = ulMaxPrice - (0xB0000000);
            pstMin30Price->ulLow = ulMinPrice - (0xB0000000);
            pstMin30Price->ulEnd = pstMin5->ulEndWithCheck - (0xB0000000);
            pstMin30Price->ulVol = ulMin30Vol+3;
            pstMin30Price->ulFlag = 0xCCCCCCCC;
            pstMin30Price++;
            ulMin30Vol = 0;
            k = 0;
            ulMaxPrice = 0;
            ulMinPrice = 0xFFFFFFFF;
        }
        ulPrevMin = pstMin5->ulMin;
    }
    return i;
}

variable_types: struct tagFile5MinuteData { unsigned int ulMin; unsigned int ulBeginWithCheck; unsigned int ulHighWithCheck; unsigned int ulLowWithCheck; unsigned int ulEndWithCheck; unsigned int ulRsv; unsigned int ulVolWithCheck; unsigned char aucRsv[-1]; } *

variable_types: struct tagWholeData { char szComment[16]; unsigned int ulDate; unsigned int ulRsv; struct tagPrice { unsigned int ulBegin; unsigned int ulHigh; unsigned int ulLow; unsigned int ulEnd; unsigned int ulVol; unsigned int ulFlag; } stDailyPrice; struct tagPrice astMin30Price[8]; struct tagFactor { unsigned int ulFlag; float fMulti; float fAdder; } stFactor; unsigned int ulPad; } *

variable_types:
i
unsigned long

variable_types:
k
unsigned long

variable_types:
ulMaxPrice
unsigned long

variable_types:
ulMinPrice
unsigned long

variable_types:
ulPrevMin
unsigned long

variable_types: struct tagPrice { unsigned int ulBegin; unsigned int ulHigh; unsigned int ulLow; unsigned int ulEnd; unsigned int ulVol; unsigned int ulFlag; } *


repo: gitslime/StockAnalyser

decompiled_code:
__int64 __fastcall FILE_QlWeightToCustom(_DWORD *a1, __int64 a2)
{
unsigned int v2; // eax
int v3; // ecx
int v4; // edx
float v5; // xmm0_4
int v6; // eax
float v7; // xmm1_4
__int64 result; // rax

v2 = a1[4];
if ( !v2 )
{
v3 = a1[5];
v4 = a1[1];
v5 = 0.0;
v6 = a1[2];
if ( !(v6 | v4 | v3) )
return 0LL;
goto LABEL_3;
}
v3 = a1[5];
v4 = a1[1];
v5 = (float)(v2 / 0xA);
v6 = a1[2];
if ( v6 | v3 | v4 )
{
LABEL_3:
v7 = (float)(v6 + v4 + v3 + 100000) / 100000.0;
v5 = v5 - (float)(a1[3] * v6 / 0x186A0u);
goto LABEL_4;
}
v7 = *(float *)&LC31;
LABEL_4:
if ( *(_DWORD *)(a2 + 240) == -2004318072 )
{
if ( v7 != *(float *)(a2 + 244) )
_assert_fail("pstFactor->fMulti == fMultiTemp", "common/file.c", 0x14Bu, "FILE_QlWeightToCustom");
if ( v5 != *(float *)(a2 + 248) )
_assert_fail("pstFactor->fAdder == fAdderTemp", "common/file.c", 0x14Cu, "FILE_QlWeightToCustom");
result = 0LL;
}
else
{
*(_DWORD *)(a2 + 240) = -2004318072;
result = 1LL;
*(float *)(a2 + 244) = v7;
*(float *)(a2 + 248) = v5;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(_DWORD *a1, __int64 a2)
{
unsigned int v2; // eax
int v3; // ecx
int v4; // edx
float v5; // xmm0_4
int v6; // eax
float v7; // xmm1_4
__int64 result; // rax

v2 = a1[4];
if ( !v2 )
{
v3 = a1[5];
v4 = a1[1];
v5 = 0.0;
v6 = a1[2];
if ( !(v6 | v4 | v3) )
return 0LL;
goto LABEL_3;
}
v3 = a1[5];
v4 = a1[1];
v5 = (float)(v2 / 0xA);
v6 = a1[2];
if ( v6 | v3 | v4 )
{
LABEL_3:
v7 = (float)(v6 + v4 + v3 + 100000) / 100000.0;
v5 = v5 - (float)(a1[3] * v6 / 0x186A0u);
goto LABEL_4;
}
v7 = *(float *)&LC31;
LABEL_4:
if ( *(_DWORD *)(a2 + 240) == -2004318072 )
{
if ( v7 != *(float *)(a2 + 244) )
_assert_fail("pstFactor->fMulti == fMultiTemp", "common/file.c", 0x14Bu, "FILE_QlWeightToCustom");
if ( v5 != *(float *)(a2 + 248) )
_assert_fail("pstFactor->fAdder == fAdderTemp", "common/file.c", 0x14Cu, "FILE_QlWeightToCustom");
result = 0LL;
}
else
{
*(_DWORD *)(a2 + 240) = -2004318072;
result = 1LL;
*(float *)(a2 + 244) = v7;
*(float *)(a2 + 248) = v5;
}
return result;
}

original_code:
ULONG FILE_QlWeightToCustom( FILE_QL_WEIGHT_ENTRY_S *pstWeight, FILE_WHOLE_DATA_S *pstWhole)
{
    BOOL_T bVaild;
    FLOAT fMultiTemp, fAdderTemp;
    FACTOR_S *pstFactor = &(pstWhole->stFactor);
    bVaild = (0);
    fMultiTemp = 1;
    fAdderTemp = 0;
    if (0 != pstWeight->ulProfit) {
        fAdderTemp = (FLOAT)(pstWeight->ulProfit / 10);
        bVaild = (1);
    }
    if ((0 != pstWeight->ulAdd) || (0 != pstWeight->ulGift) || (0 != pstWeight->ulOffer)) {
        fMultiTemp = ((FLOAT)(pstWeight->ulAdd + pstWeight->ulGift + pstWeight->ulOffer + 100000) / 100000);
        fAdderTemp -= (FLOAT)(pstWeight->ulOffer * pstWeight->ulOfferPrice / 100000);
        bVaild = (1);
    }
    if ((0) == bVaild) {
        return 0;
    }
    if (0x88888888 == pstFactor->ulFlag) {
        ((void) sizeof ((pstFactor->fMulti == fMultiTemp) ? 1 : 0), __extension__ ({ if (pstFactor->fMulti == fMultiTemp) ; else __assert_fail ("pstFactor->fMulti == fMultiTemp", "common/file.c", 331, __extension__ __PRETTY_FUNCTION__); }));
        ((void) sizeof ((pstFactor->fAdder == fAdderTemp) ? 1 : 0), __extension__ ({ if (pstFactor->fAdder == fAdderTemp) ; else __assert_fail ("pstFactor->fAdder == fAdderTemp", "common/file.c", 332, __extension__ __PRETTY_FUNCTION__); }));
        return 0;
    }
    pstFactor->fMulti = fMultiTemp;
    pstFactor->fAdder = fAdderTemp;
    pstFactor->ulFlag = 0x88888888;
    return 1;
}

canonical_original_code:
unsigned long FILE_QlWeightToCustom(struct tagFileWeight *pstWeight, struct tagWholeData *pstWhole)
{
    unsigned short bVaild;
    float fMultiTemp; float fAdderTemp;
    struct tagFactor *pstFactor = &(pstWhole->stFactor);
    bVaild = (0);
    fMultiTemp = 1;
    fAdderTemp = 0;
    if (0 != pstWeight->ulProfit) {
        fAdderTemp = (FLOAT)(pstWeight->ulProfit / 10);
        bVaild = (1);
    }
    if ((0 != pstWeight->ulAdd) || (0 != pstWeight->ulGift) || (0 != pstWeight->ulOffer)) {
        fMultiTemp = ((FLOAT)(pstWeight->ulAdd + pstWeight->ulGift + pstWeight->ulOffer + 100000) / 100000);
        fAdderTemp -= (FLOAT)(pstWeight->ulOffer * pstWeight->ulOfferPrice / 100000);
        bVaild = (1);
    }
    if ((0) == bVaild) {
        return 0;
    }
    if (0x88888888 == pstFactor->ulFlag) {
        ((void) sizeof ((pstFactor->fMulti == fMultiTemp) ? 1 : 0), __extension__ ({ if (pstFactor->fMulti == fMultiTemp) ; else __assert_fail ("pstFactor->fMulti == fMultiTemp", "common/file.c", 331, __extension__ __PRETTY_FUNCTION__); }));
        ((void) sizeof ((pstFactor->fAdder == fAdderTemp) ? 1 : 0), __extension__ ({ if (pstFactor->fAdder == fAdderTemp) ; else __assert_fail ("pstFactor->fAdder == fAdderTemp", "common/file.c", 332, __extension__ __PRETTY_FUNCTION__); }));
        return 0;
    }
    pstFactor->fMulti = fMultiTemp;
    pstFactor->fAdder = fAdderTemp;
    pstFactor->ulFlag = 0x88888888;
    return 1;
}

variable_types: struct tagFileWeight { unsigned int ulQlDate; unsigned int ulGift; unsigned int ulOffer; unsigned int ulOfferPrice; unsigned int ulProfit; unsigned int ulAdd; unsigned int ulTotalStock; unsigned int ulCirStock; unsigned int ulRsv; } *

variable_types:
bVaild
unsigned short

variable_types: fMultiTemp float

variable_types: fAdderTemp float

variable_types: struct tagFactor { unsigned int ulFlag; float fMulti; float fAdder; } *

return_type: unsigned long

user_defined_types: struct tagWholeData { char szComment[16]; unsigned int ulDate; unsigned int ulRsv; struct tagPrice stDailyPrice; struct tagPrice astMin30Price[8]; struct tagFactor stFactor; unsigned int ulPad; }

user_defined_types: struct tagPrice { unsigned int ulBegin; unsigned int ulHigh; unsigned int ulLow; unsigned int ulEnd; unsigned int ulVol; unsigned int ulFlag; }


decompiled_code:
__int64 __fastcall FILE_QlDate2Custom(unsigned __int64 a1)
{
return ((unsigned __int16)a1 >> 11) + 10000LL * ((unsigned int)a1 >> 20) + 100 * ((a1 >> 16) & 0xF);
}

original_code:
ULONG FILE_QlDate2Custom( ULONG ulWeightDate)
{
    ULONG ulYear = (((ulWeightDate) & 0xFFF00000) >> 20);
    ULONG ulMonth = (((ulWeightDate) & 0x000F0000) >> 16);
    ULONG ulDay = (((ulWeightDate) & 0x0000F800) >> 11);
    return ((ulYear * 10000) + (ulMonth * 100) + ulDay);
}

canonical_original_code:
unsigned long FILE_QlDate2Custom(unsigned long ulWeightDate)
{
    unsigned long ulYear = (((ulWeightDate) & 0xFFF00000) >> 20);
    unsigned long ulMonth = (((ulWeightDate) & 0x000F0000) >> 16);
    unsigned long ulDay = (((ulWeightDate) & 0x0000F800) >> 11);
    return ((ulYear * 10000) + (ulMonth * 100) + ulDay);
}

variable_types:
ulWeightDate
unsigned long

variable_types:
ulYear
unsigned long

variable_types:
ulMonth
unsigned long

variable_types:
ulDay
unsigned long


decompiled_code:
int __fastcall CHOOSE_Track(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 v5; // rax
__int64 v6; // rbx
char *v7; // r14
__int64 v8; // rbx
unsigned __int64 v9; // r8
unsigned __int64 v10; // r9
void *ptr; // [rsp+8h] [rbp-A0h] BYREF
__int128 v13; // [rsp+10h] [rbp-98h] BYREF
__int64 v14; // [rsp+20h] [rbp-88h]
int v15; // [rsp+28h] [rbp-80h]
__int64 v16[15]; // [rsp+30h] [rbp-78h] BYREF

ptr = 0LL;
v5 = FILE_GetFileData(a1, a3, 4026531840LL, &ptr);
if ( v5 )
{
v6 = v5;
if ( GetIndexByDate(a2, 0LL, v5, ptr) == 0xFFFFFFFFLL )
{
free(ptr);
LODWORD(v5) = DebugOutString("invalid date=%lu, code=%06lu\n", a2, a1);
}
else
{
v7 = (char *)ptr + 256 * v6 - 256;
v8 = *((unsigned int *)v7 + 9);
METHOD_GetFuncSet(a4, v16);
((void (__fastcall *)(_QWORD, _QWORD))v16[6])(0LL, 0LL);
v13 = 0LL;
v14 = 0LL;
v15 = 0;
DWORD2(v13) = a2;
LODWORD(v13) = ((__int64 (__fastcall *)(char *, __int128 *))v16[0])(v7, &v13);
DWORD1(v13) = ((__int64 (__fastcall *)(char *, __int128 *))v16[1])(v7, &v13);
free(ptr);
v9 = 1LL;
if ( (unsigned int)v13 > (unsigned __int64)(v8 + 10) )
v9 = ((unsigned __int64)(unsigned int)v13 - v8) / 0xA;
v10 = 1LL;
if ( (unsigned int)v8 > DWORD1(v13) + 10 )
v10 = (v8 - (unsigned __int64)DWORD1(v13)) / 0xA;
LODWORD(v5) = printf(
"%06lu,%lu,%.2f,%.2f,%lu,%.2f,%lu\n",
a1,
DWORD2(v13),
(float)((float)(int)v8 / 1000.0),
(float)((float)SDWORD1(v13) / 1000.0),
v10,
(float)((float)(int)v13 / 1000.0),
v9);
}
}
return v5;
}

canonical_decompiled_code:
int __fastcall func0(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 v5; // rax
__int64 v6; // rbx
char *v7; // r14
__int64 v8; // rbx
unsigned __int64 v9; // r8
unsigned __int64 v10; // r9
void *ptr; // [rsp+8h] [rbp-A0h] BYREF
__int128 v13; // [rsp+10h] [rbp-98h] BYREF
__int64 v14; // [rsp+20h] [rbp-88h]
int v15; // [rsp+28h] [rbp-80h]
__int64 v16[15]; // [rsp+30h] [rbp-78h] BYREF

ptr = 0LL;
v5 = FILE_GetFileData(a1, a3, 4026531840LL, &ptr);
if ( v5 )
{
v6 = v5;
if ( GetIndexByDate(a2, 0LL, v5, ptr) == 0xFFFFFFFFLL )
{
free(ptr);
LODWORD(v5) = DebugOutString("invalid date=%lu, code=%06lu\n", a2, a1);
}
else
{
v7 = (char *)ptr + 256 * v6 - 256;
v8 = *((unsigned int *)v7 + 9);
METHOD_GetFuncSet(a4, v16);
((void (__fastcall *)(_QWORD, _QWORD))v16[6])(0LL, 0LL);
v13 = 0LL;
v14 = 0LL;
v15 = 0;
DWORD2(v13) = a2;
LODWORD(v13) = ((__int64 (__fastcall *)(char *, __int128 *))v16[0])(v7, &v13);
DWORD1(v13) = ((__int64 (__fastcall *)(char *, __int128 *))v16[1])(v7, &v13);
free(ptr);
v9 = 1LL;
if ( (unsigned int)v13 > (unsigned __int64)(v8 + 10) )
v9 = ((unsigned __int64)(unsigned int)v13 - v8) / 0xA;
v10 = 1LL;
if ( (unsigned int)v8 > DWORD1(v13) + 10 )
v10 = (v8 - (unsigned __int64)DWORD1(v13)) / 0xA;
LODWORD(v5) = printf(
"%06lu,%lu,%.2f,%.2f,%lu,%.2f,%lu\n",
a1,
DWORD2(v13),
(float)((float)(int)v8 / 1000.0),
(float)((float)SDWORD1(v13) / 1000.0),
v10,
(float)((float)(int)v13 / 1000.0),
v9);
}
}
return v5;
}

original_code:
VOID CHOOSE_Track( ULONG ulCode, ULONG ulDate, CHAR * szDir, ULONG ulMethod)
{
    ULONG ulEntryCnt;
    ULONG ulIndex;
    ULONG ulLatestEndPrice;
    ULONG ulGainPriceDiff, ulLossPriceDiff;
    METHOD_FUNC_SET_S stMethodFunc;
    STOCK_CTRL_S stStockCtrl;
    FILE_WHOLE_DATA_S *astWholeData = ((void *)0);
    FILE_WHOLE_DATA_S *pstLatestData = ((void *)0);
    ulEntryCnt = FILE_GetFileData(ulCode, szDir, 0xF0000000, (VOID**)&astWholeData);
    if (0 == ulEntryCnt) return;
    ulIndex = GetIndexByDate(ulDate, (0x00), ulEntryCnt, astWholeData);
    if ((0xFFFFFFFF) == ulIndex) {
        free(astWholeData);
        DebugOutString("invalid date=%lu, code=%06lu\n", ulDate, ulCode);
        return;
    }
    pstLatestData=&astWholeData[ulEntryCnt-1];
    ulLatestEndPrice = pstLatestData->stDailyPrice.ulEnd;
    METHOD_GetFuncSet(ulMethod, &stMethodFunc);
    stMethodFunc.pfSetParam(0, ((void *)0));
    memset(&stStockCtrl, 0, sizeof(stStockCtrl));
    stStockCtrl.ulBuyDate = ulDate;
    stStockCtrl.ulGainPrice = stMethodFunc.pfGetGainPrice(pstLatestData, &stStockCtrl);
    stStockCtrl.ulLossPrice = stMethodFunc.pfGetLossPrice(pstLatestData, &stStockCtrl);
    free(astWholeData);
    ulGainPriceDiff=(stStockCtrl.ulGainPrice > (ulLatestEndPrice+10)) ?
                    (stStockCtrl.ulGainPrice-ulLatestEndPrice) : 10;
    ulLossPriceDiff=(ulLatestEndPrice>(stStockCtrl.ulLossPrice+10)) ?
                    (ulLatestEndPrice-stStockCtrl.ulLossPrice) : 10;
    printf("%06lu,%lu,%.2f,%.2f,%lu,%.2f,%lu\n",
           ulCode, stStockCtrl.ulBuyDate, (((FLOAT)(ulLatestEndPrice))/(1000)),
           (((FLOAT)(stStockCtrl.ulLossPrice))/(1000)), ulLossPriceDiff/10,
           (((FLOAT)(stStockCtrl.ulGainPrice))/(1000)), ulGainPriceDiff/10);
    return;
}

canonical_original_code:
void CHOOSE_Track(unsigned long ulCode, unsigned long ulDate, char *szDir, unsigned long ulMethod)
{
    unsigned long ulEntryCnt;
    unsigned long ulIndex;
    unsigned long ulLatestEndPrice;
    unsigned long ulGainPriceDiff; unsigned long ulLossPriceDiff;
    struct tagMethodFuncSet stMethodFunc;
    struct tagStockCtrl stStockCtrl;
    struct tagWholeData *astWholeData = ((void *)0);
    struct tagWholeData *pstLatestData = ((void *)0);
    ulEntryCnt = FILE_GetFileData(ulCode, szDir, 0xF0000000, (void **)&astWholeData);
    if (0 == ulEntryCnt) return;
    ulIndex = GetIndexByDate(ulDate, (0x00), ulEntryCnt, astWholeData);
    if ((0xFFFFFFFF) == ulIndex) {
        free(astWholeData);
        DebugOutString("invalid date=%lu, code=%06lu\n", ulDate, ulCode);
        return;
    }
    pstLatestData=&astWholeData[ulEntryCnt-1];
    ulLatestEndPrice = pstLatestData->stDailyPrice.ulEnd;
    METHOD_GetFuncSet(ulMethod, &stMethodFunc);
    stMethodFunc.pfSetParam(0, ((void *)0));
    memset(&stStockCtrl, 0, sizeof(stStockCtrl));
    stStockCtrl.ulBuyDate = ulDate;
    stStockCtrl.ulGainPrice = stMethodFunc.pfGetGainPrice(pstLatestData, &stStockCtrl);
    stStockCtrl.ulLossPrice = stMethodFunc.pfGetLossPrice(pstLatestData, &stStockCtrl);
    free(astWholeData);
    ulGainPriceDiff=(stStockCtrl.ulGainPrice > (ulLatestEndPrice+10)) ?
                    (stStockCtrl.ulGainPrice-ulLatestEndPrice) : 10;
    ulLossPriceDiff=(ulLatestEndPrice>(stStockCtrl.ulLossPrice+10)) ?
                    (ulLatestEndPrice-stStockCtrl.ulLossPrice) : 10;
    printf("%06lu,%lu,%.2f,%.2f,%lu,%.2f,%lu\n",
           ulCode, stStockCtrl.ulBuyDate, (((FLOAT)(ulLatestEndPrice))/(1000)),
           (((FLOAT)(stStockCtrl.ulLossPrice))/(1000)), ulLossPriceDiff/10,
           (((FLOAT)(stStockCtrl.ulGainPrice))/(1000)), ulGainPriceDiff/10);
    return;
}

variable_types:
ulCode
unsigned long

variable_types:
ulDate
unsigned long

variable_types:
szDir
char *

variable_types:
ulMethod
unsigned long

variable_types:
ulEntryCnt
unsigned long

variable_types:
ulIndex
unsigned long

variable_types:
ulLatestEndPrice
unsigned long

variable_types:
ulGainPriceDiff
unsigned long

variable_types:
ulLossPriceDiff
unsigned long

variable_types: struct tagMethodFuncSet { unsigned long (*pfGetGainPrice)(struct tagWholeData { char szComment[16]; unsigned int ulDate; unsigned int ulRsv; struct tagPrice { unsigned int ulBegin; unsigned int ulHigh; unsigned int ulLow; unsigned int ulEnd; unsigned int ulVol; unsigned int ulFlag; } stDailyPrice; struct tagPrice astMin30Price[8]; struct tagFactor { unsigned int ulFlag; float fMulti; float fAdder; } stFactor; unsigned int ulPad; } *, struct tagStockCtrl { unsigned int ulGainPrice; unsigned int ulLossPrice; unsigned int ulBuyDate; unsigned int ulBuyPrice; unsigned int ulSellDate; unsigned int ulSellPrice; float fContext; } *); unsigned long (*pfGetLossPrice)(struct tagWholeData *, struct tagStockCtrl *); unsigned long (*pfGetBuyPrice)(struct tagWholeData *, unsigned long); unsigned long (*pfGetSellPrice)(struct tagWholeData *, struct tagStockCtrl *); unsigned short (*pfDailyChoose)(unsigned long, struct tagWholeData *, struct tagPreDealInfo { unsigned short bIsSell; unsigned short usDealHour; unsigned short usDealMin; unsigned short bIsHigher; float fThresholdPrice; float fWeight; } *); void (*pfStatistics)(unsigned long, struct tagWholeData *); void (*pfSetParam)(unsigned long, float *); }

return_type: void

user_defined_types: struct tagMethodFuncSet { unsigned long (*pfGetGainPrice)(struct tagWholeData *, struct tagStockCtrl *); unsigned long (*pfGetLossPrice)(struct tagWholeData *, struct tagStockCtrl *); unsigned long (*pfGetBuyPrice)(struct tagWholeData *, unsigned long); unsigned long (*pfGetSellPrice)(struct tagWholeData *, struct tagStockCtrl *); unsigned short (*pfDailyChoose)(unsigned long, struct tagWholeData *, struct tagPreDealInfo *); void (*pfStatistics)(unsigned long, struct tagWholeData *); void (*pfSetParam)(unsigned long, float *); }


decompiled_code:
int __fastcall CHOOSE_Distribute(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 v5; // rax
__int64 v6; // r14
__int64 (__fastcall *v7)(__int64, char *, __int16 *); // r12
void *ptr; // [rsp+8h] [rbp-80h] BYREF
__int16 v10[4]; // [rsp+10h] [rbp-78h] BYREF
float v11; // [rsp+18h] [rbp-70h]
char v12[32]; // [rsp+20h] [rbp-68h] BYREF
__int64 (__fastcall *v13)(__int64, char *, __int16 *); // [rsp+40h] [rbp-48h]
void (__fastcall *v14)(_QWORD, _QWORD); // [rsp+50h] [rbp-38h]

ptr = 0LL;
v5 = FILE_GetFileData(a1, a3, 4026531840LL, &ptr);
if ( v5 )
{
v6 = GetIndexByDate(a2, 16LL, v5, ptr);
if ( v6 == 0xFFFFFFFFLL )
{
free(ptr);
LODWORD(v5) = DebugOutString("invalid date=%lu, code=%06lu\n", a2, a1);
}
else
{
METHOD_GetFuncSet(a4, v12);
v7 = v13;
v14(0LL, 0LL);
LOWORD(v7) = v7(v6, (char *)ptr + 256 * v6, v10);
free(ptr);
if ( (_WORD)v7 == 1 )
LODWORD(v5) = printf(
"%06lu,%u,%u,%u,%u,%.2f\n",
a1,
(unsigned __int16)v10[0],
(unsigned __int16)v10[1],
(unsigned __int16)v10[2],
(unsigned __int16)v10[3],
v11);
else
LODWORD(v5) = DebugOutString("%06lu not in deal\n", a1);
}
}
return v5;
}

canonical_decompiled_code:
int __fastcall func1(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 v5; // rax
__int64 v6; // r14
__int64 (__fastcall *v7)(__int64, char *, __int16 *); // r12
void *ptr; // [rsp+8h] [rbp-80h] BYREF
__int16 v10[4]; // [rsp+10h] [rbp-78h] BYREF
float v11; // [rsp+18h] [rbp-70h]
char v12[32]; // [rsp+20h] [rbp-68h] BYREF
__int64 (__fastcall *v13)(__int64, char *, __int16 *); // [rsp+40h] [rbp-48h]
void (__fastcall *v14)(_QWORD, _QWORD); // [rsp+50h] [rbp-38h]

ptr = 0LL;
v5 = FILE_GetFileData(a1, a3, 4026531840LL, &ptr);
if ( v5 )
{
v6 = GetIndexByDate(a2, 16LL, v5, ptr);
if ( v6 == 0xFFFFFFFFLL )
{
free(ptr);
LODWORD(v5) = DebugOutString("invalid date=%lu, code=%06lu\n", a2, a1);
}
else
{
METHOD_GetFuncSet(a4, v12);
v7 = v13;
v14(0LL, 0LL);
LOWORD(v7) = v7(v6, (char *)ptr + 256 * v6, v10);
free(ptr);
if ( (_WORD)v7 == 1 )
LODWORD(v5) = printf(
"%06lu,%u,%u,%u,%u,%.2f\n",
a1,
(unsigned __int16)v10[0],
(unsigned __int16)v10[1],
(unsigned __int16)v10[2],
(unsigned __int16)v10[3],
v11);
else
LODWORD(v5) = DebugOutString("%06lu not in deal\n", a1);
}
}
return v5;
}

original_code:
VOID CHOOSE_Distribute( ULONG ulCode, ULONG ulDate, CHAR * szDir, ULONG ulMethod)
{
    BOOL_T bIsDeal;
    CHOOSE_PRE_DEAL_S stDealInfo;
    ULONG ulEntryCnt;
    ULONG ulIndex;
    METHOD_FUNC_SET_S stMethodFunc;
    Choose_PF pfChoose = ((void *)0);
    FILE_WHOLE_DATA_S *astWholeData = ((void *)0);
    ulEntryCnt = FILE_GetFileData(ulCode, szDir, 0xF0000000, (VOID**)&astWholeData);
    if (0 == ulEntryCnt) return;
    ulIndex = GetIndexByDate(ulDate, (0x10), ulEntryCnt, astWholeData);
    if ((0xFFFFFFFF) == ulIndex) {
        free(astWholeData);
        DebugOutString("invalid date=%lu, code=%06lu\n", ulDate, ulCode);
        return;
    }
    METHOD_GetFuncSet(ulMethod, &stMethodFunc);
    pfChoose = stMethodFunc.pfDailyChoose;
    stMethodFunc.pfSetParam(0, ((void *)0));
    bIsDeal = pfChoose(ulIndex, &astWholeData[ulIndex], &stDealInfo);
    free(astWholeData);
    if ((1) == bIsDeal) {
        printf("%06lu,%u,%u,%u,%u,%.2f\n",
               ulCode, stDealInfo.bIsSell, stDealInfo.usDealHour, stDealInfo.usDealMin,
               stDealInfo.bIsHigher, stDealInfo.fThresholdPrice);
    }
    else {
        DebugOutString("%06lu not in deal\n",ulCode);
    }
    return;
}

canonical_original_code:
void CHOOSE_Distribute(unsigned long ulCode, unsigned long ulDate, char *szDir, unsigned long ulMethod)
{
    unsigned short bIsDeal;
    struct tagPreDealInfo stDealInfo;
    unsigned long ulEntryCnt;
    unsigned long ulIndex;
    struct tagMethodFuncSet stMethodFunc;
    unsigned short (*pfChoose)(unsigned long, struct tagWholeData *, struct tagPreDealInfo *) = ((void *)0);
    struct tagWholeData *astWholeData = ((void *)0);
    ulEntryCnt = FILE_GetFileData(ulCode, szDir, 0xF0000000, (void **)&astWholeData);
    if (0 == ulEntryCnt) return;
    ulIndex = GetIndexByDate(ulDate, (0x10), ulEntryCnt, astWholeData);
    if ((0xFFFFFFFF) == ulIndex) {
        free(astWholeData);
        DebugOutString("invalid date=%lu, code=%06lu\n", ulDate, ulCode);
        return;
    }
    METHOD_GetFuncSet(ulMethod, &stMethodFunc);
    pfChoose = stMethodFunc.pfDailyChoose;
    stMethodFunc.pfSetParam(0, ((void *)0));
    bIsDeal = pfChoose(ulIndex, &astWholeData[ulIndex], &stDealInfo);
    free(astWholeData);
    if ((1) == bIsDeal) {
        printf("%06lu,%u,%u,%u,%u,%.2f\n",
               ulCode, stDealInfo.bIsSell, stDealInfo.usDealHour, stDealInfo.usDealMin,
               stDealInfo.bIsHigher, stDealInfo.fThresholdPrice);
    }
    else {
        DebugOutString("%06lu not in deal\n",ulCode);
    }
    return;
}

variable_types:
bIsDeal
unsigned short

variable_types: unsigned short (*)(unsigned long, struct tagWholeData { char szComment[16]; unsigned int ulDate; unsigned int ulRsv; struct tagPrice { unsigned int ulBegin; unsigned int ulHigh; unsigned int ulLow; unsigned int ulEnd; unsigned int ulVol; unsigned int ulFlag; } stDailyPrice; struct tagPrice astMin30Price[8]; struct tagFactor { unsigned int ulFlag; float fMulti; float fAdder; } stFactor; unsigned int ulPad; } *, struct tagPreDealInfo { unsigned short bIsSell; unsigned short usDealHour; unsigned short usDealMin; unsigned short bIsHigher; float fThresholdPrice; float fWeight; } *)

user_defined_types: struct tagStockCtrl { unsigned int ulGainPrice; unsigned int ulLossPrice; unsigned int ulBuyDate; unsigned int ulBuyPrice; unsigned int ulSellDate; unsigned int ulSellPrice; float fContext; }


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // r14
__int64 v4; // r13
__int64 v5; // rax
__int64 v6; // r12
__int64 v7; // rbx
__int64 v8; // rdi
__int64 *v10; // [rsp+8h] [rbp-30h] BYREF

v10 = 0LL;
if ( (unsigned int)(argc - 5) > 1 )
{
printf("USAGE: %s method path date { code | all } [debug]", *argv);
exit(1);
}
RandomInit(argc, argv, envp);
if ( !strcasecmp(argv[argc - 1], "debug") )
g_bIsDebugMode = 1;
v3 = GetMethod(argv[1]);
v4 = atol(argv[3]);
v5 = GetCodeList(argv[4], &v10);
v6 = v5;
if ( v5 == 1 )
{
CHOOSE_Track(*v10, v4, (__int64)argv[2], v3);
}
else
{
v7 = 0LL;
if ( v5 )
{
do
{
v8 = v10[v7++];
CHOOSE_Distribute(v8, v4, (__int64)argv[2], v3);
}
while ( v6 != v7 );
}
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // r14
__int64 v4; // r13
__int64 v5; // rax
__int64 v6; // r12
__int64 v7; // rbx
__int64 v8; // rdi
__int64 *v10; // [rsp+8h] [rbp-30h] BYREF

v10 = 0LL;
if ( (unsigned int)(argc - 5) > 1 )
{
printf("USAGE: %s method path date { code | all } [debug]", *argv);
exit(1);
}
RandomInit(argc, argv, envp);
if ( !strcasecmp(argv[argc - 1], "debug") )
g_bIsDebugMode = 1;
v3 = GetMethod(argv[1]);
v4 = atol(argv[3]);
v5 = GetCodeList(argv[4], &v10);
v6 = v5;
if ( v5 == 1 )
{
func0(*v10, v4, (__int64)argv[2], v3);
}
else
{
v7 = 0LL;
if ( v5 )
{
do
{
v8 = v10[v7++];
func1(v8, v4, (__int64)argv[2], v3);
}
while ( v6 != v7 );
}
}
return 0;
}

original_code:
int main(int argc,char *argv[])
{
    ULONG i, ulCodeCnt;
    ULONG ulDate;
    ULONG ulMethod;
    ULONG *pulCodeList = ((void *)0);
    if ((argc < 5) || (argc > 6)) {
        printf("USAGE: %s method path date { code | all } [debug]", argv[0]);
        exit(1);
    }
    RandomInit();
    if (0 == strcasecmp(argv[argc-1], "debug"))
        g_bIsDebugMode = (1);
    ulMethod = GetMethod(argv[1]);
    ulDate = (ULONG)atol(argv[3]);
    ulCodeCnt = GetCodeList(argv[4], &pulCodeList);
    if (1 == ulCodeCnt) {
        CHOOSE_Track(pulCodeList[0], ulDate, argv[2], ulMethod);
    }
    else {
        for (i=0;i<ulCodeCnt;i++) {
            CHOOSE_Distribute(pulCodeList[i], ulDate, argv[2], ulMethod);
        }
    }
    return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
    unsigned long i; unsigned long ulCodeCnt;
    unsigned long ulDate;
    unsigned long ulMethod;
    unsigned long *pulCodeList = ((void *)0);
    if ((argc < 5) || (argc > 6)) {
        printf("USAGE: %s method path date { code | all } [debug]", argv[0]);
        exit(1);
    }
    RandomInit();
    if (0 == strcasecmp(argv[argc-1], "debug"))
        g_bIsDebugMode = (1);
    ulMethod = GetMethod(argv[1]);
    ulDate = (unsigned long)atol(argv[3]);
    ulCodeCnt = GetCodeList(argv[4], &pulCodeList);
    if (1 == ulCodeCnt) {
        CHOOSE_Track(pulCodeList[0], ulDate, argv[2], ulMethod);
    }
    else {
        for (i=0;i<ulCodeCnt;i++) {
            CHOOSE_Distribute(pulCodeList[i], ulDate, argv[2], ulMethod);
        }
    }
    return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types:
i
unsigned long

variable_types:
ulCodeCnt
unsigned long

variable_types:
pulCodeList
unsigned long *

return_type: int


decompiled_code:
void RISE_SetParam()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code:
VOID RISE_SetParam( ULONG ulCnt, FLOAT *afParam)
{
    return;
}

canonical_original_code:
void RISE_SetParam(unsigned long ulCnt, float *afParam)
{
    return;
}

variable_types:
ulCnt
unsigned long

variable_types:
afParam
float *


decompiled_code:
void RISE_SortWishList()
{
;
}

canonical_decompiled_code:
void func2()
{
;
}

original_code:
VOID RISE_SortWishList( ULONG ulWishCnt, SIM_STOCK_DATA_S *pstAllData, SIM_WISH_LIST_S *astWishList)
{
    return;
}

canonical_original_code:
void RISE_SortWishList(unsigned long ulWishCnt, struct tagStockData *pstAllData, struct tagWishList *astWishList)
{
    return;
}

variable_types:
ulWishCnt
unsigned long

variable_types: struct tagStockData { unsigned int ulStockCode; unsigned int ulEntryCnt; unsigned short bIsHold; struct tagWholeData { char szComment[16]; unsigned int ulDate; unsigned int ulRsv; struct tagPrice { unsigned int ulBegin; unsigned int ulHigh; unsigned int ulLow; unsigned int ulEnd; unsigned int ulVol; unsigned int ulFlag; } stDailyPrice; struct tagPrice astMin30Price[8]; struct tagFactor { unsigned int ulFlag; float fMulti; float fAdder; } stFactor; unsigned int ulPad; } *pstCurrData; struct tagWholeData *astWholeData; } *

variable_types: struct tagWishList { unsigned int ulCode; unsigned int ulIndex; unsigned int ulWishPrice; float fWeight; } *

user_defined_types: struct tagStockData { unsigned int ulStockCode; unsigned int ulEntryCnt; unsigned short bIsHold; struct tagWholeData *pstCurrData; struct tagWholeData *astWholeData; }


decompiled_code:
void __fastcall RISE_Statistics(unsigned __int64 a1, __int64 a2)
{
float v2; // xmm0_4
float v3; // [rsp+0h] [rbp-20h] BYREF
float v4[7]; // [rsp+4h] [rbp-1Ch] BYREF

if ( a1 > 3 )
{
GetTotalRise(1LL, a2, 4LL, v4);
if ( v4[0] >= -0.11 && v4[0] <= 0.11 )
{
GetTotalRise(3LL, a2 - 256, 4LL, &v3);
v2 = GetVolRatio(a2 - 256);
if ( v2 > 5.0 && v3 > 0.1 )
printf("%lu,%.5f,%.5f\n", *(unsigned int *)(a2 + 16), v2, v4[0]);
}
}
}

original_code:
VOID RISE_Statistics( ULONG ulIndex, FILE_WHOLE_DATA_S *pstSettleData)
{
    FLOAT fWatchRise;
    FLOAT fPrevVolRate;
    FLOAT fCurrRise;
    if (ulIndex <= (3)) return;
    (VOID)GetTotalRise(1, pstSettleData, (0x04UL), &fCurrRise);
    if ((fCurrRise < -0.11) || (fCurrRise > 0.11)) return;
    (VOID)GetTotalRise((3), pstSettleData-1, (0x04UL), &fWatchRise);
    fPrevVolRate=GetVolRatio(pstSettleData-1);
    if ((fPrevVolRate>5) && (fWatchRise>0.1))
    printf("%lu,%.5f,%.5f\n", pstSettleData->ulDate, fPrevVolRate, fCurrRise);
    return;
}

canonical_original_code:
void RISE_Statistics(unsigned long ulIndex, struct tagWholeData *pstSettleData)
{
    float fWatchRise;
    float fPrevVolRate;
    float fCurrRise;
    if (ulIndex <= (3)) return;
    (void)GetTotalRise(1, pstSettleData, (0x04UL), &fCurrRise);
    if ((fCurrRise < -0.11) || (fCurrRise > 0.11)) return;
    (void)GetTotalRise((3), pstSettleData-1, (0x04UL), &fWatchRise);
    fPrevVolRate=GetVolRatio(pstSettleData-1);
    if ((fPrevVolRate>5) && (fWatchRise>0.1))
    printf("%lu,%.5f,%.5f\n", pstSettleData->ulDate, fPrevVolRate, fCurrRise);
    return;
}

variable_types:
ulIndex
unsigned long

variable_types: struct tagWholeData { char szComment[16]; unsigned int ulDate; unsigned int ulRsv; struct tagPrice { unsigned int ulBegin; unsigned int ulHigh; unsigned int ulLow; unsigned int ulEnd; unsigned int ulVol; unsigned int ulFlag; } stDailyPrice; struct tagPrice astMin30Price[8]; struct tagFactor { unsigned int ulFlag; float fMulti; float fAdder; } stFactor; unsigned int ulPad; } *

variable_types: fWatchRise float

variable_types: fPrevVolRate float

variable_types: fCurrRise float


decompiled_code:
__int64 __fastcall RISE_Choose(unsigned __int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax
char v5[28]; // [rsp+0h] [rbp-1Ch] BYREF

if ( a1 <= 2 )
return 0LL;
if ( !(unsigned __int16)GetTotalRise(2LL, a2, 4LL, v5) )
return 0LL;
*(_DWORD *)a3 = 917504;
*(_WORD *)(a3 + 4) = RandomUlong(50LL, 60LL);
*(_WORD *)(a3 + 6) = 1;
result = 1LL;
*(float *)(a3 + 8) = fmaxf((float)*(int *)(a2 - 476) * 1.1, (float)*(int *)(a2 + 36) * 1.02) / 1000.0;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned __int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax
char v5[28]; // [rsp+0h] [rbp-1Ch] BYREF

if ( a1 <= 2 )
return 0LL;
if ( !(unsigned __int16)GetTotalRise(2LL, a2, 4LL, v5) )
return 0LL;
*(_DWORD *)a3 = 917504;
*(_WORD *)(a3 + 4) = RandomUlong(50LL, 60LL);
*(_WORD *)(a3 + 6) = 1;
result = 1LL;
*(float *)(a3 + 8) = fmaxf((float)*(int *)(a2 - 476) * 1.1, (float)*(int *)(a2 + 36) * 1.02) / 1000.0;
return result;
}

original_code:
BOOL_T RISE_Choose( ULONG ulIndex, FILE_WHOLE_DATA_S *pstCurrData, CHOOSE_PRE_DEAL_S *pstDealInfo)
{
    FLOAT fPrevRise;
    FLOAT fThreshPrice;
    ULONG ulMeanPrice=(0xFFFFFFFF);
    FILE_WHOLE_DATA_S *pstBase = pstCurrData - (2);
    FILE_WHOLE_DATA_S *pstTemp = pstBase-1;
    if (ulIndex <= ((2))) return (0);
    {
        BOOL_T bIsContinuous;
        bIsContinuous = GetTotalRise((2), pstCurrData, (0x04UL), &fPrevRise);
        if ((0) == bIsContinuous) return (0);
    }
    pstDealInfo->bIsSell = (0);
    pstDealInfo->usDealHour = (14);
    pstDealInfo->usDealMin = (USHORT)RandomUlong(50,60);
    pstDealInfo->bIsHigher = (1);
    fThreshPrice = (((((1.10F) * pstBase->stDailyPrice.ulEnd)) > (((1.02F) * pstCurrData->stDailyPrice.ulEnd))) ? (((1.10F) * pstBase->stDailyPrice.ulEnd)) : (((1.02F) * pstCurrData->stDailyPrice.ulEnd)));
    pstDealInfo->fThresholdPrice = (((FLOAT)(fThreshPrice))/(1000));
    return (1);
}

canonical_original_code:
unsigned short RISE_Choose(unsigned long ulIndex, struct tagWholeData *pstCurrData, struct tagPreDealInfo *pstDealInfo)
{
    float fPrevRise;
    float fThreshPrice;
    unsigned long ulMeanPrice = (0xFFFFFFFF);
    struct tagWholeData *pstBase = pstCurrData - (2);
    struct tagWholeData *pstTemp = pstBase-1;
    if (ulIndex <= ((2))) return (0);
    {
        unsigned short bIsContinuous;
        bIsContinuous = GetTotalRise((2), pstCurrData, (0x04UL), &fPrevRise);
        if ((0) == bIsContinuous) return (0);
    }
    pstDealInfo->bIsSell = (0);
    pstDealInfo->usDealHour = (14);
    pstDealInfo->usDealMin = (unsigned short)RandomUlong(50,60);
    pstDealInfo->bIsHigher = (1);
    fThreshPrice = (((((1.10F) * pstBase->stDailyPrice.ulEnd)) > (((1.02F) * pstCurrData->stDailyPrice.ulEnd))) ? (((1.10F) * pstBase->stDailyPrice.ulEnd)) : (((1.02F) * pstCurrData->stDailyPrice.ulEnd)));
    pstDealInfo->fThresholdPrice = (((FLOAT)(fThreshPrice))/(1000));
    return (1);
}

variable_types: struct tagPreDealInfo { unsigned short bIsSell; unsigned short usDealHour; unsigned short usDealMin; unsigned short bIsHigher; float fThresholdPrice; float fWeight; } *

variable_types: fPrevRise float

variable_types: fThreshPrice float

variable_types:
ulMeanPrice
unsigned long

variable_types:
bIsContinuous
unsigned short

return_type: unsigned short

user_defined_types: struct tagFactor { unsigned int ulFlag; float fMulti; float fAdder; }


decompiled_code:
unsigned __int64 __fastcall RISE_GetGainPrice(__int64 a1, __int64 a2)
{
unsigned int v2; // eax
float v3; // xmm0_4
unsigned __int64 result; // rax

v2 = *(_DWORD *)(a2 + 8);
if ( *(_DWORD *)(a1 + 16) < v2 )
_assert_fail("pstCurrData->ulDate>=pstStockCtrl->ulBuyDate", "method/rise.c", 0x74u, "RISE_GetGainPrice");
for ( ; v2 != *(_DWORD *)(a1 + 16); a1 -= 256LL )
;
v3 = (float)*(int *)(a1 + 36) * 1.033;
if ( v3 < 9.223372e18 )
result = (unsigned int)(int)v3;
else
result = (unsigned int)(int)(float)(v3 - 9.223372e18) ^ 0x8000000000000000LL;
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func5(__int64 a1, __int64 a2)
{
unsigned int v2; // eax
float v3; // xmm0_4
unsigned __int64 result; // rax

v2 = *(_DWORD *)(a2 + 8);
if ( *(_DWORD *)(a1 + 16) < v2 )
_assert_fail("pstCurrData->ulDate>=pstStockCtrl->ulBuyDate", "method/rise.c", 0x74u, "RISE_GetGainPrice");
for ( ; v2 != *(_DWORD *)(a1 + 16); a1 -= 256LL )
;
v3 = (float)*(int *)(a1 + 36) * 1.033;
if ( v3 < 9.223372e18 )
result = (unsigned int)(int)v3;
else
result = (unsigned int)(int)(float)(v3 - 9.223372e18) ^ 0x8000000000000000LL;
return result;
}

original_code:
ULONG RISE_GetGainPrice( FILE_WHOLE_DATA_S *pstCurrData, STOCK_CTRL_S *pstStockCtrl)
{
    ULONG ulHoldDays=0;
    FILE_WHOLE_DATA_S *pstData=pstCurrData;
    ((void) sizeof ((pstCurrData->ulDate>=pstStockCtrl->ulBuyDate) ? 1 : 0), __extension__ ({ if (pstCurrData->ulDate>=pstStockCtrl->ulBuyDate) ; else __assert_fail ("pstCurrData->ulDate>=pstStockCtrl->ulBuyDate", "method/rise.c", 116, __extension__ __PRETTY_FUNCTION__); }));
    while (1) {
        ulHoldDays++;
        if (pstData->ulDate==pstStockCtrl->ulBuyDate) break;
        pstData--;
    }
    return (ULONG)(pstData->stDailyPrice.ulEnd * (1.033F));
}

canonical_original_code:
unsigned long RISE_GetGainPrice(struct tagWholeData *pstCurrData, struct tagStockCtrl *pstStockCtrl)
{
    unsigned long ulHoldDays = 0;
    struct tagWholeData *pstData = pstCurrData;
    ((void) sizeof ((pstCurrData->ulDate>=pstStockCtrl->ulBuyDate) ? 1 : 0), __extension__ ({ if (pstCurrData->ulDate>=pstStockCtrl->ulBuyDate) ; else __assert_fail ("pstCurrData->ulDate>=pstStockCtrl->ulBuyDate", "method/rise.c", 116, __extension__ __PRETTY_FUNCTION__); }));
    while (1) {
        ulHoldDays++;
        if (pstData->ulDate==pstStockCtrl->ulBuyDate) break;
        pstData--;
    }
    return (ULONG)(pstData->stDailyPrice.ulEnd * (1.033F));
}

variable_types: struct tagStockCtrl { unsigned int ulGainPrice; unsigned int ulLossPrice; unsigned int ulBuyDate; unsigned int ulBuyPrice; unsigned int ulSellDate; unsigned int ulSellPrice; float fContext; } *

variable_types:
ulHoldDays
unsigned long


decompiled_code:
unsigned __int64 __fastcall RISE_GetLossPrice(__int64 a1, __int64 a2)
{
unsigned int v2; // eax
float v3; // xmm0_4
unsigned __int64 result; // rax

v2 = *(_DWORD *)(a2 + 8);
if ( *(_DWORD *)(a1 + 16) < v2 )
_assert_fail("pstCurrData->ulDate>=pstStockCtrl->ulBuyDate", "method/rise.c", 0x85u, "RISE_GetLossPrice");
for ( ; v2 != *(_DWORD *)(a1 + 16); a1 -= 256LL )
;
v3 = (float)*(int *)(a1 + 36) * 0.92299998;
if ( v3 < 9.223372e18 )
result = (unsigned int)(int)v3;
else
result = (unsigned int)(int)(float)(v3 - 9.223372e18) ^ 0x8000000000000000LL;
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func6(__int64 a1, __int64 a2)
{
unsigned int v2; // eax
float v3; // xmm0_4
unsigned __int64 result; // rax

v2 = *(_DWORD *)(a2 + 8);
if ( *(_DWORD *)(a1 + 16) < v2 )
_assert_fail("pstCurrData->ulDate>=pstStockCtrl->ulBuyDate", "method/rise.c", 0x85u, "RISE_GetLossPrice");
for ( ; v2 != *(_DWORD *)(a1 + 16); a1 -= 256LL )
;
v3 = (float)*(int *)(a1 + 36) * 0.92299998;
if ( v3 < 9.223372e18 )
result = (unsigned int)(int)v3;
else
result = (unsigned int)(int)(float)(v3 - 9.223372e18) ^ 0x8000000000000000LL;
return result;
}

original_code:
ULONG RISE_GetLossPrice( FILE_WHOLE_DATA_S *pstCurrData, STOCK_CTRL_S *pstStockCtrl)
{
    ULONG ulHoldDays=0;
    FILE_WHOLE_DATA_S *pstData=pstCurrData;
    ((void) sizeof ((pstCurrData->ulDate>=pstStockCtrl->ulBuyDate) ? 1 : 0), __extension__ ({ if (pstCurrData->ulDate>=pstStockCtrl->ulBuyDate) ; else __assert_fail ("pstCurrData->ulDate>=pstStockCtrl->ulBuyDate", "method/rise.c", 133, __extension__ __PRETTY_FUNCTION__); }));
    while (1) {
        ulHoldDays++;
        if (pstData->ulDate==pstStockCtrl->ulBuyDate) break;
        pstData--;
    }
    return (ULONG)(pstData->stDailyPrice.ulEnd * (0.923F));
}

canonical_original_code:
unsigned long RISE_GetLossPrice(struct tagWholeData *pstCurrData, struct tagStockCtrl *pstStockCtrl)
{
    unsigned long ulHoldDays = 0;
    struct tagWholeData *pstData = pstCurrData;
    ((void) sizeof ((pstCurrData->ulDate>=pstStockCtrl->ulBuyDate) ? 1 : 0), __extension__ ({ if (pstCurrData->ulDate>=pstStockCtrl->ulBuyDate) ; else __assert_fail ("pstCurrData->ulDate>=pstStockCtrl->ulBuyDate", "method/rise.c", 133, __extension__ __PRETTY_FUNCTION__); }));
    while (1) {
        ulHoldDays++;
        if (pstData->ulDate==pstStockCtrl->ulBuyDate) break;
        pstData--;
    }
    return (ULONG)(pstData->stDailyPrice.ulEnd * (0.923F));
}


decompiled_code:
__int64 __fastcall RISE_GetBuyPrice(_DWORD *a1, unsigned __int64 a2)
{
__int64 result; // rax
unsigned int v3; // edx
float v4[7]; // [rsp+Ch] [rbp-1Ch] BYREF

GetTotalRise(1LL, a1, 4LL, v4);
result = 0xFFFFFFFFLL;
if ( v4[0] <= 0.098999999 )
{
v3 = a1[9];
if ( a1[6] != v3 || a1[7] != a1[8] )
{
result = v3;
if ( v3 < a2 )
result = 0xFFFFFFFFLL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(_DWORD *a1, unsigned __int64 a2)
{
__int64 result; // rax
unsigned int v3; // edx
float v4[7]; // [rsp+Ch] [rbp-1Ch] BYREF

GetTotalRise(1LL, a1, 4LL, v4);
result = 0xFFFFFFFFLL;
if ( v4[0] <= 0.098999999 )
{
v3 = a1[9];
if ( a1[6] != v3 || a1[7] != a1[8] )
{
result = v3;
if ( v3 < a2 )
result = 0xFFFFFFFFLL;
}
}
return result;
}

original_code:
ULONG RISE_GetBuyPrice( FILE_WHOLE_DATA_S *pstCurrData, ULONG ulWishPrice)
{
    FLOAT fRise;
    (VOID)GetTotalRise(1,pstCurrData,(0x04UL),&fRise);
    if (fRise > (0.099F)) return (0xFFFFFFFF);
    if ((pstCurrData->stDailyPrice.ulBegin == pstCurrData->stDailyPrice.ulEnd) &&
        (pstCurrData->stDailyPrice.ulHigh == pstCurrData->stDailyPrice.ulLow)) return (0xFFFFFFFF);
    if (pstCurrData->stDailyPrice.ulEnd < ulWishPrice) return (0xFFFFFFFF);
    return pstCurrData->stDailyPrice.ulEnd;
}

canonical_original_code:
unsigned long RISE_GetBuyPrice(struct tagWholeData *pstCurrData, unsigned long ulWishPrice)
{
    float fRise;
    (void)GetTotalRise(1,pstCurrData,(0x04UL),&fRise);
    if (fRise > (0.099F)) return (0xFFFFFFFF);
    if ((pstCurrData->stDailyPrice.ulBegin == pstCurrData->stDailyPrice.ulEnd) &&
        (pstCurrData->stDailyPrice.ulHigh == pstCurrData->stDailyPrice.ulLow)) return (0xFFFFFFFF);
    if (pstCurrData->stDailyPrice.ulEnd < ulWishPrice) return (0xFFFFFFFF);
    return pstCurrData->stDailyPrice.ulEnd;
}

variable_types:
ulWishPrice
unsigned long

variable_types: fRise float


decompiled_code:
__int64 __fastcall RISE_GetSellPrice(unsigned int *a1, __int64 a2)
{
unsigned int *v2; // rbx
__int64 v3; // r8
unsigned __int64 v4; // rax
__int64 v5; // rax
__int64 result; // rax
float v7; // xmm0_4
int v8; // eax

v2 = a1 + 12;
v3 = GetDateInterval(*(unsigned int *)(a2 + 8), a1[4]);
v4 = 0LL;
if ( v3 )
{
while ( v2[5] == -858993460 )
{
++v4;
v2 += 6;
if ( v4 == 8 )
{
v5 = 6LL;
return a1[6 * v5 + 15];
}
}
if ( v4 > 1 )
{
v5 = v4 - 2;
return a1[6 * v5 + 15];
}
result = RandomUlong(a1[8], a1[7]);
}
else
{
v7 = (float)*(int *)(a2 + 4) * 1.01;
if ( v7 >= 9.223372e18 )
v8 = (int)(float)(v7 - 9.223372e18);
else
v8 = (int)v7;
*(_DWORD *)(a2 + 4) = v8;
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
ULONG RISE_GetSellPrice( FILE_WHOLE_DATA_S *pstCurrData, STOCK_CTRL_S *pstStockCtrl)
{
    ULONG i;
    ULONG ulSellPrice;
    PRICE_S *pstMin30Price = pstCurrData->astMin30Price;
    if ((1) > GetDateInterval(pstStockCtrl->ulBuyDate, pstCurrData->ulDate)) {
        pstStockCtrl->ulLossPrice=(ULONG)(pstStockCtrl->ulLossPrice*1.01F);
        return (0xFFFFFFFF);
    }
    for (i=0;i<8;i++, pstMin30Price++) {
        if (0xCCCCCCCC != pstMin30Price->ulFlag) break;
    }
    if (i>1) {
        ulSellPrice = pstCurrData->astMin30Price[i-2].ulEnd;
    }
    else {
        ulSellPrice = RandomUlong(pstCurrData->stDailyPrice.ulLow, pstCurrData->stDailyPrice.ulHigh);
    }
    return ulSellPrice;
}

canonical_original_code:
unsigned long RISE_GetSellPrice(struct tagWholeData *pstCurrData, struct tagStockCtrl *pstStockCtrl)
{
    unsigned long i;
    unsigned long ulSellPrice;
    struct tagPrice *pstMin30Price = pstCurrData->astMin30Price;
    if ((1) > GetDateInterval(pstStockCtrl->ulBuyDate, pstCurrData->ulDate)) {
        pstStockCtrl->ulLossPrice=(ULONG)(pstStockCtrl->ulLossPrice*1.01F);
        return (0xFFFFFFFF);
    }
    for (i=0;i<8;i++, pstMin30Price++) {
        if (0xCCCCCCCC != pstMin30Price->ulFlag) break;
    }
    if (i>1) {
        ulSellPrice = pstCurrData->astMin30Price[i-2].ulEnd;
    }
    else {
        ulSellPrice = RandomUlong(pstCurrData->stDailyPrice.ulLow, pstCurrData->stDailyPrice.ulHigh);
    }
    return ulSellPrice;
}

variable_types:
i
unsigned long

variable_types:
ulSellPrice
unsigned long

variable_types: struct tagPrice { unsigned int ulBegin; unsigned int ulHigh; unsigned int ulLow; unsigned int ulEnd; unsigned int ulVol; unsigned int ulFlag; } *


GetMethod

decompiled_code:
__int64 __fastcall GetMethod(char *s1)
{
if ( !strcasecmp(s1, "rise") )
return 1LL;
if ( !strcasecmp(s1, "sma") )
return 2LL;
if ( !strcasecmp(s1, "mma") )
return 3LL;
if ( strcasecmp(s1, "oma") )
{
puts("invaild method type");
exit(2);
}
return 4LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *s1)
{
if ( !strcasecmp(s1, "rise") )
return 1LL;
if ( !strcasecmp(s1, "sma") )
return 2LL;
if ( !strcasecmp(s1, "mma") )
return 3LL;
if ( strcasecmp(s1, "oma") )
{
puts("invaild method type");
exit(2);
}
return 4LL;
}

original_code:
ULONG GetMethod( CHAR* szMethod)
{
    ULONG ulMethod;
    if (0 == strcasecmp(szMethod, "rise")) {
        ulMethod = (0x0001);
    }
    else if (0 == strcasecmp(szMethod, "sma")) {
        ulMethod = (0x0002);
    }
    else if (0 == strcasecmp(szMethod, "mma")) {
        ulMethod = (0x0003);
    }
    else if (0 == strcasecmp(szMethod, "oma")) {
        ulMethod = (0x0004);
    }
    else {
        printf("invaild method type\n");
        ulMethod = (0xFFFFFFFF);
        exit(2);
    }
    return ulMethod;
}

canonical_original_code:
unsigned long GetMethod(char *szMethod)
{
    unsigned long ulMethod;
    if (0 == strcasecmp(szMethod, "rise")) {
        ulMethod = (0x0001);
    }
    else if (0 == strcasecmp(szMethod, "sma")) {
        ulMethod = (0x0002);
    }
    else if (0 == strcasecmp(szMethod, "mma")) {
        ulMethod = (0x0003);
    }
    else if (0 == strcasecmp(szMethod, "oma")) {
        ulMethod = (0x0004);
    }
    else {
        printf("invaild method type\n");
        ulMethod = (0xFFFFFFFF);
        exit(2);
    }
    return ulMethod;
}

variable_types:
szMethod
char *

variable_types:
ulMethod
unsigned long


original_code:
VOID FILE_UpdateDailyPrice( ULONG ulCode, const CHAR *szSrcDir, const CHAR *szTrgDir)
{
    ULONG i,j;
    ULONG ulSrcEntryCnt, ulOgEntryCnt, ulTrgEntryCnt;
    ULONG ulRemainingCnt;
    FILE_THS_DAILY_ENTRY_S *astDailyData = ((void *)0);
    FILE_THS_DAILY_ENTRY_S *pstDailyData = ((void *)0);
    FILE_WHOLE_DATA_S *astOgData = ((void *)0);
    FILE_WHOLE_DATA_S *pstOgData = ((void *)0);
    FILE_WHOLE_DATA_S *astWholeData = ((void *)0);
    FILE_WHOLE_DATA_S *pstWholeData = ((void *)0);
    ((void) sizeof ((((void *)0) != szSrcDir) ? 1 : 0), __extension__ ({ if (((void *)0) != szSrcDir) ; else __assert_fail ("NULL != szSrcDir", "OrgData.c", 19, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((((void *)0) != szTrgDir) ? 1 : 0), __extension__ ({ if (((void *)0) != szTrgDir) ; else __assert_fail ("NULL != szTrgDir", "OrgData.c", 20, __extension__ __PRETTY_FUNCTION__); }));
    ulSrcEntryCnt = FILE_GetFileData(ulCode, szSrcDir, 0x10000024, (VOID**)&astDailyData);
    if (0==ulSrcEntryCnt) return;
    ulOgEntryCnt = FILE_GetFileData(ulCode, szTrgDir, 0xF0000000, (VOID**)&astOgData);
    astWholeData = malloc(sizeof(FILE_WHOLE_DATA_S) * (ulSrcEntryCnt+ulOgEntryCnt));
    ((void) sizeof ((((void *)0) != astWholeData) ? 1 : 0), __extension__ ({ if (((void *)0) != astWholeData) ; else __assert_fail ("NULL != astWholeData", "OrgData.c", 30, __extension__ __PRETTY_FUNCTION__); }));
    memset(astWholeData, 0xFF, sizeof(FILE_WHOLE_DATA_S) * (ulSrcEntryCnt+ulOgEntryCnt));
    if (0 == ulOgEntryCnt) {
        astOgData = malloc(sizeof(FILE_WHOLE_DATA_S));
        ((void) sizeof ((((void *)0) != astOgData) ? 1 : 0), __extension__ ({ if (((void *)0) != astOgData) ; else __assert_fail ("NULL != astOgData", "OrgData.c", 35, __extension__ __PRETTY_FUNCTION__); }));
        memset(astOgData, 0xFF, sizeof(FILE_WHOLE_DATA_S));
    }
    pstDailyData = astDailyData;
    pstOgData = astOgData;
    pstWholeData = astWholeData;
    for (i=0,j=0;i<ulSrcEntryCnt;i++,pstDailyData++) {
        if ((0 == pstDailyData->ulDate) || ((0) == ((((pstDailyData->ulBeginWithCheck) & 0xF0000000) == (0xB0000000)) ? (1) : (0))) ||
            (0x80000000 == pstDailyData->ulVolWithCheck)) continue;
        for (;j<ulOgEntryCnt;j++) {
            if (pstDailyData->ulDate > pstOgData->ulDate) {
                memcpy(pstWholeData, pstOgData, sizeof(FILE_WHOLE_DATA_S));
                pstWholeData++;
                pstOgData++;
            }
            else {
                break;
            }
        }
        if (pstDailyData->ulDate == pstOgData->ulDate) {
            memcpy(pstWholeData, pstOgData, sizeof(FILE_WHOLE_DATA_S));
            pstOgData++;
            j++;
        }
        FILE_ThsDayToCustom(pstDailyData, pstWholeData);
        pstWholeData++;
    }
    ulRemainingCnt = ulOgEntryCnt-(pstOgData-astOgData);
    if (0 != ulRemainingCnt) {
        memcpy(pstWholeData, pstOgData, ulRemainingCnt*sizeof(FILE_WHOLE_DATA_S));
        pstWholeData += ulRemainingCnt;
    }
    ulTrgEntryCnt = pstWholeData - astWholeData;
    FILE_SetFileData(ulCode, szTrgDir, 0xF0000000, sizeof(FILE_WHOLE_DATA_S)*ulTrgEntryCnt,astWholeData);
    free(astDailyData);
    free(astOgData);
    free(astWholeData);
    return;
}

canonical_original_code:
void FILE_UpdateDailyPrice(unsigned long ulCode, char *szSrcDir, char *szTrgDir)
{
    unsigned long i; unsigned long j;
    unsigned long ulSrcEntryCnt; unsigned long ulOgEntryCnt; unsigned long ulTrgEntryCnt;
    unsigned long ulRemainingCnt;
    struct tagFileDailyData *astDailyData = ((void *)0);
    struct tagFileDailyData *pstDailyData = ((void *)0);
    struct tagWholeData *astOgData = ((void *)0);
    struct tagWholeData *pstOgData = ((void *)0);
    struct tagWholeData *astWholeData = ((void *)0);
    struct tagWholeData *pstWholeData = ((void *)0);
    ((void) sizeof ((((void *)0) != szSrcDir) ? 1 : 0), __extension__ ({ if (((void *)0) != szSrcDir) ; else __assert_fail ("NULL != szSrcDir", "OrgData.c", 19, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((((void *)0) != szTrgDir) ? 1 : 0), __extension__ ({ if (((void *)0) != szTrgDir) ; else __assert_fail ("NULL != szTrgDir", "OrgData.c", 20, __extension__ __PRETTY_FUNCTION__); }));
    ulSrcEntryCnt = FILE_GetFileData(ulCode, szSrcDir, 0x10000024, (void **)&astDailyData);
    if (0==ulSrcEntryCnt) return;
    ulOgEntryCnt = FILE_GetFileData(ulCode, szTrgDir, 0xF0000000, (void **)&astOgData);
    astWholeData = malloc(sizeof(FILE_WHOLE_DATA_S) * (ulSrcEntryCnt+ulOgEntryCnt));
    ((void) sizeof ((((void *)0) != astWholeData) ? 1 : 0), __extension__ ({ if (((void *)0) != astWholeData) ; else __assert_fail ("NULL != astWholeData", "OrgData.c", 30, __extension__ __PRETTY_FUNCTION__); }));
    memset(astWholeData, 0xFF, sizeof(FILE_WHOLE_DATA_S) * (ulSrcEntryCnt+ulOgEntryCnt));
    if (0 == ulOgEntryCnt) {
        astOgData = malloc(sizeof(FILE_WHOLE_DATA_S));
        ((void) sizeof ((((void *)0) != astOgData) ? 1 : 0), __extension__ ({ if (((void *)0) != astOgData) ; else __assert_fail ("NULL != astOgData", "OrgData.c", 35, __extension__ __PRETTY_FUNCTION__); }));
        memset(astOgData, 0xFF, sizeof(FILE_WHOLE_DATA_S));
    }
    pstDailyData = astDailyData;
    pstOgData = astOgData;
    pstWholeData = astWholeData;
    for (i=0,j=0;i<ulSrcEntryCnt;i++,pstDailyData++) {
        if ((0 == pstDailyData->ulDate) || ((0) == ((((pstDailyData->ulBeginWithCheck) & 0xF0000000) == (0xB0000000)) ? (1) : (0))) ||
            (0x80000000 == pstDailyData->ulVolWithCheck)) continue;
        for (;j<ulOgEntryCnt;j++) {
            if (pstDailyData->ulDate > pstOgData->ulDate) {
                memcpy(pstWholeData, pstOgData, sizeof(FILE_WHOLE_DATA_S));
                pstWholeData++;
                pstOgData++;
            }
            else {
                break;
            }
        }
        if (pstDailyData->ulDate == pstOgData->ulDate) {
            memcpy(pstWholeData, pstOgData, sizeof(FILE_WHOLE_DATA_S));
            pstOgData++;
            j++;
        }
        FILE_ThsDayToCustom(pstDailyData, pstWholeData);
        pstWholeData++;
    }
    ulRemainingCnt = ulOgEntryCnt-(pstOgData-astOgData);
    if (0 != ulRemainingCnt) {
        memcpy(pstWholeData, pstOgData, ulRemainingCnt*sizeof(FILE_WHOLE_DATA_S));
        pstWholeData += ulRemainingCnt;
    }
    ulTrgEntryCnt = pstWholeData - astWholeData;
    FILE_SetFileData(ulCode, szTrgDir, 0xF0000000, sizeof(FILE_WHOLE_DATA_S)*ulTrgEntryCnt,astWholeData);
    free(astDailyData);
    free(astOgData);
    free(astWholeData);
    return;
}

variable_types:
ulCode
unsigned long

variable_types:
szSrcDir
char *

variable_types:
szTrgDir
char *

variable_types:
j
unsigned long

variable_types:
ulSrcEntryCnt
unsigned long

variable_types:
ulOgEntryCnt
unsigned long

variable_types:
ulTrgEntryCnt
unsigned long

variable_types:
ulRemainingCnt
unsigned long

variable_types: struct tagFileDailyData { unsigned int ulDate; unsigned int ulBeginWithCheck; unsigned int ulHighWithCheck; unsigned int ulLowWithCheck; unsigned int ulEndWithCheck; unsigned int ulRsv; unsigned int ulVolWithCheck; unsigned char aucRsv[-1]; } *

variable_types: struct tagWholeData { char szComment[16]; unsigned int ulDate; unsigned int ulRsv; struct tagPrice { unsigned int ulBegin; unsigned int ulHigh; unsigned int ulLow; unsigned int ulEnd; unsigned int ulVol; unsigned int ulFlag; } stDailyPrice; struct tagPrice astMin30Price[8]; struct tagFactor { unsigned int ulFlag; float fMulti; float fAdder; } stFactor; unsigned int ulPad; } *


decompiled_code:
void __fastcall FILE_UpdateMin30Price(__int64 a1, __int64 a2, __int64 a3)
{
unsigned __int64 v3; // r12
unsigned __int64 v4; // r15
unsigned int *v5; // r13
_DWORD *v6; // rbx
unsigned __int64 v7; // rbp
unsigned __int64 v8; // r14
__int64 v9; // rsi
void *ptr; // [rsp+10h] [rbp-48h] BYREF
void *v12; // [rsp+18h] [rbp-40h] BYREF

ptr = 0LL;
v12 = 0LL;
if ( !a2 )
_assert_fail("NULL != szSrcDir", "OrgData.c", 0x64u, "FILE_UpdateMin30Price");
if ( !a3 )
_assert_fail("NULL != szTrgDir", "OrgData.c", 0x65u, "FILE_UpdateMin30Price");
v3 = FILE_GetFileData(a1, a2, 268435461LL, &ptr);
if ( !v3 )
return;
v4 = FILE_GetFileData(a1, a3, 4026531840LL, &v12);
if ( !v4 )
_assert_fail("0!=ulOgEntryCnt", "OrgData.c", 0x6Bu, "FILE_UpdateMin30Price");
v5 = (unsigned int *)ptr;
v6 = v12;
v7 = 0LL;
v8 = 0LL;
while ( 1 )
{
v9 = FILE_ThsMin2Date(*v5);
if ( v4 > v7 )
{
while ( v6[4] != v9 )
{
++v7;
v6 += 64;
if ( v4 == v7 )
goto LABEL_12;
}
goto LABEL_10;
}
LABEL_12:
if ( v6[4] != v9 )
break;
LABEL_10:
v8 += FILE_ThsMin5ToMin30(v5, v6);
v5 = (unsigned int *)((char *)ptr + 136 * v8);
if ( v3 <= v8 )
goto LABEL_11;
}
printf("daily entry of %ld is not exist\n", v9);
LABEL_11:
FILE_SetFileData(a1, a3, 4026531840LL, v4 << 8, v12);
free(ptr);
free(v12);
}

canonical_decompiled_code:
void __fastcall func1(__int64 a1, __int64 a2, __int64 a3)
{
unsigned __int64 v3; // r12
unsigned __int64 v4; // r15
unsigned int *v5; // r13
_DWORD *v6; // rbx
unsigned __int64 v7; // rbp
unsigned __int64 v8; // r14
__int64 v9; // rsi
void *ptr; // [rsp+10h] [rbp-48h] BYREF
void *v12; // [rsp+18h] [rbp-40h] BYREF

ptr = 0LL;
v12 = 0LL;
if ( !a2 )
_assert_fail("NULL != szSrcDir", "OrgData.c", 0x64u, "FILE_UpdateMin30Price");
if ( !a3 )
_assert_fail("NULL != szTrgDir", "OrgData.c", 0x65u, "FILE_UpdateMin30Price");
v3 = FILE_GetFileData(a1, a2, 268435461LL, &ptr);
if ( !v3 )
return;
v4 = FILE_GetFileData(a1, a3, 4026531840LL, &v12);
if ( !v4 )
_assert_fail("0!=ulOgEntryCnt", "OrgData.c", 0x6Bu, "FILE_UpdateMin30Price");
v5 = (unsigned int *)ptr;
v6 = v12;
v7 = 0LL;
v8 = 0LL;
while ( 1 )
{
v9 = FILE_ThsMin2Date(*v5);
if ( v4 > v7 )
{
while ( v6[4] != v9 )
{
++v7;
v6 += 64;
if ( v4 == v7 )
goto LABEL_12;
}
goto LABEL_10;
}
LABEL_12:
if ( v6[4] != v9 )
break;
LABEL_10:
v8 += FILE_ThsMin5ToMin30(v5, v6);
v5 = (unsigned int *)((char *)ptr + 136 * v8);
if ( v3 <= v8 )
goto LABEL_11;
}
printf("daily entry of %ld is not exist\n", v9);
LABEL_11:
FILE_SetFileData(a1, a3, 4026531840LL, v4 << 8, v12);
free(ptr);
free(v12);
}

original_code:
VOID FILE_UpdateMin30Price( ULONG ulCode, const CHAR *szSrcDir, const CHAR *szTrgDir)
{
    ULONG i, j;
    ULONG ulSrcEntryCnt, ulOgEntryCnt;
    ULONG ulCurrDate;
    FILE_THS_MIN5_ENTRY_S *astMin5Data = ((void *)0);
    FILE_THS_MIN5_ENTRY_S *pstMin5Data = ((void *)0);
    FILE_WHOLE_DATA_S *astOgData = ((void *)0);
    FILE_WHOLE_DATA_S *pstOgData = ((void *)0);
    ((void) sizeof ((((void *)0) != szSrcDir) ? 1 : 0), __extension__ ({ if (((void *)0) != szSrcDir) ; else __assert_fail ("NULL != szSrcDir", "OrgData.c", 100, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((((void *)0) != szTrgDir) ? 1 : 0), __extension__ ({ if (((void *)0) != szTrgDir) ; else __assert_fail ("NULL != szTrgDir", "OrgData.c", 101, __extension__ __PRETTY_FUNCTION__); }));
    ulSrcEntryCnt = FILE_GetFileData(ulCode, szSrcDir, 0x10000005, (VOID**)&astMin5Data);
    if (0 == ulSrcEntryCnt) return;
    ulOgEntryCnt = FILE_GetFileData(ulCode, szTrgDir, 0xF0000000, (VOID**)&astOgData);
    ((void) sizeof ((0!=ulOgEntryCnt) ? 1 : 0), __extension__ ({ if (0!=ulOgEntryCnt) ; else __assert_fail ("0!=ulOgEntryCnt", "OrgData.c", 107, __extension__ __PRETTY_FUNCTION__); }));
    i = j = 0;
    pstMin5Data = astMin5Data;
    pstOgData = astOgData;
    while (i<ulSrcEntryCnt) {
        ulCurrDate = FILE_ThsMin2Date(pstMin5Data->ulMin);
        for (;j<ulOgEntryCnt;j++,pstOgData++) {
            if (ulCurrDate == pstOgData->ulDate) break;
        }
        if (ulCurrDate != pstOgData->ulDate) {
            printf("daily entry of %ld is not exist\n", ulCurrDate);
            break;
        }
        i += FILE_ThsMin5ToMin30(pstMin5Data, pstOgData);
        pstMin5Data=astMin5Data+i;
    }
    FILE_SetFileData(ulCode, szTrgDir, 0xF0000000, sizeof(FILE_WHOLE_DATA_S)*ulOgEntryCnt, astOgData);
    free(astMin5Data);
    free(astOgData);
    return;
}

canonical_original_code:
void FILE_UpdateMin30Price(unsigned long ulCode, char *szSrcDir, char *szTrgDir)
{
    unsigned long i; unsigned long j;
    unsigned long ulSrcEntryCnt; unsigned long ulOgEntryCnt;
    unsigned long ulCurrDate;
    struct tagFile5MinuteData *astMin5Data = ((void *)0);
    struct tagFile5MinuteData *pstMin5Data = ((void *)0);
    struct tagWholeData *astOgData = ((void *)0);
    struct tagWholeData *pstOgData = ((void *)0);
    ((void) sizeof ((((void *)0) != szSrcDir) ? 1 : 0), __extension__ ({ if (((void *)0) != szSrcDir) ; else __assert_fail ("NULL != szSrcDir", "OrgData.c", 100, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((((void *)0) != szTrgDir) ? 1 : 0), __extension__ ({ if (((void *)0) != szTrgDir) ; else __assert_fail ("NULL != szTrgDir", "OrgData.c", 101, __extension__ __PRETTY_FUNCTION__); }));
    ulSrcEntryCnt = FILE_GetFileData(ulCode, szSrcDir, 0x10000005, (void **)&astMin5Data);
    if (0 == ulSrcEntryCnt) return;
    ulOgEntryCnt = FILE_GetFileData(ulCode, szTrgDir, 0xF0000000, (void **)&astOgData);
    ((void) sizeof ((0!=ulOgEntryCnt) ? 1 : 0), __extension__ ({ if (0!=ulOgEntryCnt) ; else __assert_fail ("0!=ulOgEntryCnt", "OrgData.c", 107, __extension__ __PRETTY_FUNCTION__); }));
    i = j = 0;
    pstMin5Data = astMin5Data;
    pstOgData = astOgData;
    while (i<ulSrcEntryCnt) {
        ulCurrDate = FILE_ThsMin2Date(pstMin5Data->ulMin);
        for (;j<ulOgEntryCnt;j++,pstOgData++) {
            if (ulCurrDate == pstOgData->ulDate) break;
        }
        if (ulCurrDate != pstOgData->ulDate) {
            printf("daily entry of %ld is not exist\n", ulCurrDate);
            break;
        }
        i += FILE_ThsMin5ToMin30(pstMin5Data, pstOgData);
        pstMin5Data=astMin5Data+i;
    }
    FILE_SetFileData(ulCode, szTrgDir, 0xF0000000, sizeof(FILE_WHOLE_DATA_S)*ulOgEntryCnt, astOgData);
    free(astMin5Data);
    free(astOgData);
    return;
}

variable_types:
ulCurrDate
unsigned long

variable_types: struct tagFile5MinuteData { unsigned int ulMin; unsigned int ulBeginWithCheck; unsigned int ulHighWithCheck; unsigned int ulLowWithCheck; unsigned int ulEndWithCheck; unsigned int ulRsv; unsigned int ulVolWithCheck; unsigned char aucRsv[-1]; } *


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbp
__int64 v4; // r12

if ( (unsigned int)(argc - 4) > 2 )
{
printf("USAGE: %s code source_path target_path [debug] [verbose]", *argv);
exit(1);
}
v3 = argc;
v4 = GetCodeByIndex(argv[1]);
if ( !strcasecmp(argv[v3 - 1], "debug") || !strcasecmp(argv[v3 - 2], "debug") )
g_bIsDebugMode = 1;
FILE_UpdateDailyPrice(v4, (__int64)argv[2], (__int64)argv[3]);
FILE_UpdateMin30Price(v4, (__int64)argv[2], (__int64)argv[3]);
FILE_UpdateWeight(v4, (__int64)argv[2], (__int64)argv[3]);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbp
__int64 v4; // r12

if ( (unsigned int)(argc - 4) > 2 )
{
printf("USAGE: %s code source_path target_path [debug] [verbose]", *argv);
exit(1);
}
v3 = argc;
v4 = GetCodeByIndex(argv[1]);
if ( !strcasecmp(argv[v3 - 1], "debug") || !strcasecmp(argv[v3 - 2], "debug") )
g_bIsDebugMode = 1;
func0(v4, (__int64)argv[2], (__int64)argv[3]);
func1(v4, (__int64)argv[2], (__int64)argv[3]);
func2(v4, (__int64)argv[2], (__int64)argv[3]);
return 0;
}

original_code:
int main(int argc,char *argv[])
{
    ULONG ulStockCode;
    if ((argc < 4) || (argc > 6)) {
        printf("USAGE: %s code source_path target_path [debug] [verbose]", argv[0]);
        exit(1);
    }
    ulStockCode = GetCodeByIndex(argv[1]);
    if ((0 == strcasecmp(argv[argc-1], "debug")) || (0 == strcasecmp(argv[argc-2], "debug")))
        g_bIsDebugMode = (1);
    FILE_UpdateDailyPrice(ulStockCode, argv[2], argv[3]);
    FILE_UpdateMin30Price(ulStockCode, argv[2], argv[3]);
    FILE_UpdateWeight(ulStockCode, argv[2], argv[3]);
    return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
    unsigned long ulStockCode;
    if ((argc < 4) || (argc > 6)) {
        printf("USAGE: %s code source_path target_path [debug] [verbose]", argv[0]);
        exit(1);
    }
    ulStockCode = GetCodeByIndex(argv[1]);
    if ((0 == strcasecmp(argv[argc-1], "debug")) || (0 == strcasecmp(argv[argc-2], "debug")))
        g_bIsDebugMode = (1);
    FILE_UpdateDailyPrice(ulStockCode, argv[2], argv[3]);
    FILE_UpdateMin30Price(ulStockCode, argv[2], argv[3]);
    FILE_UpdateWeight(ulStockCode, argv[2], argv[3]);
    return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types:
ulStockCode
unsigned long


decompiled_code:
int __fastcall STAT_PrintWatch(__int64 a1, unsigned __int64 a2, __int64 a3, __int64 a4)
{
__int64 v6; // r12
int v7[7]; // [rsp+0h] [rbp-1Ch] BYREF

if ( a3 + a1 >= a2 )
return printf("-100,-100,");
v6 = a4 + (a3 << 8);
GetTotalRise(a3, v6, 3LL, v7);
printf("%f,", *(float *)v7);
GetTotalRise(a3, v6, 2LL, v7);
return printf("%f,", *(float *)v7);
}

canonical_decompiled_code:
int __fastcall func0(__int64 a1, unsigned __int64 a2, __int64 a3, __int64 a4)
{
__int64 v6; // r12
int v7[7]; // [rsp+0h] [rbp-1Ch] BYREF

if ( a3 + a1 >= a2 )
return printf("-100,-100,");
v6 = a4 + (a3 << 8);
GetTotalRise(a3, v6, 3LL, v7);
printf("%f,", *(float *)v7);
GetTotalRise(a3, v6, 2LL, v7);
return printf("%f,", *(float *)v7);
}

original_code:
VOID STAT_PrintWatch( ULONG ulIndex, ULONG ulEntryCnt, ULONG ulWatchDays, FILE_WHOLE_DATA_S *pstCurr)
{
    FLOAT fWatchRise;
    if ((ulIndex+ulWatchDays)>=ulEntryCnt) {
        printf("-100,-100,");
    }
    else {
        (VOID)GetTotalRise(ulWatchDays, pstCurr+ulWatchDays, (0x03UL), &fWatchRise);
        printf("%f,", fWatchRise);
        (VOID)GetTotalRise(ulWatchDays, pstCurr+ulWatchDays, (0x02UL), &fWatchRise);
        printf("%f,", fWatchRise);
    }
    return;
}

canonical_original_code:
void STAT_PrintWatch(unsigned long ulIndex, unsigned long ulEntryCnt, unsigned long ulWatchDays, struct tagWholeData *pstCurr)
{
    float fWatchRise;
    if ((ulIndex+ulWatchDays)>=ulEntryCnt) {
        printf("-100,-100,");
    }
    else {
        (void)GetTotalRise(ulWatchDays, pstCurr+ulWatchDays, (0x03UL), &fWatchRise);
        printf("%f,", fWatchRise);
        (void)GetTotalRise(ulWatchDays, pstCurr+ulWatchDays, (0x02UL), &fWatchRise);
        printf("%f,", fWatchRise);
    }
    return;
}

variable_types:
ulIndex
unsigned long

variable_types:
ulEntryCnt
unsigned long

variable_types:
ulWatchDays
unsigned long

variable_types: fWatchRise float


decompiled_code:
void __fastcall STAT_Distribute(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
__int64 v8; // rax
__int64 v9; // r12
unsigned __int64 v10; // rbx
unsigned __int64 v11; // r12
void (__fastcall *v12)(unsigned __int64, char *); // r13
char *v13; // rbp
unsigned __int64 v14; // rdi
char *v15; // rsi
void *ptr; // [rsp+8h] [rbp-80h] BYREF
char v17[40]; // [rsp+10h] [rbp-78h] BYREF
void (__fastcall *v18)(unsigned __int64, char *); // [rsp+38h] [rbp-50h]

ptr = 0LL;
v8 = FILE_GetFileData(a1, a2, 4026531840LL, &ptr);
if ( v8 )
{
v9 = v8;
v10 = GetIndexByDate(a4, 17LL, v8, ptr);
v11 = GetIndexByDate(a5, 16LL, v9, ptr);
if ( v10 > v11 )
{
DebugOutString("%lu: invaild begin date: %lu, end date: %lu\n", a1, a4, a5);
free(ptr);
}
else
{
METHOD_GetFuncSet(a3, v17);
v12 = v18;
v13 = (char *)ptr + 256 * v10;
do
{
v14 = v10++;
v15 = v13;
v13 += 256;
v12(v14, v15);
}
while ( v11 >= v10 );
free(ptr);
}
}
}

canonical_decompiled_code:
void __fastcall func1(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
__int64 v8; // rax
__int64 v9; // r12
unsigned __int64 v10; // rbx
unsigned __int64 v11; // r12
void (__fastcall *v12)(unsigned __int64, char *); // r13
char *v13; // rbp
unsigned __int64 v14; // rdi
char *v15; // rsi
void *ptr; // [rsp+8h] [rbp-80h] BYREF
char v17[40]; // [rsp+10h] [rbp-78h] BYREF
void (__fastcall *v18)(unsigned __int64, char *); // [rsp+38h] [rbp-50h]

ptr = 0LL;
v8 = FILE_GetFileData(a1, a2, 4026531840LL, &ptr);
if ( v8 )
{
v9 = v8;
v10 = GetIndexByDate(a4, 17LL, v8, ptr);
v11 = GetIndexByDate(a5, 16LL, v9, ptr);
if ( v10 > v11 )
{
DebugOutString("%lu: invaild begin date: %lu, end date: %lu\n", a1, a4, a5);
free(ptr);
}
else
{
METHOD_GetFuncSet(a3, v17);
v12 = v18;
v13 = (char *)ptr + 256 * v10;
do
{
v14 = v10++;
v15 = v13;
v13 += 256;
v12(v14, v15);
}
while ( v11 >= v10 );
free(ptr);
}
}
}

original_code:
VOID STAT_Distribute( ULONG ulCode, CHAR *szDir, ULONG ulMethod, ULONG ulBeginDate, ULONG ulEndDate)
{
    ULONG i, ulEntryCnt;
    ULONG ulBeginIndex, ulEndIndex;
    METHOD_FUNC_SET_S stMethodFunc;
    Choose_PF pfChoose = ((void *)0);
    Statistics_PF pfStat = ((void *)0);
    CHOOSE_PRE_DEAL_S stDealInfo;
    FILE_WHOLE_DATA_S *astWholeData = ((void *)0);
    FILE_WHOLE_DATA_S *pstStatData = ((void *)0);
    ulEntryCnt = FILE_GetFileData(ulCode, szDir, 0xF0000000, (VOID**)&astWholeData);
    if (0 == ulEntryCnt) return;
    ulBeginIndex = GetIndexByDate(ulBeginDate, (0x11), ulEntryCnt, astWholeData);
    ulEndIndex = GetIndexByDate(ulEndDate, (0x10), ulEntryCnt, astWholeData);
    if (ulBeginIndex>ulEndIndex) {
        DebugOutString("%lu: invaild begin date: %lu, end date: %lu\n", ulCode, ulBeginDate, ulEndDate);
        free(astWholeData);
        return;
    }
    METHOD_GetFuncSet(ulMethod, &stMethodFunc);
    pfChoose = stMethodFunc.pfDailyChoose;
    pfStat = stMethodFunc.pfStatistics;
    memset(&stDealInfo, 0, sizeof(stDealInfo));
    for (i=ulBeginIndex,pstStatData = &astWholeData[ulBeginIndex];i<=ulEndIndex;i++, pstStatData++) {
        pfStat(i, pstStatData);
    }
    free(astWholeData);
    return;
}

canonical_original_code:
void STAT_Distribute(unsigned long ulCode, char *szDir, unsigned long ulMethod, unsigned long ulBeginDate, unsigned long ulEndDate)
{
    unsigned long i; unsigned long ulEntryCnt;
    unsigned long ulBeginIndex; unsigned long ulEndIndex;
    struct tagMethodFuncSet stMethodFunc;
    unsigned short (*pfChoose)(unsigned long, struct tagWholeData *, struct tagPreDealInfo *) = ((void *)0);
    void (*pfStat)(unsigned long, struct tagWholeData *) = ((void *)0);
    struct tagPreDealInfo stDealInfo;
    struct tagWholeData *astWholeData = ((void *)0);
    struct tagWholeData *pstStatData = ((void *)0);
    ulEntryCnt = FILE_GetFileData(ulCode, szDir, 0xF0000000, (void **)&astWholeData);
    if (0 == ulEntryCnt) return;
    ulBeginIndex = GetIndexByDate(ulBeginDate, (0x11), ulEntryCnt, astWholeData);
    ulEndIndex = GetIndexByDate(ulEndDate, (0x10), ulEntryCnt, astWholeData);
    if (ulBeginIndex>ulEndIndex) {
        DebugOutString("%lu: invaild begin date: %lu, end date: %lu\n", ulCode, ulBeginDate, ulEndDate);
        free(astWholeData);
        return;
    }
    METHOD_GetFuncSet(ulMethod, &stMethodFunc);
    pfChoose = stMethodFunc.pfDailyChoose;
    pfStat = stMethodFunc.pfStatistics;
    memset(&stDealInfo, 0, sizeof(stDealInfo));
    for (i=ulBeginIndex,pstStatData = &astWholeData[ulBeginIndex];i<=ulEndIndex;i++, pstStatData++) {
        pfStat(i, pstStatData);
    }
    free(astWholeData);
    return;
}

variable_types:
ulCode
unsigned long

variable_types:
szDir
char *

variable_types:
ulMethod
unsigned long

variable_types:
ulBeginDate
unsigned long

variable_types:
ulEndDate
unsigned long

variable_types:
i
unsigned long

variable_types:
ulBeginIndex
unsigned long

variable_types:
ulEndIndex
unsigned long

variable_types: struct tagMethodFuncSet { unsigned long (*pfGetGainPrice)(struct tagWholeData { char szComment[16]; unsigned int ulDate; unsigned int ulRsv; struct tagPrice { unsigned int ulBegin; unsigned int ulHigh; unsigned int ulLow; unsigned int ulEnd; unsigned int ulVol; unsigned int ulFlag; } stDailyPrice; struct tagPrice astMin30Price[8]; struct tagFactor { unsigned int ulFlag; float fMulti; float fAdder; } stFactor; unsigned int ulPad; } *, struct tagStockCtrl { unsigned int ulGainPrice; unsigned int ulLossPrice; unsigned int ulBuyDate; unsigned int ulBuyPrice; unsigned int ulSellDate; unsigned int ulSellPrice; float fContext; } *); unsigned long (*pfGetLossPrice)(struct tagWholeData *, struct tagStockCtrl *); unsigned long (*pfGetBuyPrice)(struct tagWholeData *, unsigned long); unsigned long (*pfGetSellPrice)(struct tagWholeData *, struct tagStockCtrl *); unsigned short (*pfDailyChoose)(unsigned long, struct tagWholeData *, struct tagPreDealInfo { unsigned short bIsSell; unsigned short usDealHour; unsigned short usDealMin; unsigned short bIsHigher; float fThresholdPrice; float fWeight; } *); void (*pfStatistics)(unsigned long, struct tagWholeData *); void (*pfSetParam)(unsigned long, float *); }

variable_types: unsigned short (*)(unsigned long, struct tagWholeData { char szComment[16]; unsigned int ulDate; unsigned int ulRsv; struct tagPrice { unsigned int ulBegin; unsigned int ulHigh; unsigned int ulLow; unsigned int ulEnd; unsigned int ulVol; unsigned int ulFlag; } stDailyPrice; struct tagPrice astMin30Price[8]; struct tagFactor { unsigned int ulFlag; float fMulti; float fAdder; } stFactor; unsigned int ulPad; } *, struct tagPreDealInfo { unsigned short bIsSell; unsigned short usDealHour; unsigned short usDealMin; unsigned short bIsHigher; float fThresholdPrice; float fWeight; } *)

variable_types: void (*)(unsigned long, struct tagWholeData { char szComment[16]; unsigned int ulDate; unsigned int ulRsv; struct tagPrice { unsigned int ulBegin; unsigned int ulHigh; unsigned int ulLow; unsigned int ulEnd; unsigned int ulVol; unsigned int ulFlag; } stDailyPrice; struct tagPrice astMin30Price[8]; struct tagFactor { unsigned int ulFlag; float fMulti; float fAdder; } stFactor; unsigned int ulPad; } *)


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // r12
__int64 v4; // rbp
__int64 v5; // r13
__int64 v6; // r14
__int64 i; // rbx
__int64 v8; // rdi
__int64 v10[8]; // [rsp+8h] [rbp-40h] BYREF

v10[0] = 0LL;
if ( (unsigned int)(argc - 6) > 1 )
{
printf("USAGE: %s method path begin-date end-date { code | all } [debug]", *argv);
exit(1);
}
if ( !strcasecmp(argv[argc - 1], "debug") )
g_bIsDebugMode = 1;
v3 = GetMethod(argv[1]);
v4 = GetCodeList(argv[5], v10);
v5 = atol(argv[3]);
v6 = atol(argv[4]);
if ( v4 )
{
for ( i = 0LL; i != v4; ++i )
{
v8 = *(_QWORD *)(v10[0] + 8 * i);
STAT_Distribute(v8, (__int64)argv[2], v3, v5, v6);
}
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // r12
__int64 v4; // rbp
__int64 v5; // r13
__int64 v6; // r14
__int64 i; // rbx
__int64 v8; // rdi
__int64 v10[8]; // [rsp+8h] [rbp-40h] BYREF

v10[0] = 0LL;
if ( (unsigned int)(argc - 6) > 1 )
{
printf("USAGE: %s method path begin-date end-date { code | all } [debug]", *argv);
exit(1);
}
if ( !strcasecmp(argv[argc - 1], "debug") )
g_bIsDebugMode = 1;
v3 = GetMethod(argv[1]);
v4 = GetCodeList(argv[5], v10);
v5 = atol(argv[3]);
v6 = atol(argv[4]);
if ( v4 )
{
for ( i = 0LL; i != v4; ++i )
{
v8 = *(_QWORD *)(v10[0] + 8 * i);
func1(v8, (__int64)argv[2], v3, v5, v6);
}
}
return 0;
}

original_code:
int main(int argc,char *argv[])
{
    ULONG i, ulCodeCnt;
    ULONG ulMethod;
    ULONG ulBeginDate, ulEndDate;
    ULONG *pulCodeList = ((void *)0);
    if ((argc < 6) || (argc > 7)) {
        printf("USAGE: %s method path begin-date end-date { code | all } [debug]", argv[0]);
        exit(1);
    }
    if (0 == strcasecmp(argv[argc-1], "debug"))
        g_bIsDebugMode = (1);
    ulMethod = GetMethod(argv[1]);
    ulCodeCnt = GetCodeList(argv[5], &pulCodeList);
    ulBeginDate = (ULONG)atol(argv[3]);
    ulEndDate = (ULONG)atol(argv[4]);
    for (i=0;i<ulCodeCnt;i++) {
        STAT_Distribute(pulCodeList[i], argv[2], ulMethod, ulBeginDate, ulEndDate);
    }
    return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
    unsigned long i; unsigned long ulCodeCnt;
    unsigned long ulMethod;
    unsigned long ulBeginDate; unsigned long ulEndDate;
    unsigned long *pulCodeList = ((void *)0);
    if ((argc < 6) || (argc > 7)) {
        printf("USAGE: %s method path begin-date end-date { code | all } [debug]", argv[0]);
        exit(1);
    }
    if (0 == strcasecmp(argv[argc-1], "debug"))
        g_bIsDebugMode = (1);
    ulMethod = GetMethod(argv[1]);
    ulCodeCnt = GetCodeList(argv[5], &pulCodeList);
    ulBeginDate = (unsigned long)atol(argv[3]);
    ulEndDate = (unsigned long)atol(argv[4]);
    for (i=0;i<ulCodeCnt;i++) {
        STAT_Distribute(pulCodeList[i], argv[2], ulMethod, ulBeginDate, ulEndDate);
    }
    return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types:
ulCodeCnt
unsigned long

variable_types:
pulCodeList
unsigned long *


decompiled_code:
__int64 __fastcall CHECK_IsPriceFit(unsigned __int64 a1, unsigned __int64 a2, char a3)
{
return ((a2 >> a3) + a2 >= a1) & (unsigned __int8)(a2 - (a2 >> a3) <= a1);
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned __int64 a1, unsigned __int64 a2, char a3)
{
return ((a2 >> a3) + a2 >= a1) & (unsigned __int8)(a2 - (a2 >> a3) <= a1);
}

original_code:
BOOL_T CHECK_IsPriceFit( ULONG ulCheckPrice, ULONG ulBasePrice, ULONG ulRange)
{
    ULONG ulPriceHigh = ulBasePrice + (ulBasePrice>>ulRange);
    ULONG ulPriceLow = ulBasePrice - (ulBasePrice>>ulRange);
    return ((ulCheckPrice < ulPriceLow) || (ulCheckPrice > ulPriceHigh)) ? (0) : (1);
}

canonical_original_code:
unsigned short CHECK_IsPriceFit(unsigned long ulCheckPrice, unsigned long ulBasePrice, unsigned long ulRange)
{
    unsigned long ulPriceHigh = ulBasePrice + (ulBasePrice>>ulRange);
    unsigned long ulPriceLow = ulBasePrice - (ulBasePrice>>ulRange);
    return ((ulCheckPrice < ulPriceLow) || (ulCheckPrice > ulPriceHigh)) ? (0) : (1);
}

variable_types:
ulCheckPrice
unsigned long

variable_types:
ulBasePrice
unsigned long

variable_types:
ulRange
unsigned long

variable_types:
ulPriceHigh
unsigned long

variable_types:
ulPriceLow
unsigned long


decompiled_code:
void __fastcall CHECK_CheckOne(__int64 a1, __int64 a2, __int64 a3)
{
unsigned __int64 v3; // rbp
unsigned int *v4; // r12
__int64 v5; // rdx
__int64 i; // rbx
__int64 v7; // rsi
unsigned int *v8; // r15
unsigned __int64 v9; // rbx
unsigned int *v10; // r15
unsigned __int64 v11; // r13
unsigned int *v12; // rax
__int64 v13; // r14
unsigned __int64 v14; // r12
__int64 v15; // rdx
__int64 v16; // rcx
__int64 v17; // r9
unsigned int v18; // er10
unsigned int v19; // er9
unsigned int v20; // er9
unsigned int v21; // er9
unsigned __int64 v22; // rax
unsigned __int64 v23; // [rsp+8h] [rbp-50h]
void *ptr; // [rsp+18h] [rbp-40h] BYREF

ptr = 0LL;
v23 = FILE_GetFileData(a1, a3, 4026531840LL, &ptr);
if ( v23 )
{
v4 = (unsigned int *)ptr;
v5 = *((unsigned int *)ptr + 4);
if ( v5 != a2 )
{
printf("start date = %lu, data has %lu\n", a2, v5);
v4 = (unsigned int *)ptr;
}
if ( v23 != 1 )
{
for ( i = 1LL; i != v23; ++i )
{
if ( v4[69] != -1 )
printf("%lu data invalid!\n", v4[68]);
v7 = v4[68];
if ( (unsigned int)v7 <= v4[4] )
printf("%lu data reverse!\n", v7);
v4 += 64;
}
v4 = (unsigned int *)ptr;
}
v8 = v4;
v9 = 0LL;
while ( v8[17] != -858993460 )
{
++v9;
v8 += 64;
if ( v23 == v9 )
goto LABEL_15;
}
DebugOutString("MIN30 starts at %lu\n", v8[4]);
if ( v23 > v9 )
{
v10 = v8 + 12;
do
{
v11 = v10[1];
v12 = v10;
v13 = 0LL;
v14 = v10[2];
v15 = 0LL;
while ( v12[5] == -858993460 )
{
v3 = v12[3];
if ( v11 < v12[1] )
v11 = v12[1];
if ( v14 > v12[2] )
v14 = v12[2];
v16 = v12[4];
++v15;
v12 += 6;
v13 += v16;
if ( v15 == 8 )
goto LABEL_25;
}
if ( !v15 )
{
printf("%lu min30 price miss!\n", *(v10 - 8));
goto LABEL_36;
}
LABEL_25:
if ( !(unsigned __int16)CHECK_IsPriceFit(*v10, *(v10 - 6), 3) )
printf("%lu begin price not march! %lu VS %lu\n", *(v10 - 8), v17, v18);
if ( !(unsigned __int16)CHECK_IsPriceFit(v11, *(v10 - 5), 6) )
printf("%lu high price not march! %lu VS %lu\n", *(v10 - 8), v11, v19);
if ( !(unsigned __int16)CHECK_IsPriceFit(v14, *(v10 - 4), 6) )
printf("%lu low price not march! %lu VS %lu\n", *(v10 - 8), v14, v20);
if ( !(unsigned __int16)CHECK_IsPriceFit(v3, *(v10 - 3), 4) )
printf("%lu end price not march! %lu VS %lu\n", *(v10 - 8), v3, v21);
v22 = *(v10 - 2);
if ( v22 < v13 - 25 || v22 > v13 + 10 )
printf("%lu volume not march! %lu VS %lu\n", *(v10 - 8), v22, v13);
LABEL_36:
++v9;
v10 += 64;
}
while ( v23 != v9 );
}
v4 = (unsigned int *)ptr;
LABEL_15:
free(v4);
}
else
{
puts("can't get data");
}
}

canonical_decompiled_code:
void __fastcall func1(__int64 a1, __int64 a2, __int64 a3)
{
unsigned __int64 v3; // rbp
unsigned int *v4; // r12
__int64 v5; // rdx
__int64 i; // rbx
__int64 v7; // rsi
unsigned int *v8; // r15
unsigned __int64 v9; // rbx
unsigned int *v10; // r15
unsigned __int64 v11; // r13
unsigned int *v12; // rax
__int64 v13; // r14
unsigned __int64 v14; // r12
__int64 v15; // rdx
__int64 v16; // rcx
__int64 v17; // r9
unsigned int v18; // er10
unsigned int v19; // er9
unsigned int v20; // er9
unsigned int v21; // er9
unsigned __int64 v22; // rax
unsigned __int64 v23; // [rsp+8h] [rbp-50h]
void *ptr; // [rsp+18h] [rbp-40h] BYREF

ptr = 0LL;
v23 = FILE_GetFileData(a1, a3, 4026531840LL, &ptr);
if ( v23 )
{
v4 = (unsigned int *)ptr;
v5 = *((unsigned int *)ptr + 4);
if ( v5 != a2 )
{
printf("start date = %lu, data has %lu\n", a2, v5);
v4 = (unsigned int *)ptr;
}
if ( v23 != 1 )
{
for ( i = 1LL; i != v23; ++i )
{
if ( v4[69] != -1 )
printf("%lu data invalid!\n", v4[68]);
v7 = v4[68];
if ( (unsigned int)v7 <= v4[4] )
printf("%lu data reverse!\n", v7);
v4 += 64;
}
v4 = (unsigned int *)ptr;
}
v8 = v4;
v9 = 0LL;
while ( v8[17] != -858993460 )
{
++v9;
v8 += 64;
if ( v23 == v9 )
goto LABEL_15;
}
DebugOutString("MIN30 starts at %lu\n", v8[4]);
if ( v23 > v9 )
{
v10 = v8 + 12;
do
{
v11 = v10[1];
v12 = v10;
v13 = 0LL;
v14 = v10[2];
v15 = 0LL;
while ( v12[5] == -858993460 )
{
v3 = v12[3];
if ( v11 < v12[1] )
v11 = v12[1];
if ( v14 > v12[2] )
v14 = v12[2];
v16 = v12[4];
++v15;
v12 += 6;
v13 += v16;
if ( v15 == 8 )
goto LABEL_25;
}
if ( !v15 )
{
printf("%lu min30 price miss!\n", *(v10 - 8));
goto LABEL_36;
}
LABEL_25:
if ( !(unsigned __int16)func0(*v10, *(v10 - 6), 3) )
printf("%lu begin price not march! %lu VS %lu\n", *(v10 - 8), v17, v18);
if ( !(unsigned __int16)func0(v11, *(v10 - 5), 6) )
printf("%lu high price not march! %lu VS %lu\n", *(v10 - 8), v11, v19);
if ( !(unsigned __int16)func0(v14, *(v10 - 4), 6) )
printf("%lu low price not march! %lu VS %lu\n", *(v10 - 8), v14, v20);
if ( !(unsigned __int16)func0(v3, *(v10 - 3), 4) )
printf("%lu end price not march! %lu VS %lu\n", *(v10 - 8), v3, v21);
v22 = *(v10 - 2);
if ( v22 < v13 - 25 || v22 > v13 + 10 )
printf("%lu volume not march! %lu VS %lu\n", *(v10 - 8), v22, v13);
LABEL_36:
++v9;
v10 += 64;
}
while ( v23 != v9 );
}
v4 = (unsigned int *)ptr;
LABEL_15:
free(v4);
}
else
{
puts("can't get data");
}
}

original_code:
VOID CHECK_CheckOne( ULONG ulCode, ULONG ulStartDate, CHAR *szDir)
{
    ULONG i, j, ulEntryCnt;
    ULONG ulHigh, ulLow, ulBegin, ulEnd, ulVol;
    FILE_WHOLE_DATA_S *astWholeData = ((void *)0);
    FILE_WHOLE_DATA_S *pstCurrData = ((void *)0);
    FILE_WHOLE_DATA_S *pstPrevData = ((void *)0);
    PRICE_S *pstMin30Price = ((void *)0);
    PRICE_S *pstDailyPrice = ((void *)0);
    ulEntryCnt = FILE_GetFileData(ulCode, szDir, 0xF0000000, (VOID**)&astWholeData);
    if (0 == ulEntryCnt) {
        printf("can't get data\n");
        return;
    }
    if (ulStartDate != astWholeData[0].ulDate) {
        printf("start date = %lu, data has %lu\n", ulStartDate, astWholeData[0].ulDate);
    }
    pstPrevData = astWholeData;
    pstCurrData = pstPrevData+1;
    for (i=1;i<ulEntryCnt;i++,pstPrevData++,pstCurrData++) {
        if ((0xFFFFFFFF) != pstCurrData->ulRsv) {
            printf("%lu data invalid!\n", pstCurrData->ulDate);
        }
        if (pstCurrData->ulDate <= pstPrevData->ulDate) {
            printf("%lu data reverse!\n", pstCurrData->ulDate);
        }
    }
    pstCurrData = astWholeData;
    for (i=0;i<ulEntryCnt;i++,pstCurrData++) {
        if (0xCCCCCCCC == pstCurrData->astMin30Price[0].ulFlag) {
            DebugOutString("MIN30 starts at %lu\n", pstCurrData->ulDate);
            break;
        }
    }
    for (;i<ulEntryCnt;i++,pstCurrData++) {
        pstMin30Price = pstCurrData->astMin30Price;
        ulBegin = pstMin30Price->ulBegin;
        ulHigh = pstMin30Price->ulHigh;
        ulLow = pstMin30Price->ulLow;
        ulVol = 0;
        for (j=0;j<8;j++, pstMin30Price++) {
            if (0xCCCCCCCC != pstMin30Price->ulFlag) break;
            ulHigh = (((ulHigh) > (pstMin30Price->ulHigh)) ? (ulHigh) : (pstMin30Price->ulHigh));
            ulLow = (((ulLow) < (pstMin30Price->ulLow)) ? (ulLow) : (pstMin30Price->ulLow));
            ulEnd = pstMin30Price->ulEnd;
            ulVol += pstMin30Price->ulVol;
        }
        if (0 == j) {
            printf("%lu min30 price miss!\n", pstCurrData->ulDate);
            continue;
        }
        pstDailyPrice = &(pstCurrData->stDailyPrice);
        if ((0) == CHECK_IsPriceFit(ulBegin, pstDailyPrice->ulBegin, 3))
            printf("%lu begin price not march! %lu VS %lu\n", pstCurrData->ulDate, ulBegin, pstDailyPrice->ulBegin);
        if ((0) == CHECK_IsPriceFit(ulHigh, pstDailyPrice->ulHigh, 6))
            printf("%lu high price not march! %lu VS %lu\n", pstCurrData->ulDate, ulHigh, pstDailyPrice->ulHigh);
        if ((0) == CHECK_IsPriceFit(ulLow, pstDailyPrice->ulLow, 6))
            printf("%lu low price not march! %lu VS %lu\n", pstCurrData->ulDate, ulLow, pstDailyPrice->ulLow);
        if ((0) == CHECK_IsPriceFit(ulEnd, pstDailyPrice->ulEnd, 4))
            printf("%lu end price not march! %lu VS %lu\n", pstCurrData->ulDate, ulEnd, pstDailyPrice->ulEnd);
        if ((pstDailyPrice->ulVol < ulVol-25) || (pstDailyPrice->ulVol > ulVol+10))
            printf("%lu volume not march! %lu VS %lu\n", pstCurrData->ulDate, pstDailyPrice->ulVol, ulVol);
    }
    free(astWholeData);
    return;
}

canonical_original_code:
void CHECK_CheckOne(unsigned long ulCode, unsigned long ulStartDate, char *szDir)
{
    unsigned long i; unsigned long j; unsigned long ulEntryCnt;
    unsigned long ulHigh; unsigned long ulLow; unsigned long ulBegin; unsigned long ulEnd; unsigned long ulVol;
    struct tagWholeData *astWholeData = ((void *)0);
    struct tagWholeData *pstCurrData = ((void *)0);
    struct tagWholeData *pstPrevData = ((void *)0);
    struct tagPrice *pstMin30Price = ((void *)0);
    struct tagPrice *pstDailyPrice = ((void *)0);
    ulEntryCnt = FILE_GetFileData(ulCode, szDir, 0xF0000000, (void **)&astWholeData);
    if (0 == ulEntryCnt) {
        printf("can't get data\n");
        return;
    }
    if (ulStartDate != astWholeData[0].ulDate) {
        printf("start date = %lu, data has %lu\n", ulStartDate, astWholeData[0].ulDate);
    }
    pstPrevData = astWholeData;
    pstCurrData = pstPrevData+1;
    for (i=1;i<ulEntryCnt;i++,pstPrevData++,pstCurrData++) {
        if ((0xFFFFFFFF) != pstCurrData->ulRsv) {
            printf("%lu data invalid!\n", pstCurrData->ulDate);
        }
        if (pstCurrData->ulDate <= pstPrevData->ulDate) {
            printf("%lu data reverse!\n", pstCurrData->ulDate);
        }
    }
    pstCurrData = astWholeData;
    for (i=0;i<ulEntryCnt;i++,pstCurrData++) {
        if (0xCCCCCCCC == pstCurrData->astMin30Price[0].ulFlag) {
            DebugOutString("MIN30 starts at %lu\n", pstCurrData->ulDate);
            break;
        }
    }
    for (;i<ulEntryCnt;i++,pstCurrData++) {
        pstMin30Price = pstCurrData->astMin30Price;
        ulBegin = pstMin30Price->ulBegin;
        ulHigh = pstMin30Price->ulHigh;
        ulLow = pstMin30Price->ulLow;
        ulVol = 0;
        for (j=0;j<8;j++, pstMin30Price++) {
            if (0xCCCCCCCC != pstMin30Price->ulFlag) break;
            ulHigh = (((ulHigh) > (pstMin30Price->ulHigh)) ? (ulHigh) : (pstMin30Price->ulHigh));
            ulLow = (((ulLow) < (pstMin30Price->ulLow)) ? (ulLow) : (pstMin30Price->ulLow));
            ulEnd = pstMin30Price->ulEnd;
            ulVol += pstMin30Price->ulVol;
        }
        if (0 == j) {
            printf("%lu min30 price miss!\n", pstCurrData->ulDate);
            continue;
        }
        pstDailyPrice = &(pstCurrData->stDailyPrice);
        if ((0) == CHECK_IsPriceFit(ulBegin, pstDailyPrice->ulBegin, 3))
            printf("%lu begin price not march! %lu VS %lu\n", pstCurrData->ulDate, ulBegin, pstDailyPrice->ulBegin);
        if ((0) == CHECK_IsPriceFit(ulHigh, pstDailyPrice->ulHigh, 6))
            printf("%lu high price not march! %lu VS %lu\n", pstCurrData->ulDate, ulHigh, pstDailyPrice->ulHigh);
        if ((0) == CHECK_IsPriceFit(ulLow, pstDailyPrice->ulLow, 6))
            printf("%lu low price not march! %lu VS %lu\n", pstCurrData->ulDate, ulLow, pstDailyPrice->ulLow);
        if ((0) == CHECK_IsPriceFit(ulEnd, pstDailyPrice->ulEnd, 4))
            printf("%lu end price not march! %lu VS %lu\n", pstCurrData->ulDate, ulEnd, pstDailyPrice->ulEnd);
        if ((pstDailyPrice->ulVol < ulVol-25) || (pstDailyPrice->ulVol > ulVol+10))
            printf("%lu volume not march! %lu VS %lu\n", pstCurrData->ulDate, pstDailyPrice->ulVol, ulVol);
    }
    free(astWholeData);
    return;
}

variable_types:
ulCode
unsigned long

variable_types:
ulStartDate
unsigned long

variable_types:
szDir
char *

variable_types:
j
unsigned long

variable_types:
ulEntryCnt
unsigned long

variable_types:
ulHigh
unsigned long

variable_types:
ulLow
unsigned long

variable_types:
ulBegin
unsigned long

variable_types:
ulEnd
unsigned long

variable_types:
ulVol
unsigned long

variable_types: struct tagWholeData { char szComment[16]; unsigned int ulDate; unsigned int ulRsv; struct tagPrice { unsigned int ulBegin; unsigned int ulHigh; unsigned int ulLow; unsigned int ulEnd; unsigned int ulVol; unsigned int ulFlag; } stDailyPrice; struct tagPrice astMin30Price[8]; struct tagFactor { unsigned int ulFlag; float fMulti; float fAdder; } stFactor; unsigned int ulPad; } *

variable_types: struct tagPrice { unsigned int ulBegin; unsigned int ulHigh; unsigned int ulLow; unsigned int ulEnd; unsigned int ulVol; unsigned int ulFlag; } *


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v4; // r13
__int64 i; // rbx
__int64 v6; // rbp
__int64 v7; // rdi
__int64 v8; // rsi
__int64 v10; // [rsp+0h] [rbp-38h] BYREF
void *ptr; // [rsp+8h] [rbp-30h] BYREF

v10 = 0LL;
ptr = 0LL;
if ( (unsigned int)(argc - 4) > 1 )
{
printf("USAGE: %s data-path weight-path { code | all } [debug]", *argv);
exit(1);
}
if ( !strcasecmp(argv[argc - 1], "debug") )
g_bIsDebugMode = 1;
v4 = GetCodeList(argv[3], &v10);
if ( v4 )
{
for ( i = 0LL; i != v4; ++i )
{
while ( FILE_GetFileData(*(_QWORD *)(v10 + 8 * i), argv[2], 536903680LL, &ptr) )
{
v6 = FILE_QlDate2Custom(*(unsigned int *)ptr);
free(ptr);
DebugOutString("========%06lu========\n", *(_QWORD *)(v10 + 8 * i));
v7 = *(_QWORD *)(v10 + 8 * i++);
CHECK_CheckOne(v7, v6, (__int64)argv[1]);
if ( v4 == i )
return 0;
}
v8 = *(_QWORD *)(v10 + 8 * i);
printf("weight of %06lu not exist!\n", v8);
}
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v4; // r13
__int64 i; // rbx
__int64 v6; // rbp
__int64 v7; // rdi
__int64 v8; // rsi
__int64 v10; // [rsp+0h] [rbp-38h] BYREF
void *ptr; // [rsp+8h] [rbp-30h] BYREF

v10 = 0LL;
ptr = 0LL;
if ( (unsigned int)(argc - 4) > 1 )
{
printf("USAGE: %s data-path weight-path { code | all } [debug]", *argv);
exit(1);
}
if ( !strcasecmp(argv[argc - 1], "debug") )
g_bIsDebugMode = 1;
v4 = GetCodeList(argv[3], &v10);
if ( v4 )
{
for ( i = 0LL; i != v4; ++i )
{
while ( FILE_GetFileData(*(_QWORD *)(v10 + 8 * i), argv[2], 536903680LL, &ptr) )
{
v6 = FILE_QlDate2Custom(*(unsigned int *)ptr);
free(ptr);
DebugOutString("========%06lu========\n", *(_QWORD *)(v10 + 8 * i));
v7 = *(_QWORD *)(v10 + 8 * i++);
func1(v7, v6, (__int64)argv[1]);
if ( v4 == i )
return 0;
}
v8 = *(_QWORD *)(v10 + 8 * i);
printf("weight of %06lu not exist!\n", v8);
}
}
return 0;
}

original_code:
int main(int argc,char *argv[])
{
    ULONG i, ulCodeCnt;
    ULONG ulStartDate;
    ULONG ulWgtCnt;
    ULONG *pulCodeList = ((void *)0);
    FILE_QL_WEIGHT_ENTRY_S *astWgtData = ((void *)0);
    if ((argc < 4) || (argc > 5)) {
        printf("USAGE: %s data-path weight-path { code | all } [debug]", argv[0]);
        exit(1);
    }
    if (0 == strcasecmp(argv[argc-1], "debug"))
        g_bIsDebugMode = (1);
    ulCodeCnt = GetCodeList(argv[3], &pulCodeList);
    for (i=0;i<ulCodeCnt;i++) {
        ulWgtCnt = FILE_GetFileData(pulCodeList[i], argv[2], 0x20008000, (VOID**)&astWgtData);
        if (0 == ulWgtCnt) {
            printf("weight of %06lu not exist!\n", pulCodeList[i]);
            continue;
        }
        ulStartDate = FILE_QlDate2Custom(astWgtData[0].ulQlDate);
        free(astWgtData);
        DebugOutString("========%06lu========\n", pulCodeList[i]);
        CHECK_CheckOne(pulCodeList[i], ulStartDate, argv[1]);
    }
    return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
    unsigned long i; unsigned long ulCodeCnt;
    unsigned long ulStartDate;
    unsigned long ulWgtCnt;
    unsigned long *pulCodeList = ((void *)0);
    struct tagFileWeight *astWgtData = ((void *)0);
    if ((argc < 4) || (argc > 5)) {
        printf("USAGE: %s data-path weight-path { code | all } [debug]", argv[0]);
        exit(1);
    }
    if (0 == strcasecmp(argv[argc-1], "debug"))
        g_bIsDebugMode = (1);
    ulCodeCnt = GetCodeList(argv[3], &pulCodeList);
    for (i=0;i<ulCodeCnt;i++) {
        ulWgtCnt = FILE_GetFileData(pulCodeList[i], argv[2], 0x20008000, (void **)&astWgtData);
        if (0 == ulWgtCnt) {
            printf("weight of %06lu not exist!\n", pulCodeList[i]);
            continue;
        }
        ulStartDate = FILE_QlDate2Custom(astWgtData[0].ulQlDate);
        free(astWgtData);
        DebugOutString("========%06lu========\n", pulCodeList[i]);
        CHECK_CheckOne(pulCodeList[i], ulStartDate, argv[1]);
    }
    return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types:
i
unsigned long

variable_types:
ulCodeCnt
unsigned long

variable_types:
ulWgtCnt
unsigned long

variable_types:
pulCodeList
unsigned long *

variable_types: struct tagFileWeight { unsigned int ulQlDate; unsigned int ulGift; unsigned int ulOffer; unsigned int ulOfferPrice; unsigned int ulProfit; unsigned int ulAdd; unsigned int ulTotalStock; unsigned int ulCirStock; unsigned int ulRsv; } *


GetCodeList

decompiled_code:
__int64 __fastcall GetCodeList(char *nptr, _QWORD *a2)
{
__int64 result; // rax
__int64 v4; // rsi
__int64 v5; // rax

if ( !strcasecmp(nptr, "all") )
{
*a2 = g_aulStockCode;
result = 2470LL;
}
else
{
v4 = atol(nptr);
v5 = 0LL;
while ( g_aulStockCode[v5] != v4 )
{
if ( ++v5 == 2470 )
{
DebugOutString("code %06lu not found!\n", v4);
return 0LL;
}
}
*a2 = &g_aulStockCode[v5];
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *nptr, _QWORD *a2)
{
__int64 result; // rax
__int64 v4; // rsi
__int64 v5; // rax

if ( !strcasecmp(nptr, "all") )
{
*a2 = g_aulStockCode;
result = 2470LL;
}
else
{
v4 = atol(nptr);
v5 = 0LL;
while ( g_aulStockCode[v5] != v4 )
{
if ( ++v5 == 2470 )
{
DebugOutString("code %06lu not found!\n", v4);
return 0LL;
}
}
*a2 = &g_aulStockCode[v5];
result = 1LL;
}
return result;
}

original_code:
ULONG GetCodeList( CHAR* szCode, ULONG **ppulList)
{
    ULONG i;
    ULONG ulCode;
    ULONG ulCodeCnt;
    if (0 == strcasecmp(szCode, "all")) {
        ulCodeCnt = g_ulTotalCount;
        *ppulList = g_aulStockCode;
    }
    else {
        ulCode = (ULONG)atol(szCode);
        for (i=0;i<g_ulTotalCount;i++) {
            if (ulCode == g_aulStockCode[i]) break;
        }
        if (g_ulTotalCount == i) {
            ulCodeCnt = 0;
            DebugOutString("code %06lu not found!\n", ulCode);
        }
        else {
            ulCodeCnt = 1;
            *ppulList = &g_aulStockCode[i];
        }
    }
    return ulCodeCnt;
}

canonical_original_code:
unsigned long GetCodeList(char *szCode, unsigned long **ppulList)
{
    unsigned long i;
    unsigned long ulCode;
    unsigned long ulCodeCnt;
    if (0 == strcasecmp(szCode, "all")) {
        ulCodeCnt = g_ulTotalCount;
        *ppulList = g_aulStockCode;
    }
    else {
        ulCode = (unsigned long)atol(szCode);
        for (i=0;i<g_ulTotalCount;i++) {
            if (ulCode == g_aulStockCode[i]) break;
        }
        if (g_ulTotalCount == i) {
            ulCodeCnt = 0;
            DebugOutString("code %06lu not found!\n", ulCode);
        }
        else {
            ulCodeCnt = 1;
            *ppulList = &g_aulStockCode[i];
        }
    }
    return ulCodeCnt;
}

variable_types:
szCode
char *

variable_types:
ppulList
unsigned long **

variable_types:
ulCode
unsigned long


repo: gitson/footex

decompiled_code:
int __fastcall print_arr(unsigned int *a1, int a2)
{
__int64 v2; // rbp
unsigned int *v3; // rbx
__int64 v4; // rsi

if ( a2 > 0 )
{
v2 = (__int64)&a1[a2 - 1 + 1];
v3 = a1;
do
{
v4 = *v3++;
printf("%d ", v4);
}
while ( v3 != (unsigned int *)v2 );
}
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func7(unsigned int *a1, int a2)
{
__int64 v2; // rbp
unsigned int *v3; // rbx
__int64 v4; // rsi

if ( a2 > 0 )
{
v2 = (__int64)&a1[a2 - 1 + 1];
v3 = a1;
do
{
v4 = *v3++;
printf("%d ", v4);
}
while ( v3 != (unsigned int *)v2 );
}
return putchar(10);
}

original_code:
void print_arr(int *arr, int n) {
 int i;
 for(i = 0; i < n; i++) {
  printf("%d ", arr[i]);
 }
 printf("\n");
}

variable_types:
arr
int *

variable_types: n int

variable_types: i int


decompiled_code:
__int64 __fastcall bubble_iter(int *a1, int a2)
{
int v2; // eax
__int64 i; // rsi
__int64 v5; // rdx
int *v6; // rbp
__int64 v7; // r8
__int64 v8; // rcx
int v10; // eax
int v11; // eax

v2 = a2 - 1;
for ( i = 0LL; ; i = (unsigned int)v8 )
{
if ( (int)i >= v2 )
return 1LL;
v5 = (unsigned int)*a1;
v6 = a1;
v7 = (unsigned int)a1[1];
++a1;
v8 = (unsigned int)(i + 1);
if ( (int)v5 > (int)v7 )
break;
}
printf("Swapping arr[%d]=%d and arr[%d]=%d\n", i, v5, v8, v7);
v10 = *a1 ^ *v6;
*v6 = v10;
v11 = *a1 ^ v10;
*a1 = v11;
*v6 ^= v11;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func8(int *a1, int a2)
{
int v2; // eax
__int64 i; // rsi
__int64 v5; // rdx
int *v6; // rbp
__int64 v7; // r8
__int64 v8; // rcx
int v10; // eax
int v11; // eax

v2 = a2 - 1;
for ( i = 0LL; ; i = (unsigned int)v8 )
{
if ( (int)i >= v2 )
return 1LL;
v5 = (unsigned int)*a1;
v6 = a1;
v7 = (unsigned int)a1[1];
++a1;
v8 = (unsigned int)(i + 1);
if ( (int)v5 > (int)v7 )
break;
}
printf("Swapping arr[%d]=%d and arr[%d]=%d\n", i, v5, v8, v7);
v10 = *a1 ^ *v6;
*v6 = v10;
v11 = *a1 ^ v10;
*a1 = v11;
*v6 ^= v11;
return 0LL;
}

original_code:
int bubble_iter(int *arr, int n) {
 int i;
 for(i = 0; i < n - 1; i++) {
  if(arr[i] > arr[i + 1]) {
   { printf("Swapping arr[%d]=%d and arr[%d]=%d\n", i, arr[i], i + 1, arr[i + 1]); arr[i]^=arr[i + 1];arr[i + 1]^=arr[i];arr[i]^=arr[i + 1];};
   return 0;
  }
 }
 return 1;
}


decompiled_code:
int __fastcall print_futex(int *a1)
{
int v1; // eax
const char *v2; // rdi

v1 = *a1;
v2 = "Locked";
if ( !v1 )
v2 = "Unlocked";
return puts(v2);
}

canonical_decompiled_code:
int __fastcall func9(int *a1)
{
int v1; // eax
const char *v2; // rdi

v1 = *a1;
v2 = "Locked";
if ( !v1 )
v2 = "Unlocked";
return puts(v2);
}

original_code:
void print_futex(int *futex_ptr) {
     printf("%s\n", (*futex_ptr) ? "Locked": "Unlocked");
}