#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_fudiv(int, int);
int instr_mod(int, int);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int DIVIDER_32b_AUTOTEST() {
  printf("LAUNCHING THE (uDIV/MOD) RESOURCE TEST...\n");
  int isOk1 = 1;
  int i, j;
  for (j = 0; j < 10; j++) {
    int op1 = rand() % 65536;
    int op2 = rand() % 65536;
    int res1 = instr_fudiv(op1, op2);
    int res2 = instr_fudiv(op1, op2);
    int res3 = instr_mod(op1, op2);
    int res4 = instr_mod(op1, op2);
    if ((res1 != res2) || (res3 != res4)) {
      printf("- TEST OF THE DIVIDER_32b RESOURCE => FAILED !\n");
      printf("  + %d COMPUTATION BEFORE ERROR... !\n", j);
      printf("  + INSTRUCTION RESULT (%d udiv %d) => %d\n", op1, op2, res1);
      printf("  + C CODE RESULT      (%d udiv %d) => %d\n", op1, op2, res2);
      printf("  + INSTRUCTION RESULT (%d umod %d) => %d\n", op1, op2, res3);
      printf("  + C CODE RESULT      (%d umod %d) => %d\n", op1, op2, res4);
      return 0;
    }
  }
  printf("- TEST OF THE DIVIDER_32b RESOURCE => OK\n");
  return 1;
}


x86 assembly (clang, -O0):
<DIVIDER_32b_AUTOTEST>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0xa,-0x10(%rbp)
jge    127c <DIVIDER_32b_AUTOTEST+0x13c>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x10000,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x10000,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1050 <instr_fudiv@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1050 <instr_fudiv@plt>
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1040 <instr_mod@plt>
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1040 <instr_mod@plt>
mov    %eax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jne    11e2 <DIVIDER_32b_AUTOTEST+0xa2>
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
je     1269 <DIVIDER_32b_AUTOTEST+0x129>
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x20(%rbp),%ecx
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x24(%rbp),%ecx
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x28(%rbp),%ecx
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1291 <DIVIDER_32b_AUTOTEST+0x151>
jmp    126e <DIVIDER_32b_AUTOTEST+0x12e>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1164 <DIVIDER_32b_AUTOTEST+0x24>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DIVIDER_32b_AUTOTEST>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xf70(%rip),%rdi
call   1030 <puts@plt>
xor    %ebp,%ebp
nopl   0x0(%rax)
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%r14d
lea    0xffff(%r14),%eax
test   %r14d,%r14d
cmovns %r14d,%eax
and    $0xffff0000,%eax
sub    %eax,%r14d
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
mov    %r14d,%edi
mov    %ebx,%esi
call   1060 <instr_fudiv@plt>
mov    %eax,%r15d
mov    %r14d,%edi
mov    %ebx,%esi
call   1060 <instr_fudiv@plt>
mov    %eax,%r13d
mov    %r14d,%edi
mov    %ebx,%esi
call   1050 <instr_mod@plt>
mov    %eax,%r12d
mov    %r14d,%edi
mov    %ebx,%esi
call   1050 <instr_mod@plt>
cmp    %r13d,%r15d
jne    1201 <DIVIDER_32b_AUTOTEST+0xb1>
cmp    %eax,%r12d
jne    1201 <DIVIDER_32b_AUTOTEST+0xb1>
add    $0x1,%ebp
cmp    $0xa,%ebp
jne    1170 <DIVIDER_32b_AUTOTEST+0x20>
lea    0xf07(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
jmp    127c <DIVIDER_32b_AUTOTEST+0x12c>
lea    0xf1d(%rip),%rdi
mov    %eax,0x4(%rsp)
call   1030 <puts@plt>
lea    0xde8(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdfe(%rip),%rdi
mov    %r14d,%esi
mov    %ebx,%edx
mov    %r15d,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe13(%rip),%rdi
mov    %r14d,%esi
mov    %ebx,%edx
mov    %r13d,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe28(%rip),%rdi
mov    %r14d,%esi
mov    %ebx,%edx
mov    %r12d,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe3d(%rip),%rdi
mov    %r14d,%esi
mov    %ebx,%edx
mov    0x4(%rsp),%ecx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [43 x i8] c"LAUNCHING THE (uDIV/MOD) RESOURCE TEST...\0A\00"
@.str.1 = [48 x i8] c"- TEST OF THE DIVIDER_32b RESOURCE => FAILED !\0A\00"
@.str.2 = [38 x i8] c" + %d COMPUTATION BEFORE ERROR... !\0A\00"
@.str.3 = [43 x i8] c" + INSTRUCTION RESULT (%d udiv %d) => %d\0A\00"
@.str.4 = [43 x i8] c" + C CODE RESULT (%d udiv %d) => %d\0A\00"
@.str.5 = [43 x i8] c" + INSTRUCTION RESULT (%d umod %d) => %d\0A\00"
@.str.6 = [43 x i8] c" + C CODE RESULT (%d umod %d) => %d\0A\00"
@.str.7 = [42 x i8] c"- TEST OF THE DIVIDER_32b RESOURCE => OK\0A\00"
define i32 @DIVIDER_32b_AUTOTEST() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %2
store i32 0, i32* %4
br label %12
12: ; preds = %60, %0
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 10
br i1 %14, label %15, label %63
15: ; preds = %12
%16 = call i32 (...) @rand()
%17 = srem i32 %16, 65536
store i32 %17, i32* %5
%18 = call i32 (...) @rand()
%19 = srem i32 %18, 65536
store i32 %19, i32* %6
%20 = load i32, i32* %5
%21 = load i32, i32* %6
%22 = call i32 @instr_fudiv(i32 %20, i32 %21)
store i32 %22, i32* %7
%23 = load i32, i32* %5
%24 = load i32, i32* %6
%25 = call i32 @instr_fudiv(i32 %23, i32 %24)
store i32 %25, i32* %8
%26 = load i32, i32* %5
%27 = load i32, i32* %6
%28 = call i32 @instr_mod(i32 %26, i32 %27)
store i32 %28, i32* %9
%29 = load i32, i32* %5
%30 = load i32, i32* %6
%31 = call i32 @instr_mod(i32 %29, i32 %30)
store i32 %31, i32* %10
%32 = load i32, i32* %7
%33 = load i32, i32* %8
%34 = icmp ne i32 %32, %33
br i1 %34, label %39, label %35
35: ; preds = %15
%36 = load i32, i32* %9
%37 = load i32, i32* %10
%38 = icmp ne i32 %36, %37
br i1 %38, label %39, label %59
39: ; preds = %35, %15
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0))
%41 = load i32, i32* %4
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i32 %41)
%43 = load i32, i32* %5
%44 = load i32, i32* %6
%45 = load i32, i32* %7
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i32 %43, i32 %44, i32 %45)
%47 = load i32, i32* %5
%48 = load i32, i32* %6
%49 = load i32, i32* %8
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), i32 %47, i32 %48, i32 %49)
%51 = load i32, i32* %5
%52 = load i32, i32* %6
%53 = load i32, i32* %9
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0), i32 %51, i32 %52, i32 %53)
%55 = load i32, i32* %5
%56 = load i32, i32* %6
%57 = load i32, i32* %10
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0), i32 %55, i32 %56, i32 %57)
store i32 0, i32* %1
br label %65
59: ; preds = %35
br label %60
60: ; preds = %59
%61 = load i32, i32* %4
%62 = add nsw i32 %61, 1
store i32 %62, i32* %4
br label %12
63: ; preds = %12
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %1
br label %65
65: ; preds = %63, %39
%66 = load i32, i32* %1
ret i32 %66
}

