#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_mod(int, int);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int MODULUS_2x_32b_AUTOTEST() {
  int i, j;
  printf("LAUNCHING THE (MODULUS_2x_32b) RESOURCE AUTOTEST...\n");
  for (j = 0; j < 10; j++) {
    int op1 = rand() % 65536;
    int op2 = rand() % 65536;
    int res1 = instr_mod(op1, op2);
    int res3 = instr_mod(op1, op2);
    if (res1 != res3) {
      printf("TEST OF THE (MODULUS_2x_32b) 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 (MODULUS_2x_32b) RESOURCE => OK\n");
  return 1;
}


x86 assembly (clang, -O0):
<MODULUS_2x_32b_AUTOTEST>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    120f <MODULUS_2x_32b_AUTOTEST+0xdf>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x10000,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x10000,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1040 <instr_mod@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1040 <instr_mod@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
je     11fc <MODULUS_2x_32b_AUTOTEST+0xcc>
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x1c(%rbp),%ecx
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1224 <MODULUS_2x_32b_AUTOTEST+0xf4>
jmp    1201 <MODULUS_2x_32b_AUTOTEST+0xd1>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114d <MODULUS_2x_32b_AUTOTEST+0x1d>
lea    0xec2(%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):
<MODULUS_2x_32b_AUTOTEST>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xf1e(%rip),%rdi
call   1030 <puts@plt>
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <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   1060 <rand@plt>
mov    %eax,%ebp
lea    0xffff(%rbp),%eax
test   %ebp,%ebp
cmovns %ebp,%eax
and    $0xffff0000,%eax
sub    %eax,%ebp
mov    %ebx,%edi
mov    %ebp,%esi
call   1050 <instr_mod@plt>
mov    %eax,%r12d
mov    %ebx,%edi
mov    %ebp,%esi
call   1050 <instr_mod@plt>
cmp    %eax,%r12d
jne    11ce <MODULUS_2x_32b_AUTOTEST+0x8e>
add    $0x1,%r14d
cmp    $0xa,%r14d
jne    1160 <MODULUS_2x_32b_AUTOTEST+0x20>
lea    0xee3(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%r13d
jmp    121b <MODULUS_2x_32b_AUTOTEST+0xdb>
mov    %eax,%r15d
lea    0xefa(%rip),%rdi
call   1030 <puts@plt>
lea    0xe1c(%rip),%rdi
xor    %r13d,%r13d
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe2c(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %r12d,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe3d(%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 = [53 x i8] c"LAUNCHING THE (MODULUS_2x_32b) RESOURCE AUTOTEST...\0A\00"
@.str.1 = [51 x i8] c"TEST OF THE (MODULUS_2x_32b) RESOURCE => FAILED !\0A\00"
@.str.2 = [36 x i8] c"- %d COMPUTATION BEFORE ERROR... !\0A\00"
@.str.3 = [38 x i8] c"- INSTRUCTION RESULT (%d l %d) => %d\0A\00"
@.str.4 = [38 x i8] c"- C CODE RESULT (%d l %d) => %d\0A\00"
@.str.5 = [47 x i8] c"- TEST OF THE (MODULUS_2x_32b) RESOURCE => OK\0A\00"
define i32 @MODULUS_2x_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 ([53 x i8], [53 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, 65536
store i32 %16, i32* %5
%17 = load i32, i32* %4
%18 = load i32, i32* %5
%19 = call i32 @instr_mod(i32 %17, i32 %18)
store i32 %19, i32* %6
%20 = load i32, i32* %4
%21 = load i32, i32* %5
%22 = call i32 @instr_mod(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 ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
%28 = load i32, i32* %3
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 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 ([38 x i8], [38 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 ([38 x i8], [38 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 ([47 x i8], [47 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 = [36 x i8] c"- %d COMPUTATION BEFORE ERROR... !\0A\00"
@.str.3 = [38 x i8] c"- INSTRUCTION RESULT (%d l %d) => %d\0A\00"
@.str.4 = [38 x i8] c"- C CODE RESULT (%d l %d) => %d\0A\00"
@str = [52 x i8] c"LAUNCHING THE (MODULUS_2x_32b) RESOURCE AUTOTEST...\00"
@str.6 = [46 x i8] c"- TEST OF THE (MODULUS_2x_32b) RESOURCE => OK\00"
@str.7 = [50 x i8] c"TEST OF THE (MODULUS_2x_32b) RESOURCE => FAILED !\00"
define i32 @MODULUS_2x_32b_AUTOTEST() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 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, 65536
%8 = tail call i32 @instr_mod(i32 %5, i32 %7)
%9 = tail call i32 @instr_mod(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 ([50 x i8], [50 x i8]* @str.7, i64 0, i64 0))
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i32 %3)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 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 ([38 x i8], [38 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 ([46 x i8], [46 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
}