#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 leastBitPos(int);
int /*<<< orphan*/ printf(char *, int, int);
int main() {
  int a = 7;
  int b = 20;
  int c = leastBitPos(a);
  int d = leastBitPos(b);
  printf("least significant bit of %d is %d\n", a, 1);
  printf("leastBitPos(%d) -> %d\n", a, c);
  printf("least significant bit of %d is %d\n", b, 4);
  printf("leastBitPos(%d) -> %d\n", b, d);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x7,-0x4(%rbp)
movl   $0x14,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <leastBitPos@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <leastBitPos@plt>
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%esi
lea    0xeaa(%rip),%rdi
mov    $0x1,%edx
call   1030 <printf@plt>
mov    -0x4(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xeb6(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xe84(%rip),%rdi
mov    $0x4,%edx
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe90(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x7,%edi
call   1040 <leastBitPos@plt>
mov    %eax,%ebx
mov    $0x14,%edi
call   1040 <leastBitPos@plt>
mov    %eax,%ebp
lea    0xeba(%rip),%r14
mov    %r14,%rdi
mov    $0x7,%esi
mov    $0x1,%edx
call   1030 <printf@plt>
lea    0xec4(%rip),%r15
mov    %r15,%rdi
mov    $0x7,%esi
mov    %ebx,%edx
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0x14,%esi
mov    $0x4,%edx
call   1030 <printf@plt>
mov    %r15,%rdi
mov    $0x14,%esi
mov    %ebp,%edx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"least significant bit of %d is %d\0A\00"
@.str.1 = [23 x i8] c"leastBitPos(%d) -> %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 7, i32* %1
store i32 20, i32* %2
%5 = load i32, i32* %1
%6 = call i32 @leastBitPos(i32 %5)
store i32 %6, i32* %3
%7 = load i32, i32* %2
%8 = call i32 @leastBitPos(i32 %7)
store i32 %8, i32* %4
%9 = load i32, i32* %1
%10 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %9, i32 1)
%11 = load i32, i32* %1
%12 = load i32, i32* %3
%13 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %12)
%14 = load i32, i32* %2
%15 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %14, i32 4)
%16 = load i32, i32* %2
%17 = load i32, i32* %4
%18 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %16, i32 %17)
ret i32 0
}

LLVM IR (-O2):
@.str = [35 x i8] c"least significant bit of %d is %d\0A\00"
@.str.1 = [23 x i8] c"leastBitPos(%d) -> %d\0A\00"
define i32 @main() {
%1 = tail call i32 @leastBitPos(i32 7)
%2 = tail call i32 @leastBitPos(i32 20)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 7, i32 1)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 7, i32 %1)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 20, i32 4)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 20, i32 %2)
ret i32 0
}