c
#include <limits.h>

static int safe_mod(int a, int b) {
    return (b != 0) ? (a % b) : INT_MAX;
}

// ...

if (safe_mod(td->td_tilelength, (sp->v_sampling * DCTSIZE)) != 0) {
    // ... rest of the code
}
