#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int uint32_t;
typedef int int32_t;

/* Variables and functions */
uint32_t count_trailing_zeroes(uint32_t v) {
  uint32_t c = 32;
  v &= -(int32_t)(v);
  if (v)
    c--;
  if (v & 0x0000FFFF)
    c -= 16;
  if (v & 0x00FF00FF)
    c -= 8;
  if (v & 0x0F0F0F0F)
    c -= 4;
  if (v & 0x33333333)
    c -= 2;
  if (v & 0x55555555)
    c -= 1;
  return c;
}


x86 assembly (clang, -O0):
<count_trailing_zeroes>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x20,-0x8(%rbp)
xor    %eax,%eax
sub    -0x4(%rbp),%eax
and    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     112c <count_trailing_zeroes+0x2c>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0xffff,%eax
cmp    $0x0,%eax
je     1146 <count_trailing_zeroes+0x46>
mov    -0x8(%rbp),%eax
sub    $0x10,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0xff00ff,%eax
cmp    $0x0,%eax
je     1160 <count_trailing_zeroes+0x60>
mov    -0x8(%rbp),%eax
sub    $0x8,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0xf0f0f0f,%eax
cmp    $0x0,%eax
je     117a <count_trailing_zeroes+0x7a>
mov    -0x8(%rbp),%eax
sub    $0x4,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x33333333,%eax
cmp    $0x0,%eax
je     1194 <count_trailing_zeroes+0x94>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x55555555,%eax
cmp    $0x0,%eax
je     11ae <count_trailing_zeroes+0xae>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<count_trailing_zeroes>:
mov    %edi,%ecx
neg    %ecx
xor    %eax,%eax
and    %edi,%ecx
sete   %al
xor    %edx,%edx
test   %cx,%cx
sete   %dl
shl    $0x4,%edx
or     %eax,%edx
xor    %eax,%eax
test   $0xff00ff,%ecx
sete   %al
lea    (%rdx,%rax,8),%eax
xor    %edx,%edx
test   $0xf0f0f0f,%ecx
sete   %dl
lea    (%rax,%rdx,4),%eax
xor    %edx,%edx
test   $0x33333333,%ecx
sete   %dl
lea    (%rax,%rdx,2),%eax
and    $0x55555555,%ecx
cmp    $0x1,%ecx
adc    $0xffffffff,%eax
add    $0x1,%eax
ret

LLVM IR (-O0):
define i32 @count_trailing_zeroes(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 32, i32* %3
%4 = load i32, i32* %2
%5 = sub nsw i32 0, %4
%6 = load i32, i32* %2
%7 = and i32 %6, %5
store i32 %7, i32* %2
%8 = load i32, i32* %2
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = load i32, i32* %3
%12 = add nsw i32 %11, -1
store i32 %12, i32* %3
br label %13
13: ; preds = %10, %1
%14 = load i32, i32* %2
%15 = and i32 %14, 65535
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = load i32, i32* %3
%19 = sub nsw i32 %18, 16
store i32 %19, i32* %3
br label %20
20: ; preds = %17, %13
%21 = load i32, i32* %2
%22 = and i32 %21, 16711935
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %20
%25 = load i32, i32* %3
%26 = sub nsw i32 %25, 8
store i32 %26, i32* %3
br label %27
27: ; preds = %24, %20
%28 = load i32, i32* %2
%29 = and i32 %28, 252645135
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %27
%32 = load i32, i32* %3
%33 = sub nsw i32 %32, 4
store i32 %33, i32* %3
br label %34
34: ; preds = %31, %27
%35 = load i32, i32* %2
%36 = and i32 %35, 858993459
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %34
%39 = load i32, i32* %3
%40 = sub nsw i32 %39, 2
store i32 %40, i32* %3
br label %41
41: ; preds = %38, %34
%42 = load i32, i32* %2
%43 = and i32 %42, 1431655765
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %41
%46 = load i32, i32* %3
%47 = sub nsw i32 %46, 1
store i32 %47, i32* %3
br label %48
48: ; preds = %45, %41
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
define i32 @count_trailing_zeroes(i32 %0) {
%2 = sub nsw i32 0, %0
%3 = and i32 %2, %0
%4 = icmp eq i32 %3, 0
%5 = select i1 %4, i32 32, i32 31
%6 = and i32 %3, 65535
%7 = icmp eq i32 %6, 0
%8 = add nsw i32 %5, -16
%9 = select i1 %7, i32 %5, i32 %8
%10 = and i32 %3, 16711935
%11 = icmp eq i32 %10, 0
%12 = add nsw i32 %9, -8
%13 = select i1 %11, i32 %9, i32 %12
%14 = and i32 %3, 252645135
%15 = icmp eq i32 %14, 0
%16 = add nsw i32 %13, -4
%17 = select i1 %15, i32 %13, i32 %16
%18 = and i32 %3, 858993459
%19 = icmp eq i32 %18, 0
%20 = add nsw i32 %17, -2
%21 = select i1 %19, i32 %17, i32 %20
%22 = and i32 %3, 1431655765
%23 = icmp ne i32 %22, 0
%24 = sext i1 %23 to i32
%25 = add nsw i32 %21, %24
ret i32 %25
}