#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 instr_rbit(int);
int /*<<< orphan*/ printf(char *, ...);
int prog_rbit(int);
int rand();
int REVERSE_BIT_32b_AUTOTEST() {
  printf("LAUNCHING THE (REVERSE_BIT) RESOURCE TEST...\n");
  int i, j;
  for (j = 0; j < 10; j++) {
    int op1 = rand();
    int res1 = instr_rbit(op1);
    int res2 = prog_rbit(op1);
    if (res1 != res2) {
      printf("- TEST OF THE (REVERSE_BIT) RESOURCE => FAILED !\n");
      printf("  + %d COMPUTATION BEFORE ERROR... !\n", j);
      printf("  + OPERANDE 1         [%x]\n", op1);
      printf("  + INSTRUCTION RESULT [%x]\n", res1);
      printf("  + C CODE RESULT      [%x]\n", res2);
      return 0;
    }
  }
  printf("- TEST OF THE (REVERSE_BIT) RESOURCE => OK\n");
  return 1;
}


x86 assembly (clang, -O0):
<REVERSE_BIT_32b_AUTOTEST>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    1204 <REVERSE_BIT_32b_AUTOTEST+0xc4>
mov    $0x0,%al
call   1060 <rand@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
call   1040 <instr_rbit@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%edi
call   1050 <prog_rbit@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
je     11f1 <REVERSE_BIT_32b_AUTOTEST+0xb1>
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xee2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1219 <REVERSE_BIT_32b_AUTOTEST+0xd9>
jmp    11f6 <REVERSE_BIT_32b_AUTOTEST+0xb6>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115d <REVERSE_BIT_32b_AUTOTEST+0x1d>
lea    0xed2(%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):
<REVERSE_BIT_32b_AUTOTEST>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
lea    0xf1e(%rip),%rdi
call   1030 <puts@plt>
xor    %r14d,%r14d
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1050 <instr_rbit@plt>
mov    %eax,%r15d
mov    %ebp,%edi
call   1060 <prog_rbit@plt>
cmp    %eax,%r15d
jne    12d8 <REVERSE_BIT_32b_AUTOTEST+0x188>
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1050 <instr_rbit@plt>
mov    %eax,%r15d
mov    %ebp,%edi
call   1060 <prog_rbit@plt>
cmp    %eax,%r15d
jne    12df <REVERSE_BIT_32b_AUTOTEST+0x18f>
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1050 <instr_rbit@plt>
mov    %eax,%r15d
mov    %ebp,%edi
call   1060 <prog_rbit@plt>
cmp    %eax,%r15d
jne    12e9 <REVERSE_BIT_32b_AUTOTEST+0x199>
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1050 <instr_rbit@plt>
mov    %eax,%r15d
mov    %ebp,%edi
call   1060 <prog_rbit@plt>
cmp    %eax,%r15d
jne    12f3 <REVERSE_BIT_32b_AUTOTEST+0x1a3>
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1050 <instr_rbit@plt>
mov    %eax,%r15d
mov    %ebp,%edi
call   1060 <prog_rbit@plt>
cmp    %eax,%r15d
jne    12fd <REVERSE_BIT_32b_AUTOTEST+0x1ad>
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1050 <instr_rbit@plt>
mov    %eax,%r15d
mov    %ebp,%edi
call   1060 <prog_rbit@plt>
cmp    %eax,%r15d
jne    1307 <REVERSE_BIT_32b_AUTOTEST+0x1b7>
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1050 <instr_rbit@plt>
mov    %eax,%r15d
mov    %ebp,%edi
call   1060 <prog_rbit@plt>
cmp    %eax,%r15d
jne    1311 <REVERSE_BIT_32b_AUTOTEST+0x1c1>
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1050 <instr_rbit@plt>
mov    %eax,%r15d
mov    %ebp,%edi
call   1060 <prog_rbit@plt>
cmp    %eax,%r15d
jne    131b <REVERSE_BIT_32b_AUTOTEST+0x1cb>
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1050 <instr_rbit@plt>
mov    %eax,%r15d
mov    %ebp,%edi
call   1060 <prog_rbit@plt>
cmp    %eax,%r15d
jne    1325 <REVERSE_BIT_32b_AUTOTEST+0x1d5>
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1050 <instr_rbit@plt>
mov    %eax,%r15d
mov    %ebp,%edi
call   1060 <prog_rbit@plt>
cmp    %eax,%r15d
jne    132f <REVERSE_BIT_32b_AUTOTEST+0x1df>
lea    0xde2(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%r14d
jmp    1385 <REVERSE_BIT_32b_AUTOTEST+0x235>
mov    %eax,%ebx
xor    %r12d,%r12d
jmp    1337 <REVERSE_BIT_32b_AUTOTEST+0x1e7>
mov    %eax,%ebx
mov    $0x1,%r12d
jmp    1337 <REVERSE_BIT_32b_AUTOTEST+0x1e7>
mov    %eax,%ebx
mov    $0x2,%r12d
jmp    1337 <REVERSE_BIT_32b_AUTOTEST+0x1e7>
mov    %eax,%ebx
mov    $0x3,%r12d
jmp    1337 <REVERSE_BIT_32b_AUTOTEST+0x1e7>
mov    %eax,%ebx
mov    $0x4,%r12d
jmp    1337 <REVERSE_BIT_32b_AUTOTEST+0x1e7>
mov    %eax,%ebx
mov    $0x5,%r12d
jmp    1337 <REVERSE_BIT_32b_AUTOTEST+0x1e7>
mov    %eax,%ebx
mov    $0x6,%r12d
jmp    1337 <REVERSE_BIT_32b_AUTOTEST+0x1e7>
mov    %eax,%ebx
mov    $0x7,%r12d
jmp    1337 <REVERSE_BIT_32b_AUTOTEST+0x1e7>
mov    %eax,%ebx
mov    $0x8,%r12d
jmp    1337 <REVERSE_BIT_32b_AUTOTEST+0x1e7>
mov    %eax,%ebx
mov    $0x9,%r12d
lea    0xd97(%rip),%rdi
call   1030 <puts@plt>
lea    0xcb6(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xccb(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xcd8(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xce4(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [46 x i8] c"LAUNCHING THE (REVERSE_BIT) RESOURCE TEST...\0A\00"
@.str.1 = [50 x i8] c"- TEST OF THE (REVERSE_BIT) RESOURCE => FAILED !\0A\00"
@.str.2 = [38 x i8] c" + %d COMPUTATION BEFORE ERROR... !\0A\00"
@.str.3 = [29 x i8] c" + OPERANDE 1 [%x]\0A\00"
@.str.4 = [29 x i8] c" + INSTRUCTION RESULT [%x]\0A\00"
@.str.5 = [29 x i8] c" + C CODE RESULT [%x]\0A\00"
@.str.6 = [44 x i8] c"- TEST OF THE (REVERSE_BIT) RESOURCE => OK\0A\00"
define i32 @REVERSE_BIT_32b_AUTOTEST() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %8
8: ; preds = %31, %0
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 10
br i1 %10, label %11, label %34
11: ; preds = %8
%12 = call i32 (...) @rand()
store i32 %12, i32* %4
%13 = load i32, i32* %4
%14 = call i32 @instr_rbit(i32 %13)
store i32 %14, i32* %5
%15 = load i32, i32* %4
%16 = call i32 @prog_rbit(i32 %15)
store i32 %16, i32* %6
%17 = load i32, i32* %5
%18 = load i32, i32* %6
%19 = icmp ne i32 %17, %18
br i1 %19, label %20, label %30
20: ; preds = %11
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0))
%22 = load i32, i32* %3
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i32 %22)
%24 = load i32, i32* %4
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %5
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 %26)
%28 = load i32, i32* %6
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i32 %28)
store i32 0, i32* %1
br label %36
30: ; preds = %11
br label %31
31: ; preds = %30
%32 = load i32, i32* %3
%33 = add nsw i32 %32, 1
store i32 %33, i32* %3
br label %8
34: ; preds = %8
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %1
br label %36
36: ; preds = %34, %20
%37 = load i32, i32* %1
ret i32 %37
}

