#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_q168dmini(int, int);
int /*<<< orphan*/ printf(char *, ...);
int prog_q168dmini(int, int);
int rand();
int Q16_8_DoubleMini_AUTOTEST() {
  printf("LAUNCHING THE (Q16_8_DoubleMini) RESOURCE AUTOTEST...\n");
  int i, j;
  for (j = 0; j < 10; j++) {
    int op1 = (rand() % 65536) - 32768;
    int op2 = (((rand() % 65536) - 32768) << 16) | ((rand() % 65536) - 32768);
    int op3 = instr_q168dmini(op1, op2);
    int op4 = prog_q168dmini(op1, op2);
    if (op3 != op4) {
      printf("- TEST OF THE (Q16_8_DoubleMini) RESOURCE => FAILED !\n");
      printf("  + %d COMPUTATION(s) BEFORE ERROR...\n", j);
      printf("  + OPERANDE 1 [%d]\n", op1);
      printf("  + OPERANDE 2 [%d, %d]\n", ((short)(op2 >> 16)), ((short)op2));
      printf("  + ASM INSTR. [%d, %d]\n", ((short)(op3 >> 16)), ((short)op3));
      printf("  + REF C CODE [%d, %d]\n", ((short)(op4 >> 16)), ((short)op4));
      return 0;
    }
  }
  printf("- TEST OF THE (Q16_8_DoubleMini) RESOURCE => OK\n");
  return 1;
}


