#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 getBitAt(unsigned int, int);
int /*<<< orphan*/ printBits(unsigned int);
int /*<<< orphan*/ printf(char *, ...);
void test3() {
  unsigned int a = 0xFFFF1009;
  printf("a:\n");
  printBits(a);
  int v = getBitAt(a, 3);
  printf("getBitAt(3)=%d\n", v);
  v = getBitAt(a, 10);
  printf("getBitAt(10)=%d\n", v);
  v = getBitAt(a, 20);
  printf("getBitAt(20)=%d\n", v);
  v = getBitAt(a, 5);
  printf("getBitAt(5)=%d\n", v);
}


x86 assembly (clang, -O0):
<test3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0xffff1009,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x4(%rbp),%edi
call   1040 <printBits@plt>
mov    -0x4(%rbp),%edi
mov    $0x3,%esi
call   1030 <getBitAt@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x4(%rbp),%edi
mov    $0xa,%esi
call   1030 <getBitAt@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x4(%rbp),%edi
mov    $0x14,%esi
call   1030 <getBitAt@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x4(%rbp),%edi
mov    $0x5,%esi
call   1030 <getBitAt@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test3>:
push   %rax
lea    0xefa(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffff1009,%edi
call   1050 <printBits@plt>
mov    $0xffff1009,%edi
mov    $0x3,%esi
call   1040 <getBitAt@plt>
lea    0xe93(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xffff1009,%edi
mov    $0xa,%esi
call   1040 <getBitAt@plt>
lea    0xe84(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xffff1009,%edi
mov    $0x14,%esi
call   1040 <getBitAt@plt>
lea    0xe76(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xffff1009,%edi
mov    $0x5,%esi
call   1040 <getBitAt@plt>
lea    0xe68(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
pop    %rcx
jmp    1060 <printf@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"a:\0A\00"
@.str.1 = [16 x i8] c"getBitAt(3)=%d\0A\00"
@.str.2 = [17 x i8] c"getBitAt(10)=%d\0A\00"
@.str.3 = [17 x i8] c"getBitAt(20)=%d\0A\00"
@.str.4 = [16 x i8] c"getBitAt(5)=%d\0A\00"
define void @test3() {
%1 = alloca i32
%2 = alloca i32
store i32 -61431, i32* %1
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* %1
%5 = call i32 @printBits(i32 %4)
%6 = load i32, i32* %1
%7 = call i32 @getBitAt(i32 %6, i32 3)
store i32 %7, i32* %2
%8 = load i32, i32* %2
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = load i32, i32* %1
%11 = call i32 @getBitAt(i32 %10, i32 10)
store i32 %11, i32* %2
%12 = load i32, i32* %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = load i32, i32* %1
%15 = call i32 @getBitAt(i32 %14, i32 20)
store i32 %15, i32* %2
%16 = load i32, i32* %2
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %16)
%18 = load i32, i32* %1
%19 = call i32 @getBitAt(i32 %18, i32 5)
store i32 %19, i32* %2
%20 = load i32, i32* %2
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %20)
ret void
}

LLVM IR (-O2):
@.str.1 = [16 x i8] c"getBitAt(3)=%d\0A\00"
@.str.2 = [17 x i8] c"getBitAt(10)=%d\0A\00"
@.str.3 = [17 x i8] c"getBitAt(20)=%d\0A\00"
@.str.4 = [16 x i8] c"getBitAt(5)=%d\0A\00"
@str = [3 x i8] c"a:\00"
define void @test3() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @printBits(i32 -61431)
%3 = tail call i32 @getBitAt(i32 -61431, i32 3)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%5 = tail call i32 @getBitAt(i32 -61431, i32 10)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %5)
%7 = tail call i32 @getBitAt(i32 -61431, i32 20)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %7)
%9 = tail call i32 @getBitAt(i32 -61431, i32 5)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %9)
ret void
}