int __ffsl(bits)
long int bits;
{
  unsigned long int shift;
  unsigned long int ind = (bits & -bits);
  static const unsigned char lookup[] = {
      0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5,
      5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
      6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7,
      7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
      7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
      7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
      8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
      8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
      8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
      8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
      8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
  };
  shift = (ind > 0xffff) ? (ind > 0xffffff ? 24 : 16) : (ind > 0xff ? 8 : 0);
  return lookup[ind >> shift] + shift;
}


x86 assembly (clang, -O0):
<__ffsl>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
xor    %ecx,%ecx
sub    -0x8(%rbp),%rcx
and    %rcx,%rax
mov    %rax,-0x18(%rbp)
cmpq   $0xffff,-0x18(%rbp)
jbe    1147 <__ffsl+0x47>
mov    -0x18(%rbp),%rdx
mov    $0x10,%eax
mov    $0x18,%ecx
cmp    $0xffffff,%rdx
cmova  %ecx,%eax
mov    %eax,-0x1c(%rbp)
jmp    115f <__ffsl+0x5f>
mov    -0x18(%rbp),%rdx
xor    %eax,%eax
mov    $0x8,%ecx
cmp    $0xff,%rdx
cmova  %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cltq
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
shr    %cl,%rax
mov    %rax,%rcx
lea    0xe83(%rip),%rax
movzbl (%rax,%rcx,1),%eax
add    -0x10(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<__ffsl>:
mov    %rdi,%rdx
neg    %rdx
and    %rdi,%rdx
xor    %eax,%eax
cmp    $0x1000000,%rdx
setae  %al
xor    %ecx,%ecx
cmp    $0x100,%rdx
setae  %cl
shl    $0x3,%rcx
cmp    $0x10000,%rdx
lea    0x10(,%rax,8),%rax
cmovb  %rcx,%rax
mov    %eax,%ecx
shr    %cl,%rdx
lea    0xebc(%rip),%rcx
movzbl (%rdx,%rcx,1),%ecx
add    %ecx,%eax
ret

LLVM IR (-O0):
@__ffsl.lookup = internal constant [256 x i8] c"\00\01\02\02\03\03\03\03\04\04\04\04\04\04\04\04\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08"
define i32 @__ffsl(i64 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
store i64 %0, i64* %2
%5 = load i64, i64* %2
%6 = load i64, i64* %2
%7 = sub nsw i64 0, %6
%8 = and i64 %5, %7
store i64 %8, i64* %4
%9 = load i64, i64* %4
%10 = icmp ugt i64 %9, 65535
br i1 %10, label %11, label %16
11: ; preds = %1
%12 = load i64, i64* %4
%13 = icmp ugt i64 %12, 16777215
%14 = zext i1 %13 to i64
%15 = select i1 %13, i32 24, i32 16
br label %21
16: ; preds = %1
%17 = load i64, i64* %4
%18 = icmp ugt i64 %17, 255
%19 = zext i1 %18 to i64
%20 = select i1 %18, i32 8, i32 0
br label %21
21: ; preds = %16, %11
%22 = phi i32 [ %15, %11 ], [ %20, %16 ]
%23 = sext i32 %22 to i64
store i64 %23, i64* %3
%24 = load i64, i64* %4
%25 = load i64, i64* %3
%26 = lshr i64 %24, %25
%27 = getelementptr inbounds [256 x i8], [256 x i8]* @__ffsl.lookup, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = zext i8 %28 to i64
%30 = load i64, i64* %3
%31 = add i64 %29, %30
%32 = trunc i64 %31 to i32
ret i32 %32
}

LLVM IR (-O2):
@__ffsl.lookup = internal unnamed_addr constant [256 x i8] c"\00\01\02\02\03\03\03\03\04\04\04\04\04\04\04\04\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\06\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\07\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08"
define i32 @__ffsl(i64 %0) {
%2 = sub nsw i64 0, %0
%3 = and i64 %2, %0
%4 = icmp ugt i64 %3, 65535
%5 = icmp ugt i64 %3, 16777215
%6 = select i1 %5, i64 24, i64 16
%7 = icmp ugt i64 %3, 255
%8 = select i1 %7, i64 8, i64 0
%9 = select i1 %4, i64 %6, i64 %8
%10 = lshr i64 %3, %9
%11 = getelementptr inbounds [256 x i8], [256 x i8]* @__ffsl.lookup, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = zext i8 %12 to i64
%14 = add nuw nsw i64 %9, %13
%15 = trunc i64 %14 to i32
ret i32 %15
}