x86 assembly (clang, -O0):
<Q16_8_DoubleMini_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    1286 <Q16_8_DoubleMini_AUTOTEST+0x146>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x10000,%ecx
cltd
idiv   %ecx
sub    $0x8000,%edx
mov    %edx,-0x10(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x10000,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
sub    $0x8000,%eax
shl    $0x10,%eax
mov    %eax,-0x20(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x10000,%ecx
cltd
idiv   %ecx
mov    -0x20(%rbp),%eax
sub    $0x8000,%edx
or     %edx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1050 <instr_q168dmini@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1030 <prog_q168dmini@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
je     1273 <Q16_8_DoubleMini_AUTOTEST+0x133>
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
sar    $0x10,%eax
movswl %ax,%esi
mov    -0x14(%rbp),%eax
movswl %ax,%edx
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
sar    $0x10,%eax
movswl %ax,%esi
mov    -0x18(%rbp),%eax
movswl %ax,%edx
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
sar    $0x10,%eax
movswl %ax,%esi
mov    -0x1c(%rbp),%eax
movswl %ax,%edx
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    129b <Q16_8_DoubleMini_AUTOTEST+0x15b>
jmp    1278 <Q16_8_DoubleMini_AUTOTEST+0x138>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115d <Q16_8_DoubleMini_AUTOTEST+0x1d>
lea    0xe68(%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):
<Q16_8_DoubleMini_AUTOTEST>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xf25(%rip),%rdi
call   1040 <puts@plt>
xor    %ebx,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
call   1070 <rand@plt>
lea    0xffff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffff0000,%ecx
neg    %ecx
lea    (%rax,%rcx,1),%r14d
add    $0xffff8000,%r14d
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%ebp
shl    $0x10,%ebp
xor    $0x80000000,%ebp
xor    %eax,%eax
call   1070 <rand@plt>
lea    0xffff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffff0000,%ecx
neg    %ecx
lea    (%rax,%rcx,1),%r15d
add    $0xffff8000,%r15d
or     %r15d,%ebp
mov    %r14d,%edi
mov    %ebp,%esi
call   1060 <instr_q168dmini@plt>
mov    %eax,%r13d
mov    %r14d,%edi
mov    %ebp,%esi
call   1030 <prog_q168dmini@plt>
cmp    %eax,%r13d
jne    120a <Q16_8_DoubleMini_AUTOTEST+0xba>
add    $0x1,%ebx
cmp    $0xa,%ebx
jne    1170 <Q16_8_DoubleMini_AUTOTEST+0x20>
lea    0xebf(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%eax
jmp    1283 <Q16_8_DoubleMini_AUTOTEST+0x133>
mov    %eax,%r12d
lea    0xed9(%rip),%rdi
call   1040 <puts@plt>
lea    0xde0(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xdf7(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
sar    $0x10,%ebp
movswl %r15w,%edx
lea    0xdf4(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r13d,%esi
sar    $0x10,%esi
movswl %r13w,%edx
lea    0xdf3(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12d,%esi
sar    $0x10,%esi
movswl %r12w,%edx
lea    0xdf4(%rip),%rdi
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 = [55 x i8] c"LAUNCHING THE (Q16_8_DoubleMini) RESOURCE AUTOTEST...\0A\00"
@.str.1 = [55 x i8] c"- TEST OF THE (Q16_8_DoubleMini) RESOURCE => FAILED !\0A\00"
@.str.2 = [39 x i8] c" + %d COMPUTATION(s) BEFORE ERROR...\0A\00"
@.str.3 = [21 x i8] c" + OPERANDE 1 [%d]\0A\00"
@.str.4 = [25 x i8] c" + OPERANDE 2 [%d, %d]\0A\00"
@.str.5 = [25 x i8] c" + ASM INSTR. [%d, %d]\0A\00"
@.str.6 = [25 x i8] c" + REF C CODE [%d, %d]\0A\00"
@.str.7 = [49 x i8] c"- TEST OF THE (Q16_8_DoubleMini) RESOURCE => OK\0A\00"
define i32 @Q16_8_DoubleMini_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 ([55 x i8], [55 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %9
9: ; preds = %64, %0
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 10
br i1 %11, label %12, label %67
12: ; preds = %9
%13 = call i32 (...) @rand()
%14 = srem i32 %13, 65536
%15 = sub nsw i32 %14, 32768
store i32 %15, i32* %4
%16 = call i32 (...) @rand()
%17 = srem i32 %16, 65536
%18 = sub nsw i32 %17, 32768
%19 = shl i32 %18, 16
%20 = call i32 (...) @rand()
%21 = srem i32 %20, 65536
%22 = sub nsw i32 %21, 32768
%23 = or i32 %19, %22
store i32 %23, i32* %5
%24 = load i32, i32* %4
%25 = load i32, i32* %5
%26 = call i32 @instr_q168dmini(i32 %24, i32 %25)
store i32 %26, i32* %6
%27 = load i32, i32* %4
%28 = load i32, i32* %5
%29 = call i32 @prog_q168dmini(i32 %27, i32 %28)
store i32 %29, i32* %7
%30 = load i32, i32* %6
%31 = load i32, i32* %7
%32 = icmp ne i32 %30, %31
br i1 %32, label %33, label %63
33: ; preds = %12
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0))
%35 = load i32, i32* %3
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %35)
%37 = load i32, i32* %4
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %37)
%39 = load i32, i32* %5
%40 = ashr i32 %39, 16
%41 = trunc i32 %40 to i16
%42 = sext i16 %41 to i32
%43 = load i32, i32* %5
%44 = trunc i32 %43 to i16
%45 = sext i16 %44 to i32
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %42, i32 %45)
%47 = load i32, i32* %6
%48 = ashr i32 %47, 16
%49 = trunc i32 %48 to i16
%50 = sext i16 %49 to i32
%51 = load i32, i32* %6
%52 = trunc i32 %51 to i16
%53 = sext i16 %52 to i32
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %50, i32 %53)
%55 = load i32, i32* %7
%56 = ashr i32 %55, 16
%57 = trunc i32 %56 to i16
%58 = sext i16 %57 to i32
%59 = load i32, i32* %7
%60 = trunc i32 %59 to i16
%61 = sext i16 %60 to i32
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i32 %58, i32 %61)
store i32 0, i32* %1
br label %69
63: ; preds = %12
br label %64
64: ; preds = %63
%65 = load i32, i32* %3
%66 = add nsw i32 %65, 1
store i32 %66, i32* %3
br label %9
67: ; preds = %9
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %1
br label %69
69: ; preds = %67, %33
%70 = load i32, i32* %1
ret i32 %70
}

LLVM IR (-O2):
@.str.2 = [39 x i8] c" + %d COMPUTATION(s) BEFORE ERROR...\0A\00"
@.str.3 = [21 x i8] c" + OPERANDE 1 [%d]\0A\00"
@.str.4 = [25 x i8] c" + OPERANDE 2 [%d, %d]\0A\00"
@.str.5 = [25 x i8] c" + ASM INSTR. [%d, %d]\0A\00"
@.str.6 = [25 x i8] c" + REF C CODE [%d, %d]\0A\00"
@str = [54 x i8] c"LAUNCHING THE (Q16_8_DoubleMini) RESOURCE AUTOTEST...\00"
@str.8 = [48 x i8] c"- TEST OF THE (Q16_8_DoubleMini) RESOURCE => OK\00"
@str.9 = [54 x i8] c"- TEST OF THE (Q16_8_DoubleMini) RESOURCE => FAILED !\00"
define i32 @Q16_8_DoubleMini_AUTOTEST() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str, i64 0, i64 0))
br label %2
2: ; preds = %0, %33
%3 = phi i32 [ 0, %0 ], [ %34, %33 ]
%4 = tail call i32 (...) @rand()
%5 = srem i32 %4, 65536
%6 = add nsw i32 %5, -32768
%7 = tail call i32 (...) @rand()
%8 = shl i32 %7, 16
%9 = xor i32 %8, -2147483648
%10 = tail call i32 (...) @rand()
%11 = srem i32 %10, 65536
%12 = add nsw i32 %11, -32768
%13 = or i32 %12, %9
%14 = tail call i32 @instr_q168dmini(i32 %6, i32 %13)
%15 = tail call i32 @prog_q168dmini(i32 %6, i32 %13)
%16 = icmp eq i32 %14, %15
br i1 %16, label %33, label %17
17: ; preds = %2
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.9, i64 0, i64 0))
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %3)
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %6)
%21 = ashr i32 %13, 16
%22 = shl i32 %12, 16
%23 = ashr exact i32 %22, 16
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %21, i32 %23)
%25 = ashr i32 %14, 16
%26 = shl i32 %14, 16
%27 = ashr exact i32 %26, 16
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %25, i32 %27)
%29 = ashr i32 %15, 16
%30 = shl i32 %15, 16
%31 = ashr exact i32 %30, 16
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i32 %29, i32 %31)
br label %38
33: ; preds = %2
%34 = add nuw nsw i32 %3, 1
%35 = icmp eq i32 %34, 10
br i1 %35, label %36, label %2
36: ; preds = %33
%37 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.8, i64 0, i64 0))
br label %38
38: ; preds = %17, %36
%39 = phi i32 [ 0, %17 ], [ 1, %36 ]
ret i32 %39
}