https://www.geeksforgeeks.org/builtin-functions-gcc-compiler/
__builtin_clz(x)
: This function is used to count the leading zeros of the integer. Note : clz = count leading zero’s
Example: It counts number of zeros before the first occurrence of one(set bit).__builtin_clzl(x)
& __builtin_clzll(x)
for long and long long data types.
a = 16
Binary form of 16 is 00000000 00000000 00000000 00010000
Output: 27
__builtin_ctz(x)
: This function is used to count the trailing zeros of the given integer. Note : ctz = count trailing zeros.
Example: Count no of zeros from last to first occurrence of one(set bit).__builtin_ctzl(x)
& __builtin_ctzll(x)
for long and long long data types.
a = 16
Binary form of 16 is 00000000 00000000 00000000 00010000
Output: ctz = 4