fork download
  1. static uint32_t div4 (uint32_t n, uint32_t d)
  2. {
  3. uint32_t p = 0;
  4. uint32_t q = 0;
  5. int ctr = 31;
  6.  
  7. next_iter:
  8. p <<= 1;
  9. p |= n >> 31;
  10. n <<= 1;
  11. if (d > p) {
  12. goto zero_bit;
  13. }
  14. p -= d;
  15. q++;
  16. zero_bit:
  17. q <<= 1;
  18. ctr--;
  19. if (ctr != 0) {
  20. goto next_iter;
  21. }
  22.  
  23. p <<= 1;
  24. p |= n >> 31;
  25. n <<= 1;
  26. if (d > p) {
  27. goto end_zero_bit;
  28. }
  29. q++;
  30. end_zero_bit:
  31.  
  32. return q;
  33. }
  34.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty