inline fn ctzXi2(comptime T: type, a: T) i32
inline fn ctzXi2(comptime T: type, a: T) i32 { var x = switch (@bitSizeOf(T)) { 32 => @as(u32, @bitCast(a)), 64 => @as(u64, @bitCast(a)), 128 => @as(u128, @bitCast(a)), else => unreachable, }; var n: T = 1; // Number of trailing zeroes as binary search, from Hacker's Delight var mask: @TypeOf(x) = std.math.maxInt(@TypeOf(x)); comptime var shift = @bitSizeOf(T); if (x == 0) return shift; inline while (shift > 1) { shift = shift >> 1; mask = mask >> shift; if ((x & mask) == 0) { n = n + shift; x = x >> shift; } } return @intCast(n - @as(T, @bitCast((x & 1)))); }