Yes, constrain 0..0x7FFFFFFF was needed because it only works in this interval.
BTW: Your test with random() is useless for testing in 0..0xFFFFFFFF because it produces only values between 0..RANDOM_MAX (with RANDOM_MAX = 0x7FFFFFFF). ( See avr-libc: <stdlib.h>: General utilities )
"can it be faster?"
Yes, it can!
I took the challenge and found a solution which is the fastest (so far on my atmega328p) and finally works on the complete interval 0..0xFFFFFFFF.
void divmod10(uint32_t in, uint32_t &div, uint32_t &mod)
{
uint32_t x=(in>>1); // div = in/10 <==> div = ((in/2)/5)
uint32_t q=x;
q= (q>>8) + x;
q= (q>>8) + x;
q= (q>>8) + x;
q= (q>>8) + x + 1;
x= q;
q= (q>>1) + x;
q= (q>>3) + x;
q= (q>>1) + x;
div = (q >> 3);
mod = in - (((div << 2) + div) << 1);
}