#include <stdio.h>
#include <stdint.h>
#define STATIC_ANALYSIS (1)

int main(void) {
    int32_t rate = -252262384;
    static int32_t phaseAccumEL = 0;
	static int32_t phaseAccumAZ = 0;
	static uint32_t el_period_accum = 0;
	static uint32_t az_period_accum = 0;
 
    // for (int i = 0; i < 1000; i++)
    // {
	    // int32_t phaseAccumEL += rate;
	    phaseAccumAZ += rate;
#if STATIC_ANALYSIS
	    uint32_t phase_accum_az_uint = phaseAccumAZ;
	    uint32_t accum_az_upper = phase_accum_az_uint >> 25;
	    if (accum_az_upper > 64)
	    {
	    	accum_az_upper -= 128;
	    }
	    const int32_t adjustAZ = (int8_t)accum_az_upper;
	    phase_accum_az_uint &= (1 << 25) - 1;
	    phaseAccumAZ = phase_accum_az_uint;
	    printf("adjustAZ=%d phaseAccumAZ=%d, accum_az_upper=%d\n", adjustAZ, phaseAccumAZ, accum_az_upper);
#else
	    int adjustAZ = phaseAccumAZ >> 25;
	    phaseAccumAZ &= (1 << 25) - 1;
	    printf("adjustAZ=%d phaseAccumAZ=%d\n", adjustAZ, phaseAccumAZ);
#endif
	return 0;
}
