fork download
  1. #include <stdio.h>
  2. #include <stdint.h>
  3. #define STATIC_ANALYSIS (1)
  4.  
  5. int main(void) {
  6. int32_t rate = -252262384;
  7. static int32_t phaseAccumEL = 0;
  8. static int32_t phaseAccumAZ = 0;
  9. static uint32_t el_period_accum = 0;
  10. static uint32_t az_period_accum = 0;
  11.  
  12. // for (int i = 0; i < 1000; i++)
  13. // {
  14. // int32_t phaseAccumEL += rate;
  15. phaseAccumAZ += rate;
  16. #if STATIC_ANALYSIS
  17. uint32_t phase_accum_az_uint = phaseAccumAZ;
  18. uint32_t accum_az_upper = phase_accum_az_uint >> 25;
  19. if (accum_az_upper > 64)
  20. {
  21. accum_az_upper -= 128;
  22. }
  23. const int32_t adjustAZ = (int8_t)accum_az_upper;
  24. phase_accum_az_uint &= (1 << 25) - 1;
  25. phaseAccumAZ = phase_accum_az_uint;
  26. printf("adjustAZ=%d phaseAccumAZ=%d, accum_az_upper=%d\n", adjustAZ, phaseAccumAZ, accum_az_upper);
  27. #else
  28. int adjustAZ = phaseAccumAZ >> 25;
  29. phaseAccumAZ &= (1 << 25) - 1;
  30. printf("adjustAZ=%d phaseAccumAZ=%d\n", adjustAZ, phaseAccumAZ);
  31. #endif
  32. return 0;
  33. }
  34.  
Success #stdin #stdout 0s 5292KB
stdin
Standard input is empty
stdout
adjustAZ=-8 phaseAccumAZ=16173072, accum_az_upper=-8