#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 stb_lowbit8(unsigned int n) {
  static signed char lowbit4[16] = {-1, 0, 1, 0, 2, 0, 1, 0,
                                    3,  0, 1, 0, 2, 0, 1, 0};
  int k = lowbit4[n & 15];
  if (k >= 0)
    return k;
  k = lowbit4[(n >> 4) & 15];
  if (k >= 0)
    return k + 4;
  return k;
}


x86 assembly (clang, -O0):
<stb_lowbit8>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0xf,%eax
mov    %eax,%eax
mov    %eax,%ecx
lea    0x2f18(%rip),%rax
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     1134 <stb_lowbit8+0x34>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    116d <stb_lowbit8+0x6d>
mov    -0x8(%rbp),%eax
shr    $0x4,%eax
and    $0xf,%eax
mov    %eax,%eax
mov    %eax,%ecx
lea    0x2ee8(%rip),%rax
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     1167 <stb_lowbit8+0x67>
mov    -0xc(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x4(%rbp)
jmp    116d <stb_lowbit8+0x6d>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<stb_lowbit8>:
mov    %rdi,%rax
and    $0xf,%rax
je     1115 <stb_lowbit8+0x15>
lea    0xef0(%rip),%rcx
movsbl (%rax,%rcx,1),%eax
ret
shr    $0x4,%edi
and    $0xf,%edi
lea    0xede(%rip),%rax
movsbl (%rdi,%rax,1),%ecx
lea    0x4(%rcx),%eax
test   %rdi,%rdi
cmove  %ecx,%eax
ret

LLVM IR (-O0):
@stb_lowbit8.lowbit4 = internal global [16 x i8] c"\FF\00\01\00\02\00\01\00\03\00\01\00\02\00\01\00"
define i32 @stb_lowbit8(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = and i32 %5, 15
%7 = zext i32 %6 to i64
%8 = getelementptr inbounds [16 x i8], [16 x i8]* @stb_lowbit8.lowbit4, i64 0, i64 %7
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
store i32 %10, i32* %4
%11 = load i32, i32* %4
%12 = icmp sge i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %1
%14 = load i32, i32* %4
store i32 %14, i32* %2
br label %30
15: ; preds = %1
%16 = load i32, i32* %3
%17 = lshr i32 %16, 4
%18 = and i32 %17, 15
%19 = zext i32 %18 to i64
%20 = getelementptr inbounds [16 x i8], [16 x i8]* @stb_lowbit8.lowbit4, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
store i32 %22, i32* %4
%23 = load i32, i32* %4
%24 = icmp sge i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %15
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 4
store i32 %27, i32* %2
br label %30
28: ; preds = %15
%29 = load i32, i32* %4
store i32 %29, i32* %2
br label %30
30: ; preds = %28, %25, %13
%31 = load i32, i32* %2
ret i32 %31
}

LLVM IR (-O2):
@stb_lowbit8.lowbit4 = internal unnamed_addr constant [16 x i8] c"\FF\00\01\00\02\00\01\00\03\00\01\00\02\00\01\00"
define i32 @stb_lowbit8(i32 %0) {
%2 = and i32 %0, 15
%3 = icmp eq i32 %2, 0
br i1 %3, label %9, label %4
4: ; preds = %1
%5 = zext i32 %2 to i64
%6 = getelementptr inbounds [16 x i8], [16 x i8]* @stb_lowbit8.lowbit4, i64 0, i64 %5
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
br label %19
9: ; preds = %1
%10 = lshr i32 %0, 4
%11 = and i32 %10, 15
%12 = zext i32 %11 to i64
%13 = getelementptr inbounds [16 x i8], [16 x i8]* @stb_lowbit8.lowbit4, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %11, 0
%17 = add nsw i32 %15, 4
%18 = select i1 %16, i32 %15, i32 %17
br label %19
19: ; preds = %9, %4
%20 = phi i32 [ %8, %4 ], [ %18, %9 ]
ret i32 %20
}