#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 */

/* Variables and functions */
int Abc_Lit2Var(int);
scalar_t__ Abc_LitIsCompl(int);
int /*<<< orphan*/ assert(int);
int If_LogCounter32Eval(unsigned Count, int Start) {
  int n = (Abc_LitIsCompl(Start) || (Count & (Count - 1)) > 0) ? -1 : 0;
  assert(Count > 0);
  if ((Count & 0xFFFF0000) == 0) {
    n += 16;
    Count <<= 16;
  }
  if ((Count & 0xFF000000) == 0) {
    n += 8;
    Count <<= 8;
  }
  if ((Count & 0xF0000000) == 0) {
    n += 4;
    Count <<= 4;
  }
  if ((Count & 0xC0000000) == 0) {
    n += 2;
    Count <<= 2;
  }
  if ((Count & 0x80000000) == 0) {
    n++;
  }
  return Abc_Lit2Var(Start) + 31 - n;
}


x86 assembly (clang, -O0):
<If_LogCounter32Eval>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <Abc_LitIsCompl@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0xd(%rbp)
jne    116c <If_LogCounter32Eval+0x3c>
mov    -0x4(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
seta   %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%dl
xor    %eax,%eax
mov    $0xffffffff,%ecx
test   $0x1,%dl
cmovne %ecx,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0x4(%rbp)
seta   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x4(%rbp),%eax
and    $0xffff0000,%eax
cmp    $0x0,%eax
jne    11b3 <If_LogCounter32Eval+0x83>
mov    -0xc(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
shl    $0x10,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0xff000000,%eax
cmp    $0x0,%eax
jne    11d6 <If_LogCounter32Eval+0xa6>
mov    -0xc(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0xf0000000,%eax
cmp    $0x0,%eax
jne    11f9 <If_LogCounter32Eval+0xc9>
mov    -0xc(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
shl    $0x4,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0xc0000000,%eax
cmp    $0x0,%eax
jne    121c <If_LogCounter32Eval+0xec>
mov    -0xc(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
shl    $0x2,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0x80000000,%eax
cmp    $0x0,%eax
jne    1236 <If_LogCounter32Eval+0x106>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <Abc_Lit2Var@plt>
add    $0x1f,%eax
sub    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<If_LogCounter32Eval>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %edi,%ebx
mov    %esi,%edi
call   1050 <Abc_LitIsCompl@plt>
mov    $0xffffffff,%ebp
test   %rax,%rax
jne    1153 <If_LogCounter32Eval+0x23>
lea    -0x1(%rbx),%eax
and    %ebx,%eax
neg    %eax
sbb    %ebp,%ebp
xor    %edi,%edi
test   %ebx,%ebx
setne  %dil
call   1040 <assert@plt>
lea    0x10(%rbp),%eax
mov    %ebx,%ecx
shl    $0x10,%ecx
cmp    $0x10000,%ebx
cmovae %ebx,%ecx
cmovae %ebp,%eax
lea    0x8(%rax),%edx
mov    %ecx,%esi
shl    $0x8,%esi
cmp    $0x1000000,%ecx
cmovae %ecx,%esi
cmovae %eax,%edx
lea    0x4(%rdx),%eax
mov    %esi,%ecx
shl    $0x4,%ecx
cmp    $0x10000000,%esi
cmovae %esi,%ecx
cmovae %edx,%eax
lea    0x0(,%rcx,4),%ebx
cmp    $0x40000000,%ecx
cmovae %ecx,%ebx
lea    0x2(%rax),%ebp
cmovae %eax,%ebp
shr    $0x1f,%ebx
mov    %r14d,%edi
call   1030 <Abc_Lit2Var@plt>
add    %ebx,%eax
sub    %ebp,%eax
add    $0x1e,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @If_LogCounter32Eval(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = call i64 @Abc_LitIsCompl(i32 %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %15, label %9
9: ; preds = %2
%10 = load i32, i32* %3
%11 = load i32, i32* %3
%12 = sub i32 %11, 1
%13 = and i32 %10, %12
%14 = icmp ugt i32 %13, 0
br label %15
15: ; preds = %9, %2
%16 = phi i1 [ true, %2 ], [ %14, %9 ]
%17 = zext i1 %16 to i64
%18 = select i1 %16, i32 -1, i32 0
store i32 %18, i32* %5
%19 = load i32, i32* %3
%20 = icmp ugt i32 %19, 0
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = load i32, i32* %3
%24 = and i32 %23, -65536
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %31
26: ; preds = %15
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 16
store i32 %28, i32* %5
%29 = load i32, i32* %3
%30 = shl i32 %29, 16
store i32 %30, i32* %3
br label %31
31: ; preds = %26, %15
%32 = load i32, i32* %3
%33 = and i32 %32, -16777216
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %40
35: ; preds = %31
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 8
store i32 %37, i32* %5
%38 = load i32, i32* %3
%39 = shl i32 %38, 8
store i32 %39, i32* %3
br label %40
40: ; preds = %35, %31
%41 = load i32, i32* %3
%42 = and i32 %41, -268435456
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %49
44: ; preds = %40
%45 = load i32, i32* %5
%46 = add nsw i32 %45, 4
store i32 %46, i32* %5
%47 = load i32, i32* %3
%48 = shl i32 %47, 4
store i32 %48, i32* %3
br label %49
49: ; preds = %44, %40
%50 = load i32, i32* %3
%51 = and i32 %50, -1073741824
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %58
53: ; preds = %49
%54 = load i32, i32* %5
%55 = add nsw i32 %54, 2
store i32 %55, i32* %5
%56 = load i32, i32* %3
%57 = shl i32 %56, 2
store i32 %57, i32* %3
br label %58
58: ; preds = %53, %49
%59 = load i32, i32* %3
%60 = and i32 %59, -2147483648
%61 = icmp eq i32 %60, 0
br i1 %61, label %62, label %65
62: ; preds = %58
%63 = load i32, i32* %5
%64 = add nsw i32 %63, 1
store i32 %64, i32* %5
br label %65
65: ; preds = %62, %58
%66 = load i32, i32* %4
%67 = call i32 @Abc_Lit2Var(i32 %66)
%68 = add nsw i32 %67, 31
%69 = load i32, i32* %5
%70 = sub nsw i32 %68, %69
ret i32 %70
}

LLVM IR (-O2):
define i32 @If_LogCounter32Eval(i32 %0, i32 %1) {
%3 = tail call i64 @Abc_LitIsCompl(i32 %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = tail call i32 @llvm.ctpop.i32(i32 %0)
%7 = icmp ugt i32 %6, 1
%8 = sext i1 %7 to i32
br label %9
9: ; preds = %5, %2
%10 = phi i32 [ -1, %2 ], [ %8, %5 ]
%11 = icmp ne i32 %0, 0
%12 = zext i1 %11 to i32
%13 = tail call i32 @assert(i32 %12)
%14 = icmp ult i32 %0, 65536
%15 = add nsw i32 %10, 16
%16 = shl i32 %0, 16
%17 = select i1 %14, i32 %16, i32 %0
%18 = select i1 %14, i32 %15, i32 %10
%19 = icmp ult i32 %17, 16777216
%20 = add nsw i32 %18, 8
%21 = shl i32 %17, 8
%22 = select i1 %19, i32 %21, i32 %17
%23 = select i1 %19, i32 %20, i32 %18
%24 = icmp ult i32 %22, 268435456
%25 = add nsw i32 %23, 4
%26 = shl i32 %22, 4
%27 = select i1 %24, i32 %26, i32 %22
%28 = select i1 %24, i32 %25, i32 %23
%29 = icmp ult i32 %27, 1073741824
%30 = add nsw i32 %28, 2
%31 = shl i32 %27, 2
%32 = select i1 %29, i32 %31, i32 %27
%33 = select i1 %29, i32 %30, i32 %28
%34 = lshr i32 %32, 31
%35 = tail call i32 @Abc_Lit2Var(i32 %1)
%36 = or i32 %34, 30
%37 = add i32 %36, %35
%38 = sub i32 %37, %33
ret i32 %38
}