From the last two lines of test it's returning 0, but the function that calls it (ThreadProc_dbg) declares a local variable result and sets it to 1, then calls test but doesn't store the return value into result so the result != 1 check is always false and the program will always display "your CPU isn't buggy!"