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


x86 assembly (clang, -O0):
<MAXIMUM_32b_AUTOTEST>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    1250 <MAXIMUM_32b_AUTOTEST+0x110>
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    $0x10000,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1030 <instr_max@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1030 <instr_max@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1050 <prog_max@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jne    11cd <MAXIMUM_32b_AUTOTEST+0x8d>
mov    -0x18(%rbp),%eax
cmp    -0x20(%rbp),%eax
je     123d <MAXIMUM_32b_AUTOTEST+0xfd>
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x1c(%rbp),%ecx
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x20(%rbp),%ecx
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1265 <MAXIMUM_32b_AUTOTEST+0x125>
jmp    1242 <MAXIMUM_32b_AUTOTEST+0x102>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115d <MAXIMUM_32b_AUTOTEST+0x1d>
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MAXIMUM_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    0xffff(%rbp),%eax
test   %ebp,%ebp
cmovns %ebp,%eax
and    $0xffff0000,%eax
sub    %eax,%ebp
mov    %ebx,%edi
mov    %ebp,%esi
call   1040 <instr_max@plt>
mov    %eax,%r13d
mov    %ebp,%edi
mov    %ebx,%esi
call   1040 <instr_max@plt>
mov    %eax,%r12d
mov    %ebx,%edi
mov    %ebp,%esi
call   1060 <prog_max@plt>
mov    %eax,%r15d
cmp    %r12d,%r13d
jne    11f1 <MAXIMUM_32b_AUTOTEST+0xa1>
cmp    %r15d,%r13d
jne    11f1 <MAXIMUM_32b_AUTOTEST+0xa1>
add    $0x1,%r14d
cmp    $0xa,%r14d
jne    1170 <MAXIMUM_32b_AUTOTEST+0x20>
lea    0xeba(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
jmp    124e <MAXIMUM_32b_AUTOTEST+0xfe>
lea    0xece(%rip),%rdi
call   1030 <puts@plt>
lea    0xdfc(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe11(%rip),%r14
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %r13d,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %r12d,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe10(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %r15d,%ecx
xor    %eax,%eax
call   1050 <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 = [42 x i8] c"LAUNCHING THE (MAXIMUM) RESOURCE TEST...\0A\00"
@.str.1 = [46 x i8] c"- TEST OF THE (MAXIMUM) 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 = [40 x i8] c"- TEST OF THE (MAXIMUM) RESOURCE => OK\0A\00"
define i32 @MAXIMUM_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 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %10
10: ; preds = %51, %0
%11 = load i32, i32* %3
%12 = icmp slt i32 %11, 10
br i1 %12, label %13, label %54
13: ; preds = %10
%14 = call i32 (...) @rand()
%15 = srem i32 %14, 65536
store i32 %15, i32* %4
%16 = call i32 (...) @rand()
%17 = srem i32 %16, 65536
store i32 %17, i32* %5
%18 = load i32, i32* %4
%19 = load i32, i32* %5
%20 = call i32 @instr_max(i32 %18, i32 %19)
store i32 %20, i32* %6
%21 = load i32, i32* %5
%22 = load i32, i32* %4
%23 = call i32 @instr_max(i32 %21, i32 %22)
store i32 %23, i32* %7
%24 = load i32, i32* %4
%25 = load i32, i32* %5
%26 = call i32 @prog_max(i32 %24, i32 %25)
store i32 %26, i32* %8
%27 = load i32, i32* %6
%28 = load i32, i32* %7
%29 = icmp ne i32 %27, %28
br i1 %29, label %34, label %30
30: ; preds = %13
%31 = load i32, i32* %6
%32 = load i32, i32* %8
%33 = icmp ne i32 %31, %32
br i1 %33, label %34, label %50
34: ; preds = %30, %13
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0))
%36 = load i32, i32* %3
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i32 %36)
%38 = load i32, i32* %4
%39 = load i32, i32* %5
%40 = load i32, i32* %6
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i32 %38, i32 %39, i32 %40)
%42 = load i32, i32* %5
%43 = load i32, i32* %4
%44 = load i32, i32* %7
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i32 %42, i32 %43, i32 %44)
%46 = load i32, i32* %5
%47 = load i32, i32* %4
%48 = load i32, i32* %8
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i32 %46, i32 %47, i32 %48)
store i32 0, i32* %1
br label %56
50: ; preds = %30
br label %51
51: ; preds = %50
%52 = load i32, i32* %3
%53 = add nsw i32 %52, 1
store i32 %53, i32* %3
br label %10
54: ; preds = %10
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %1
br label %56
56: ; preds = %54, %34
%57 = load i32, i32* %1
ret i32 %57
}

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 = [41 x i8] c"LAUNCHING THE (MAXIMUM) RESOURCE TEST...\00"
@str.6 = [39 x i8] c"- TEST OF THE (MAXIMUM) RESOURCE => OK\00"
@str.7 = [45 x i8] c"- TEST OF THE (MAXIMUM) RESOURCE => FAILED !\00"
define i32 @MAXIMUM_32b_AUTOTEST() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
br label %2
2: ; preds = %0, %20
%3 = phi i32 [ 0, %0 ], [ %21, %20 ]
%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_max(i32 %5, i32 %7)
%9 = tail call i32 @instr_max(i32 %7, i32 %5)
%10 = tail call i32 @prog_max(i32 %5, i32 %7)
%11 = icmp eq i32 %8, %9
%12 = icmp eq i32 %8, %10
%13 = select i1 %11, i1 %12, i1 false
br i1 %13, label %20, label %14
14: ; preds = %2
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.7, i64 0, i64 0))
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i32 %3)
%17 = 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)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i32 %7, i32 %5, i32 %9)
%19 = 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 %10)
br label %25
20: ; preds = %2
%21 = add nuw nsw i32 %3, 1
%22 = icmp eq i32 %21, 10
br i1 %22, label %23, label %2
23: ; preds = %20
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.6, i64 0, i64 0))
br label %25
25: ; preds = %14, %23
%26 = phi i32 [ 1, %23 ], [ 0, %14 ]
ret i32 %26
}