#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 leftmost_one(unsigned int);
int /*<<< orphan*/ printf(char *, unsigned int, int);
int main(void) {
  unsigned x = 0;
  x = 0xFF00;
  printf("0x%.8x left most 1 mask is: 0x%.8x\n", x, leftmost_one(x));
  x = 0x6600;
  printf("0x%.8x left most 1 mask is: 0x%.8x\n", x, leftmost_one(x));
  x = 0x0000;
  printf("0x%.8x left most 1 mask is: 0x%.8x\n", x, leftmost_one(x));
  x = 0xFFFFFFFF;
  printf("0x%.8x left most 1 mask is: 0x%.8x\n", x, leftmost_one(x));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0xff00,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <leftmost_one@plt>
mov    -0x18(%rbp),%esi
mov    %eax,%edx
lea    0xea9(%rip),%rdi
call   1030 <printf@plt>
movl   $0x6600,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <leftmost_one@plt>
mov    -0x14(%rbp),%esi
mov    %eax,%edx
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <leftmost_one@plt>
mov    -0x10(%rbp),%esi
mov    %eax,%edx
lea    0xe5d(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <leftmost_one@plt>
mov    -0xc(%rbp),%esi
mov    %eax,%edx
lea    0xe37(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0xff00,%edi
call   1040 <leftmost_one@plt>
lea    0xece(%rip),%rbx
mov    %rbx,%rdi
mov    $0xff00,%esi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0x6600,%edi
call   1040 <leftmost_one@plt>
mov    %rbx,%rdi
mov    $0x6600,%esi
mov    %eax,%edx
call   1030 <printf@plt>
xor    %edi,%edi
call   1040 <leftmost_one@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    %eax,%edx
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1040 <leftmost_one@plt>
mov    %rbx,%rdi
mov    $0xffffffff,%esi
mov    %eax,%edx
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [36 x i8] c"0x%.8x left most 1 mask is: 0x%.8x\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 65280, i32* %2
%3 = load i32, i32* %2
%4 = load i32, i32* %2
%5 = call i32 @leftmost_one(i32 %4)
%6 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %5)
store i32 26112, i32* %2
%7 = load i32, i32* %2
%8 = load i32, i32* %2
%9 = call i32 @leftmost_one(i32 %8)
%10 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %9)
store i32 0, i32* %2
%11 = load i32, i32* %2
%12 = load i32, i32* %2
%13 = call i32 @leftmost_one(i32 %12)
%14 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %13)
store i32 -1, i32* %2
%15 = load i32, i32* %2
%16 = load i32, i32* %2
%17 = call i32 @leftmost_one(i32 %16)
%18 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %17)
ret i32 0
}

LLVM IR (-O2):
@.str = [36 x i8] c"0x%.8x left most 1 mask is: 0x%.8x\0A\00"
define i32 @main() {
%1 = tail call i32 @leftmost_one(i32 65280)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 65280, i32 %1)
%3 = tail call i32 @leftmost_one(i32 26112)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 26112, i32 %3)
%5 = tail call i32 @leftmost_one(i32 0)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 0, i32 %5)
%7 = tail call i32 @leftmost_one(i32 -1)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 -1, i32 %7)
ret i32 0
}