#include "pch.h"
#include <stdlib.h>
#include "mzstdCommon.h"
#include "mzMath.h"
#include <wchar.h>

namespace mzstd {

DECLSPEC_MZSTD ULONG WINAPI random() {
    return rand();
}

DECLSPEC_MZSTD ULONG WINAPI random(ULONG max) {
    UINT rnd;

    rnd = rand();
    if (max < UINT_MAX) {
        return rnd % (max + 1);
    }
    return rnd;
}

DECLSPEC_MZSTD ULONG WINAPI random(ULONG min, ULONG max) {
    UINT rnd;

    rnd = rand();
    if (rnd + min <= UINT_MAX) {
        rnd += min;
    }
    if (max < UINT_MAX) {
        return (rnd + min) % (max + 1);
    }
	return rnd;
}

}
