#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_pgdc(int, int);
int /*<<< orphan*/ printf(char *, ...);
int prog_pgdc(int, int);
int rand();
int PGDC_32b_AUTOTEST() {
  printf("LAUNCHING THE (PGCD) RESOURCE TEST...\n");
  int i, j;
  for (j = 0; j < 10; j++) {
    int op1 = rand() % 255;
    int op2 = rand() % 255;
    int res1 = instr_pgdc(op1, op2);
    int res2 = instr_pgdc(op2, op1);
    int res3 = prog_pgdc(op1, op2);
    if ((res1 != res3) || (res2 != res3)) {
      printf("- TEST OF THE PGDC 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 PGDC RESOURCE => OK\n");
  return 1;
}


x86 assembly (clang, -O0):
<PGDC_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 <PGDC_32b_AUTOTEST+0x110>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0xff,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0xff,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1050 <instr_pgdc@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1050 <instr_pgdc@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1030 <prog_pgdc@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x20(%rbp),%eax
jne    11cd <PGDC_32b_AUTOTEST+0x8d>
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
je     123d <PGDC_32b_AUTOTEST+0xfd>
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x1c(%rbp),%ecx
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x20(%rbp),%ecx
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1265 <PGDC_32b_AUTOTEST+0x125>
jmp    1242 <PGDC_32b_AUTOTEST+0x102>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115d <PGDC_32b_AUTOTEST+0x1d>
lea    0xe6f(%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):
<PGDC_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>
cltq
imul   $0xffffffff80808081,%rax,%rbx
shr    $0x20,%rbx
add    %eax,%ebx
mov    %ebx,%ecx
shr    $0x1f,%ecx
sar    $0x7,%ebx
add    %ecx,%ebx
mov    %ebx,%ecx
shl    $0x8,%ecx
sub    %ecx,%ebx
add    %eax,%ebx
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0xffffffff80808081,%rax,%rbp
shr    $0x20,%rbp
add    %eax,%ebp
mov    %ebp,%ecx
shr    $0x1f,%ecx
sar    $0x7,%ebp
add    %ecx,%ebp
mov    %ebp,%ecx
shl    $0x8,%ecx
sub    %ecx,%ebp
add    %eax,%ebp
mov    %ebx,%edi
mov    %ebp,%esi
call   1060 <instr_pgdc@plt>
mov    %eax,%r13d
mov    %ebp,%edi
mov    %ebx,%esi
call   1060 <instr_pgdc@plt>
mov    %eax,%r12d
mov    %ebx,%edi
mov    %ebp,%esi
call   1040 <prog_pgdc@plt>
mov    %eax,%r15d
cmp    %eax,%r13d
jne    1211 <PGDC_32b_AUTOTEST+0xc1>
cmp    %r15d,%r12d
jne    1211 <PGDC_32b_AUTOTEST+0xc1>
add    $0x1,%r14d
cmp    $0xa,%r14d
jne    1170 <PGDC_32b_AUTOTEST+0x20>
lea    0xe97(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
jmp    126e <PGDC_32b_AUTOTEST+0x11e>
lea    0xea6(%rip),%rdi
call   1030 <puts@plt>
lea    0xddc(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xdf1(%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    0xdf0(%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 = [39 x i8] c"LAUNCHING THE (PGCD) RESOURCE TEST...\0A\00"
@.str.1 = [41 x i8] c"- TEST OF THE PGDC 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 = [35 x i8] c"- TEST OF THE PGDC RESOURCE => OK\0A\00"
define i32 @PGDC_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 ([39 x i8], [39 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, 255
store i32 %15, i32* %4
%16 = call i32 (...) @rand()
%17 = srem i32 %16, 255
store i32 %17, i32* %5
%18 = load i32, i32* %4
%19 = load i32, i32* %5
%20 = call i32 @instr_pgdc(i32 %18, i32 %19)
store i32 %20, i32* %6
%21 = load i32, i32* %5
%22 = load i32, i32* %4
%23 = call i32 @instr_pgdc(i32 %21, i32 %22)
store i32 %23, i32* %7
%24 = load i32, i32* %4
%25 = load i32, i32* %5
%26 = call i32 @prog_pgdc(i32 %24, i32 %25)
store i32 %26, i32* %8
%27 = load i32, i32* %6
%28 = load i32, i32* %8
%29 = icmp ne i32 %27, %28
br i1 %29, label %34, label %30
30: ; preds = %13
%31 = load i32, i32* %7
%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 ([41 x i8], [41 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 ([35 x i8], [35 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 = [38 x i8] c"LAUNCHING THE (PGCD) RESOURCE TEST...\00"
@str.6 = [34 x i8] c"- TEST OF THE PGDC RESOURCE => OK\00"
@str.7 = [40 x i8] c"- TEST OF THE PGDC RESOURCE => FAILED !\00"
define i32 @PGDC_32b_AUTOTEST() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 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, 255
%6 = tail call i32 (...) @rand()
%7 = srem i32 %6, 255
%8 = tail call i32 @instr_pgdc(i32 %5, i32 %7)
%9 = tail call i32 @instr_pgdc(i32 %7, i32 %5)
%10 = tail call i32 @prog_pgdc(i32 %5, i32 %7)
%11 = icmp eq i32 %8, %10
%12 = icmp eq i32 %9, %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 ([40 x i8], [40 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 ([34 x i8], [34 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
}