#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_rshift(int, int);
int /*<<< orphan*/ printf(char *, ...);
int prog_rshift(int, int);
int rand();
int RIGHT_SHIFTER_32b_AUTOTEST() {
  int i, j;
  printf("LAUNCHING THE (RIGHT_SHIFTER) RESOURCE AUTOTEST...\n");
  for (j = 0; j < 10; j++) {
    int op1 = rand() % 65536;
    int op2 = rand() % 32;
    int res1 = instr_rshift(op1, op2);
    int res3 = prog_rshift(op1, op2);
    if (res1 != res3) {
      printf("- TEST OF THE (RIGHT_SHIFTER) RESOURCE => FAILED !\n");
      printf("  + %d COMPUTATION BEFORE ERROR... !\n", j);
      printf("  + INSTRUCTION RESULT (%d l %d) => %d\n", op1, op2, res1);
      printf("  + C CODE RESULT      (%d l %d) => %d\n", op2, op1, res3);
      return 0;
    }
  }
  printf("- TEST OF THE (RIGHT_SHIFTER) RESOURCE => OK\n");
  return 1;
}


x86 assembly (clang, -O0):
<RIGHT_SHIFTER_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    121f <RIGHT_SHIFTER_32b_AUTOTEST+0xdf>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x10000,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x20,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1050 <instr_rshift@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1040 <prog_rshift@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
je     120c <RIGHT_SHIFTER_32b_AUTOTEST+0xcc>
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x1c(%rbp),%ecx
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1234 <RIGHT_SHIFTER_32b_AUTOTEST+0xf4>
jmp    1211 <RIGHT_SHIFTER_32b_AUTOTEST+0xd1>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115d <RIGHT_SHIFTER_32b_AUTOTEST+0x1d>
lea    0xeb8(%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):
<RIGHT_SHIFTER_32b_AUTOTEST>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xf14(%rip),%rdi
call   1030 <puts@plt>
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%ebx
lea    0xffff(%rbx),%eax
test   %ebx,%ebx
cmovns %ebx,%eax
and    $0xffff0000,%eax
sub    %eax,%ebx
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%ebp
lea    0x1f(%rbp),%eax
test   %ebp,%ebp
cmovns %ebp,%eax
and    $0xffffffe0,%eax
sub    %eax,%ebp
mov    %ebx,%edi
mov    %ebp,%esi
call   1060 <instr_rshift@plt>
mov    %eax,%r12d
mov    %ebx,%edi
mov    %ebp,%esi
call   1050 <prog_rshift@plt>
cmp    %eax,%r12d
jne    11d9 <RIGHT_SHIFTER_32b_AUTOTEST+0x89>
add    $0x1,%r14d
cmp    $0xa,%r14d
jne    1170 <RIGHT_SHIFTER_32b_AUTOTEST+0x20>
lea    0xedd(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%r13d
jmp    1226 <RIGHT_SHIFTER_32b_AUTOTEST+0xd6>
mov    %eax,%r15d
lea    0xef3(%rip),%rdi
call   1030 <puts@plt>
lea    0xe11(%rip),%rdi
xor    %r13d,%r13d
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe23(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %r12d,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe36(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %r15d,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str.2 = [38 x i8] c" + %d COMPUTATION BEFORE ERROR... !\0A\00"
@.str.3 = [40 x i8] c" + INSTRUCTION RESULT (%d l %d) => %d\0A\00"
@.str.4 = [40 x i8] c" + C CODE RESULT (%d l %d) => %d\0A\00"
@str = [51 x i8] c"LAUNCHING THE (RIGHT_SHIFTER) RESOURCE AUTOTEST...\00"
@str.6 = [45 x i8] c"- TEST OF THE (RIGHT_SHIFTER) RESOURCE => OK\00"
@str.7 = [51 x i8] c"- TEST OF THE (RIGHT_SHIFTER) RESOURCE => FAILED !\00"
define i32 @RIGHT_SHIFTER_32b_AUTOTEST() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str, i64 0, i64 0))
br label %2
2: ; preds = %0, %16
%3 = phi i32 [ 0, %0 ], [ %17, %16 ]
%4 = tail call i32 (...) @rand()
%5 = srem i32 %4, 65536
%6 = tail call i32 (...) @rand()
%7 = srem i32 %6, 32
%8 = tail call i32 @instr_rshift(i32 %5, i32 %7)
%9 = tail call i32 @prog_rshift(i32 %5, i32 %7)
%10 = icmp eq i32 %8, %9
br i1 %10, label %16, label %11
11: ; preds = %2
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.7, i64 0, i64 0))
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i32 %3)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i32 %5, i32 %7, i32 %8)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i32 %7, i32 %5, i32 %9)
br label %21
16: ; preds = %2
%17 = add nuw nsw i32 %3, 1
%18 = icmp eq i32 %17, 10
br i1 %18, label %19, label %2
19: ; preds = %16
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.6, i64 0, i64 0))
br label %21
21: ; preds = %11, %19
%22 = phi i32 [ 0, %11 ], [ 1, %19 ]
ret i32 %22
}