#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_q168fcsel(int, int);
int /*<<< orphan*/ printf(char *, ...);
int prog_q168fcsel(int, int);
int rand();
int Q16_8_FullCondSelect_AUTOTEST() {
  printf("LAUNCHING THE (Q16_8_FullCondSelect) RESOURCE AUTOTEST...\n");
  int i, j;
  for (j = 0; j < 10; j++) {
    int op1 = (rand() % 65536) - 32768;
    int op2 = ((rand() % 65536) << 16) & (rand() % 65536);
    int op3 = instr_q168fcsel(op1, op2);
    int op4 = prog_q168fcsel(op1, op2);
    if (op3 != op4) {
      printf("- TEST OF THE (Q16_8_FullCondSelect) 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_FullCondSelect) RESOURCE => OK\n");
  return 1;
}


x86 assembly (clang, -O0):
<Q16_8_FullCondSelect_AUTOTEST>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    1279 <Q16_8_FullCondSelect_AUTOTEST+0x139>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x10000,%ecx
cltd
idiv   %ecx
sub    $0x8000,%edx
mov    %edx,-0x10(%rbp)
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x10000,%ecx
cltd
idiv   %ecx
shl    $0x10,%edx
mov    %edx,-0x20(%rbp)
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x10000,%ecx
cltd
idiv   %ecx
mov    -0x20(%rbp),%eax
and    %edx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1060 <instr_q168fcsel@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1040 <prog_q168fcsel@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
je     1266 <Q16_8_FullCondSelect_AUTOTEST+0x126>
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
sar    $0x10,%eax
movswl %ax,%esi
mov    -0x14(%rbp),%eax
movswl %ax,%edx
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
sar    $0x10,%eax
movswl %ax,%esi
mov    -0x18(%rbp),%eax
movswl %ax,%edx
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
sar    $0x10,%eax
movswl %ax,%esi
mov    -0x1c(%rbp),%eax
movswl %ax,%edx
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    128e <Q16_8_FullCondSelect_AUTOTEST+0x14e>
jmp    126b <Q16_8_FullCondSelect_AUTOTEST+0x12b>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115d <Q16_8_FullCondSelect_AUTOTEST+0x1d>
lea    0xe7d(%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):
<Q16_8_FullCondSelect_AUTOTEST>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xf25(%rip),%rdi
call   1030 <puts@plt>
xor    %r15d,%r15d
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <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   1060 <rand@plt>
mov    %eax,%ebx
shl    $0x10,%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
and    %ebx,%ebp
mov    %r14d,%edi
mov    %ebp,%esi
call   1070 <instr_q168fcsel@plt>
mov    %eax,%r13d
mov    %r14d,%edi
mov    %ebp,%esi
call   1050 <prog_q168fcsel@plt>
cmp    %eax,%r13d
jne    11f7 <Q16_8_FullCondSelect_AUTOTEST+0xa7>
add    $0x1,%r15d
cmp    $0xa,%r15d
jne    1170 <Q16_8_FullCondSelect_AUTOTEST+0x20>
lea    0xed6(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
jmp    126f <Q16_8_FullCondSelect_AUTOTEST+0x11f>
mov    %eax,%r12d
lea    0xef4(%rip),%rdi
call   1030 <puts@plt>
lea    0xdf3(%rip),%rdi
xor    %ebx,%ebx
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe07(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
sar    $0x10,%ebp
lea    0xe08(%rip),%rdi
mov    %ebp,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13d,%esi
sar    $0x10,%esi
movswl %r13w,%edx
lea    0xe05(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12d,%esi
sar    $0x10,%esi
movswl %r12w,%edx
lea    0xe06(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [59 x i8] c"LAUNCHING THE (Q16_8_FullCondSelect) RESOURCE AUTOTEST...\0A\00"
@.str.1 = [59 x i8] c"- TEST OF THE (Q16_8_FullCondSelect) 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 = [53 x i8] c"- TEST OF THE (Q16_8_FullCondSelect) RESOURCE => OK\0A\00"
define i32 @Q16_8_FullCondSelect_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 ([59 x i8], [59 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %9
9: ; preds = %62, %0
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 10
br i1 %11, label %12, label %65
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 = shl i32 %17, 16
%19 = call i32 (...) @rand()
%20 = srem i32 %19, 65536
%21 = and i32 %18, %20
store i32 %21, i32* %5
%22 = load i32, i32* %4
%23 = load i32, i32* %5
%24 = call i32 @instr_q168fcsel(i32 %22, i32 %23)
store i32 %24, i32* %6
%25 = load i32, i32* %4
%26 = load i32, i32* %5
%27 = call i32 @prog_q168fcsel(i32 %25, i32 %26)
store i32 %27, i32* %7
%28 = load i32, i32* %6
%29 = load i32, i32* %7
%30 = icmp ne i32 %28, %29
br i1 %30, label %31, label %61
31: ; preds = %12
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.1, i64 0, i64 0))
%33 = load i32, i32* %3
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %33)
%35 = load i32, i32* %4
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %35)
%37 = load i32, i32* %5
%38 = ashr i32 %37, 16
%39 = trunc i32 %38 to i16
%40 = sext i16 %39 to i32
%41 = load i32, i32* %5
%42 = trunc i32 %41 to i16
%43 = sext i16 %42 to i32
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %40, i32 %43)
%45 = load i32, i32* %6
%46 = ashr i32 %45, 16
%47 = trunc i32 %46 to i16
%48 = sext i16 %47 to i32
%49 = load i32, i32* %6
%50 = trunc i32 %49 to i16
%51 = sext i16 %50 to i32
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %48, i32 %51)
%53 = load i32, i32* %7
%54 = ashr i32 %53, 16
%55 = trunc i32 %54 to i16
%56 = sext i16 %55 to i32
%57 = load i32, i32* %7
%58 = trunc i32 %57 to i16
%59 = sext i16 %58 to i32
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i32 %56, i32 %59)
store i32 0, i32* %1
br label %67
61: ; preds = %12
br label %62
62: ; preds = %61
%63 = load i32, i32* %3
%64 = add nsw i32 %63, 1
store i32 %64, i32* %3
br label %9
65: ; preds = %9
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %1
br label %67
67: ; preds = %65, %31
%68 = load i32, i32* %1
ret i32 %68
}

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 = [58 x i8] c"LAUNCHING THE (Q16_8_FullCondSelect) RESOURCE AUTOTEST...\00"
@str.8 = [52 x i8] c"- TEST OF THE (Q16_8_FullCondSelect) RESOURCE => OK\00"
@str.9 = [58 x i8] c"- TEST OF THE (Q16_8_FullCondSelect) RESOURCE => FAILED !\00"
define i32 @Q16_8_FullCondSelect_AUTOTEST() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @str, i64 0, i64 0))
br label %2
2: ; preds = %0, %29
%3 = phi i32 [ 0, %0 ], [ %30, %29 ]
%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 = tail call i32 (...) @rand()
%10 = srem i32 %9, 65536
%11 = and i32 %10, %8
%12 = tail call i32 @instr_q168fcsel(i32 %6, i32 %11)
%13 = tail call i32 @prog_q168fcsel(i32 %6, i32 %11)
%14 = icmp eq i32 %12, %13
br i1 %14, label %29, label %15
15: ; preds = %2
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @str.9, i64 0, i64 0))
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %3)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %6)
%19 = ashr exact i32 %11, 16
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %19, i32 0)
%21 = ashr i32 %12, 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.5, i64 0, i64 0), i32 %21, i32 %23)
%25 = ashr i32 %13, 16
%26 = shl i32 %13, 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.6, i64 0, i64 0), i32 %25, i32 %27)
br label %34
29: ; preds = %2
%30 = add nuw nsw i32 %3, 1
%31 = icmp eq i32 %30, 10
br i1 %31, label %32, label %2
32: ; preds = %29
%33 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str.8, i64 0, i64 0))
br label %34
34: ; preds = %15, %32
%35 = phi i32 [ 0, %15 ], [ 1, %32 ]
ret i32 %35
}