LLVM IR (-O2):
@.str.2 = [38 x i8] c" + %d COMPUTATION BEFORE ERROR... !\0A\00"
@.str.3 = [43 x i8] c" + INSTRUCTION RESULT (%d udiv %d) => %d\0A\00"
@.str.4 = [43 x i8] c" + C CODE RESULT (%d udiv %d) => %d\0A\00"
@.str.5 = [43 x i8] c" + INSTRUCTION RESULT (%d umod %d) => %d\0A\00"
@.str.6 = [43 x i8] c" + C CODE RESULT (%d umod %d) => %d\0A\00"
@str = [42 x i8] c"LAUNCHING THE (uDIV/MOD) RESOURCE TEST...\00"
@str.8 = [41 x i8] c"- TEST OF THE DIVIDER_32b RESOURCE => OK\00"
@str.9 = [47 x i8] c"- TEST OF THE DIVIDER_32b RESOURCE => FAILED !\00"
define i32 @DIVIDER_32b_AUTOTEST() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str, i64 0, i64 0))
br label %2
2: ; preds = %0, %22
%3 = phi i32 [ 0, %0 ], [ %23, %22 ]
%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_fudiv(i32 %5, i32 %7)
%9 = tail call i32 @instr_fudiv(i32 %5, i32 %7)
%10 = tail call i32 @instr_mod(i32 %5, i32 %7)
%11 = tail call i32 @instr_mod(i32 %5, i32 %7)
%12 = icmp eq i32 %8, %9
%13 = icmp eq i32 %10, %11
%14 = select i1 %12, i1 %13, i1 false
br i1 %14, label %22, label %15
15: ; preds = %2
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str.9, i64 0, i64 0))
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i32 %3)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i32 %5, i32 %7, i32 %8)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), i32 %5, i32 %7, i32 %9)
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0), i32 %5, i32 %7, i32 %10)
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0), i32 %5, i32 %7, i32 %11)
br label %27
22: ; preds = %2
%23 = add nuw nsw i32 %3, 1
%24 = icmp eq i32 %23, 10
br i1 %24, label %25, label %2
25: ; preds = %22
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.8, i64 0, i64 0))
br label %27
27: ; preds = %15, %25
%28 = phi i32 [ 1, %25 ], [ 0, %15 ]
ret i32 %28
}