1

The code below is executed with the parameters (0, 4, 0) , the first 0 being an int pointer casted to an int, and these are the same every time. After execution, a 3 digit number string is returned/assigned to result e.g. "817". But this number string can change and be different values, but I don't understand how this could be the case if the parameters passed to the function are all constant?

unsigned int __fastcall sub_CD16FABC(unsigned int result, int a2, int a3)
{
  int v3; // r7
  signed int v4; // r3
  bool v5; // zf
  bool v6; // nf
  unsigned __int8 v7; // vf
  char v8; // r1
  int v9; // r2
  char v10; // r1
  char v11; // lr
  int v12; // r8
  int v13; // r1
  signed int v14; // r7
  int v15; // r3
  char v16; // [sp+2h] [bp-1Ah]
  char v17; // [sp+3h] [bp-19h]

  v3 = -a3 - (unsigned __int8)result;
  v4 = (((result >> 8) ^ 0xFFFF00) & (result >> 8)) + a3;
  v7 = __OFSUB__(a2, 3);
  v5 = a2 == 3;
  v6 = a2 - 3 < 0;
  v8 = 0;
  v9 = a3 + (unsigned __int8)__ROR4__(result, 16);
  if ( !((unsigned __int8)(v6 ^ v7) | v5) )
    v8 = 1;
  v17 = v8;
  v10 = result;
  if ( result )
    v10 = 1;
  v16 = v10;
  v11 = v4
      - 10
      * (((signed int)((unsigned __int64)(1717986919LL * v4) >> 32) >> 2)
       + ((((unsigned __int64)(1717986919LL * v4) >> 32) & 0x80000000) != 0LL))
      + 48;
  v12 = v9 % 10 + 48;
  v13 = -v3 % 10;
  v14 = -1319380658;
  while ( 1 )
  {
    v15 = v14 & 0x7FFFFFFF;
    if ( (v14 & 0x7FFFFFFF) == 695688137 )
      break;
    if ( v15 == 1516370106 )
    {
      *(_BYTE *)(result + 1) = v11;
      v14 = -1451795511;
      *(_BYTE *)result = v13 + 48;
      *(_BYTE *)(result + 2) = v12;
      *(_BYTE *)(result + 3) = 0;
    }
    else if ( v15 == 828102990 )
    {
      v14 = -1451795511;
      if ( v17 )
        v14 = -631113542;
      if ( !v16 )
        v14 = -1451795511;
    }
  }
  return result;
}
  • 1
    Just to be complete, can you also post the asm for this function? – sudhackar Apr 9 at 3:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.