#pragma once

#ifdef _MSC_VER
#include <intrin.h>

inline int ffs(int x) {
    unsigned long index;
    if (_BitScanForward(&index, (unsigned long)x))
        return (int)index + 1;
    return 0;
}

inline int ffsll(long long x) {
    unsigned long index;
    if (_BitScanForward64(&index, (unsigned __int64)x))
        return (int)index + 1;
    return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#endif
