#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 /*<<< orphan*/ values;

/* Variables and functions */
int EXIT_SUCCESS;
int get_rightmost_one_bit(int);
int /*<<< orphan*/ printf(char *, int, int, int);
int main(void) {
  int values[] = {0xFF, 0xA, 0x14, 0x0100, 0xABC, 0x6600, 0x0200};
  for (int i = 0; i < sizeof(values) / sizeof(*values); i++)
    printf("%#6x (hex) %6d (dec) righmost 1 is: %3d\n", values[i], values[i],
           get_rightmost_one_bit(values[i]));
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xec4(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xec2(%rip),%eax
mov    %eax,-0x8(%rbp)
movl   $0x0,-0x24(%rbp)
movslq -0x24(%rbp),%rax
cmp    $0x7,%rax
jae    11b3 <main+0x93>
movslq -0x24(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%eax
mov    %eax,-0x2c(%rbp)
movslq -0x24(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%eax
mov    %eax,-0x28(%rbp)
movslq -0x24(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%edi
call   1030 <get_rightmost_one_bit@plt>
mov    -0x2c(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    %eax,%ecx
lea    0xe7c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1160 <main+0x40>
mov    0x2e26(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0xff,%edi
call   1030 <get_rightmost_one_bit@plt>
lea    0xece(%rip),%rbx
mov    %rbx,%rdi
mov    $0xff,%esi
mov    $0xff,%edx
mov    %eax,%ecx
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <get_rightmost_one_bit@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
mov    $0xa,%edx
mov    %eax,%ecx
call   1040 <printf@plt>
mov    $0x14,%edi
call   1030 <get_rightmost_one_bit@plt>
mov    %rbx,%rdi
mov    $0x14,%esi
mov    $0x14,%edx
mov    %eax,%ecx
call   1040 <printf@plt>
mov    $0x100,%edi
call   1030 <get_rightmost_one_bit@plt>
mov    %rbx,%rdi
mov    $0x100,%esi
mov    $0x100,%edx
mov    %eax,%ecx
call   1040 <printf@plt>
mov    $0xabc,%edi
call   1030 <get_rightmost_one_bit@plt>
mov    %rbx,%rdi
mov    $0xabc,%esi
mov    $0xabc,%edx
mov    %eax,%ecx
call   1040 <printf@plt>
mov    $0x6600,%edi
call   1030 <get_rightmost_one_bit@plt>
mov    %rbx,%rdi
mov    $0x6600,%esi
mov    $0x6600,%edx
mov    %eax,%ecx
call   1040 <printf@plt>
mov    $0x200,%edi
call   1030 <get_rightmost_one_bit@plt>
mov    %rbx,%rdi
mov    $0x200,%esi
mov    $0x200,%edx
mov    %eax,%ecx
call   1040 <printf@plt>
mov    0x2ddf(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.values = [7 x i32] [i32 255, i32 10, i32 20, i32 256, i32 2748, i32 26112, i32 512]
@.str = [41 x i8] c"%x (hex) %6d (dec) righmost 1 is: %3d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [7 x i32]
%3 = alloca i32
store i32 0, i32* %1
%4 = bitcast [7 x i32]* %2 to i8*
store i32 0, i32* %3
br label %5
5: ; preds = %24, %0
%6 = load i32, i32* %3
%7 = sext i32 %6 to i64
%8 = icmp ult i64 %7, 7
br i1 %8, label %9, label %27
9: ; preds = %5
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [7 x i32], [7 x i32]* %2, i64 0, i64 %11
%13 = load i32, i32* %12
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [7 x i32], [7 x i32]* %2, i64 0, i64 %15
%17 = load i32, i32* %16
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [7 x i32], [7 x i32]* %2, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = call i32 @get_rightmost_one_bit(i32 %21)
%23 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %17, i32 %22)
br label %24
24: ; preds = %9
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
br label %5
27: ; preds = %5
%28 = load i32, i32* @EXIT_SUCCESS
ret i32 %28
}

LLVM IR (-O2):
@.str = [41 x i8] c"%x (hex) %6d (dec) righmost 1 is: %3d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = tail call i32 @get_rightmost_one_bit(i32 255)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 255, i32 255, i32 %1)
%3 = tail call i32 @get_rightmost_one_bit(i32 10)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 10, i32 10, i32 %3)
%5 = tail call i32 @get_rightmost_one_bit(i32 20)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 20, i32 20, i32 %5)
%7 = tail call i32 @get_rightmost_one_bit(i32 256)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 256, i32 256, i32 %7)
%9 = tail call i32 @get_rightmost_one_bit(i32 2748)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 2748, i32 2748, i32 %9)
%11 = tail call i32 @get_rightmost_one_bit(i32 26112)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 26112, i32 26112, i32 %11)
%13 = tail call i32 @get_rightmost_one_bit(i32 512)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 512, i32 512, i32 %13)
%15 = load i32, i32* @EXIT_SUCCESS
ret i32 %15
}