LLVM IR (-O2):
@.str.2 = [38 x i8] c" + %d COMPUTATION BEFORE ERROR... !\0A\00"
@.str.3 = [29 x i8] c" + OPERANDE 1 [%x]\0A\00"
@.str.4 = [29 x i8] c" + INSTRUCTION RESULT [%x]\0A\00"
@.str.5 = [29 x i8] c" + C CODE RESULT [%x]\0A\00"
@str = [45 x i8] c"LAUNCHING THE (REVERSE_BIT) RESOURCE TEST...\00"
@str.7 = [43 x i8] c"- TEST OF THE (REVERSE_BIT) RESOURCE => OK\00"
@str.8 = [49 x i8] c"- TEST OF THE (REVERSE_BIT) RESOURCE => FAILED !\00"
define i32 @REVERSE_BIT_32b_AUTOTEST() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (...) @rand()
%3 = tail call i32 @instr_rbit(i32 %2)
%4 = tail call i32 @prog_rbit(i32 %2)
%5 = icmp eq i32 %3, %4
br i1 %5, label %16, label %6
6: ; preds = %56, %51, %46, %41, %36, %31, %26, %21, %16, %0
%7 = phi i32 [ 0, %0 ], [ 1, %16 ], [ 2, %21 ], [ 3, %26 ], [ 4, %31 ], [ 5, %36 ], [ 6, %41 ], [ 7, %46 ], [ 8, %51 ], [ 9, %56 ]
%8 = phi i32 [ %2, %0 ], [ %17, %16 ], [ %22, %21 ], [ %27, %26 ], [ %32, %31 ], [ %37, %36 ], [ %42, %41 ], [ %47, %46 ], [ %52, %51 ], [ %57, %56 ]
%9 = phi i32 [ %3, %0 ], [ %18, %16 ], [ %23, %21 ], [ %28, %26 ], [ %33, %31 ], [ %38, %36 ], [ %43, %41 ], [ %48, %46 ], [ %53, %51 ], [ %58, %56 ]
%10 = phi i32 [ %4, %0 ], [ %19, %16 ], [ %24, %21 ], [ %29, %26 ], [ %34, %31 ], [ %39, %36 ], [ %44, %41 ], [ %49, %46 ], [ %54, %51 ], [ %59, %56 ]
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str.8, i64 0, i64 0))
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 %8)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 %9)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i32 %10)
br label %63
16: ; preds = %0
%17 = tail call i32 (...) @rand()
%18 = tail call i32 @instr_rbit(i32 %17)
%19 = tail call i32 @prog_rbit(i32 %17)
%20 = icmp eq i32 %18, %19
br i1 %20, label %21, label %6
21: ; preds = %16
%22 = tail call i32 (...) @rand()
%23 = tail call i32 @instr_rbit(i32 %22)
%24 = tail call i32 @prog_rbit(i32 %22)
%25 = icmp eq i32 %23, %24
br i1 %25, label %26, label %6
26: ; preds = %21
%27 = tail call i32 (...) @rand()
%28 = tail call i32 @instr_rbit(i32 %27)
%29 = tail call i32 @prog_rbit(i32 %27)
%30 = icmp eq i32 %28, %29
br i1 %30, label %31, label %6
31: ; preds = %26
%32 = tail call i32 (...) @rand()
%33 = tail call i32 @instr_rbit(i32 %32)
%34 = tail call i32 @prog_rbit(i32 %32)
%35 = icmp eq i32 %33, %34
br i1 %35, label %36, label %6
36: ; preds = %31
%37 = tail call i32 (...) @rand()
%38 = tail call i32 @instr_rbit(i32 %37)
%39 = tail call i32 @prog_rbit(i32 %37)
%40 = icmp eq i32 %38, %39
br i1 %40, label %41, label %6
41: ; preds = %36
%42 = tail call i32 (...) @rand()
%43 = tail call i32 @instr_rbit(i32 %42)
%44 = tail call i32 @prog_rbit(i32 %42)
%45 = icmp eq i32 %43, %44
br i1 %45, label %46, label %6
46: ; preds = %41
%47 = tail call i32 (...) @rand()
%48 = tail call i32 @instr_rbit(i32 %47)
%49 = tail call i32 @prog_rbit(i32 %47)
%50 = icmp eq i32 %48, %49
br i1 %50, label %51, label %6
51: ; preds = %46
%52 = tail call i32 (...) @rand()
%53 = tail call i32 @instr_rbit(i32 %52)
%54 = tail call i32 @prog_rbit(i32 %52)
%55 = icmp eq i32 %53, %54
br i1 %55, label %56, label %6
56: ; preds = %51
%57 = tail call i32 (...) @rand()
%58 = tail call i32 @instr_rbit(i32 %57)
%59 = tail call i32 @prog_rbit(i32 %57)
%60 = icmp eq i32 %58, %59
br i1 %60, label %61, label %6
61: ; preds = %56
%62 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.7, i64 0, i64 0))
br label %63
63: ; preds = %6, %61
%64 = phi i32 [ 0, %6 ], [ 1, %61 ]
ret i32 %64
}