#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 get_bit(unsigned int, unsigned int);
int /*<<< orphan*/ printf(char *, unsigned int, unsigned int, unsigned int,
                          ...);
void test_get_bit(unsigned x, unsigned n, unsigned expected) {
  unsigned a = get_bit(x, n);
  if (a != expected) {
    printf("get_bit(0x%08x,%u): 0x%08x, expected 0x%08x\n", x, n, a, expected);
  } else {
    printf("get_bit(0x%08x,%u): 0x%08x, correct\n", x, n, a);
  }
}


x86 assembly (clang, -O0):
<test_get_bit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <get_bit@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     116b <test_get_bit+0x4b>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0xc(%rbp),%r8d
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1182 <test_get_bit+0x62>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_get_bit>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebp
mov    %edi,%ebx
call   1040 <get_bit@plt>
cmp    %r14d,%eax
jne    114e <test_get_bit+0x2e>
lea    0xef1(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %r14d,%ecx
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <printf@plt>
lea    0xeab(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %eax,%ecx
mov    %r14d,%r8d
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [45 x i8] c"get_bit(0x%08x,%u): 0x%08x, expected 0x%08x\0A\00"
@.str.1 = [37 x i8] c"get_bit(0x%08x,%u): 0x%08x, correct\0A\00"
define void @test_get_bit(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %4
%9 = load i32, i32* %5
%10 = call i32 @get_bit(i32 %8, i32 %9)
store i32 %10, i32* %7
%11 = load i32, i32* %7
%12 = load i32, i32* %6
%13 = icmp ne i32 %11, %12
br i1 %13, label %14, label %20
14: ; preds = %3
%15 = load i32, i32* %4
%16 = load i32, i32* %5
%17 = load i32, i32* %7
%18 = load i32, i32* %6
%19 = call i32 (i8*, i32, i32, i32, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %16, i32 %17, i32 %18)
br label %25
20: ; preds = %3
%21 = load i32, i32* %4
%22 = load i32, i32* %5
%23 = load i32, i32* %7
%24 = call i32 (i8*, i32, i32, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %21, i32 %22, i32 %23)
br label %25
25: ; preds = %20, %14
ret void
}

LLVM IR (-O2):
@.str = [45 x i8] c"get_bit(0x%08x,%u): 0x%08x, expected 0x%08x\0A\00"
@.str.1 = [37 x i8] c"get_bit(0x%08x,%u): 0x%08x, correct\0A\00"
define void @test_get_bit(i32 %0, i32 %1, i32 %2) {
%4 = tail call i32 @get_bit(i32 %0, i32 %1)
%5 = icmp eq i32 %4, %2
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = tail call i32 (i8*, i32, i32, i32, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1, i32 %4, i32 %2)
br label %10
8: ; preds = %3
%9 = tail call i32 (i8*, i32, i32, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %0, i32 %1, i32 %2)
br label %10
10: ; preds = %8, %6
ret void
}