#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 */
unsigned int getBits(int, int, unsigned int);
int /*<<< orphan*/ printf(char *, ...);
int test_getBits(int low, int high, unsigned int source,
                 unsigned int expected) {
  printf("\nTesting getBits(%d, %d, %d)", low, high, source);
  unsigned int result = getBits(low, high, source);
  printf("\nExpected: %5d\nResult: %7d", expected, result);
  if (expected != result) {
    printf("\ngetBits() Test Failed\n");
    return 0;
  } else {
    printf("\ngetBits() Test Passed\n");
    return 1;
  }
}


x86 assembly (clang, -O0):
<test_getBits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1040 <getBits@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
je     1196 <test_getBits+0x76>
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11ab <test_getBits+0x8b>
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_getBits>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %esi,%ebx
mov    %edi,%ebp
lea    0xeb8(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %r15d,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    %r15d,%edx
call   1050 <getBits@plt>
mov    %eax,%ebx
lea    0xeb2(%rip),%rdi
mov    %r14d,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %ebp,%ebp
cmp    %r14d,%ebx
sete   %bpl
lea    0xeb1(%rip),%rax
lea    0xec1(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"\0ATesting getBits(%d, %d, %d)\00"
@.str.1 = [27 x i8] c"\0AExpected: %5d\0AResult: %7d\00"
@.str.2 = [24 x i8] c"\0AgetBits() Test Failed\0A\00"
@.str.3 = [24 x i8] c"\0AgetBits() Test Passed\0A\00"
define i32 @test_getBits(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%11 = load i32, i32* %6
%12 = load i32, i32* %7
%13 = load i32, i32* %8
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %12, i32 %13)
%15 = load i32, i32* %6
%16 = load i32, i32* %7
%17 = load i32, i32* %8
%18 = call i32 @getBits(i32 %15, i32 %16, i32 %17)
store i32 %18, i32* %10
%19 = load i32, i32* %9
%20 = load i32, i32* %10
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %19, i32 %20)
%22 = load i32, i32* %9
%23 = load i32, i32* %10
%24 = icmp ne i32 %22, %23
br i1 %24, label %25, label %27
25: ; preds = %4
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %5
br label %29
27: ; preds = %4
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %5
br label %29
29: ; preds = %27, %25
%30 = load i32, i32* %5
ret i32 %30
}

LLVM IR (-O2):
@.str = [29 x i8] c"\0ATesting getBits(%d, %d, %d)\00"
@.str.1 = [27 x i8] c"\0AExpected: %5d\0AResult: %7d\00"
@str = [23 x i8] c"\0AgetBits() Test Passed\00"
@str.4 = [23 x i8] c"\0AgetBits() Test Failed\00"
define i32 @test_getBits(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1, i32 %2)
%6 = tail call i32 @getBits(i32 %0, i32 %1, i32 %2)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %3, i32 %6)
%8 = icmp eq i32 %6, %3
%9 = select i1 %8, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @str.4, i64 0, i64 0)
%10 = zext i1 %8 to i32
%11 = tail call i32 @puts(i8* dereferenceable(1) %9)
ret i32 %10
}