When I use debug mode to build the code, the res is 0, correct. But After I use release mode to build the code, the res is 1. Even though I try to use the #pragma instruction to disable the compiler's optimalzation, the error is still existed.
here's the code:
#include <cstdio>
#define ulong unsigned __int64
void hashTransfer(const char * src, unsigned char hash[])
{
    sscanf_s(src, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
        &hash[0], &hash[1], &hash[2], &hash[3], &hash[4], &hash[5], &hash[6], &hash[7],
        &hash[8], &hash[9], &hash[10], &hash[11], &hash[12], &hash[13], &hash[14], &hash[15],
        &hash[16], &hash[17], &hash[18], &hash[19], &hash[20], &hash[21], &hash[22], &hash[23],
        &hash[24], &hash[25], &hash[26], &hash[27], &hash[28], &hash[29], &hash[30], &hash[31]);
}
#pragma optimize("", off)
bool compartor(const unsigned char* lhs, const unsigned char* rhs)
{
    const ulong* lhsP = (const ulong *)lhs;
    const ulong* rhsP = (const ulong *)rhs;
    ulong lhs4 = *(lhsP + 3);
    ulong lhs3 = *(lhsP + 2);
    ulong lhs2 = *(lhsP + 1);
    ulong lhs1 = *(lhsP);
    ulong rhs4 = *(rhsP + 3);
    ulong rhs3 = *(rhsP + 2);
    ulong rhs2 = *(rhsP + 1);
    ulong rhs1 = *(rhsP);
    //int a = lhs1 < rhs1;
    //int b = (lhs1 == rhs1 && lhs2 < rhs2);
    //int c = (lhs1 == rhs1 && lhs2 == rhs2 && lhs3 < rhs3);
    //int d = (lhs1 == rhs1 && lhs2 == rhs2 && lhs3 == rhs3 && lhs4 < rhs4);
    //printf("\n%llx %llx\n", lhs1, rhs1);
    //printf("%llx %llx\n", lhs2, rhs2);
    //printf("%llx %llx\n", lhs3, rhs3);
    //printf("%llx %llx\n", lhs4, rhs4);
    return (lhs1 < rhs1)
        || (lhs1 == rhs1 && lhs2 < rhs2)
        || (lhs1 == rhs1 && lhs2 == rhs2 && lhs3 < rhs3)
        || (lhs1 == rhs1 && lhs2 == rhs2 && lhs3 == rhs3 && lhs4 < rhs4);
}
#pragma optimize("", on)
int main()
{
    unsigned char hash1[32];
    hashTransfer("ff3f4036a1164d1ddbad5b3edf9022fddb3e1961a54a922708a6c1ffc49e5489", hash1);
    unsigned char hash2[32];
    hashTransfer("ff3f4036a1164d1ddbad5b3edf9022addb3e1961a54a922708a6c1ffc49e5489", hash2);
    bool res = 0;
    res = compartor(hash1, hash2);
    printf("%d", res);
    getchar();
    return 0;
}
 
    