#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_v8sub(int, int);
int /*<<< orphan*/ printf(char *, ...);
int prog_v8sub(int, int);
int rand();
int MMX_SUB_8b_AUTOTEST() {
  printf("LAUNCHING THE (MMX_SUB) RESOURCE AUTOTEST...\n");
  int i, j;
  for (j = 0; j < 10; j++) {
    int op1 = ((rand() % 65536) << 16) & (rand() % 65536);
    int op2 = ((rand() % 65536) << 16) & (rand() % 65536);
    int op3 = instr_v8sub(op1, op2);
    int op4 = prog_v8sub(op1, op2);
    if (op3 != op4) {
      printf("- TEST OF THE (MMX_SUB) RESOURCE => FAILED !\n");
      printf("  + %d COMPUTATION(s) BEFORE ERROR...\n", j);
      printf("  + OPERANDE 1 [%.3d %.3d %.3d %.3d]\n",
             ((op1 & 0xFF000000) >> 24), ((op1 & 0x00FF0000) >> 16),
             ((op1 & 0x0000FF00) >> 8), ((op1 & 0x000000FF)));
      printf("  + OPERANDE 2 [%.3d %.3d %.3d %.3d]\n",
             ((op2 & 0xFF000000) >> 24), ((op2 & 0x00FF0000) >> 16),
             ((op2 & 0x0000FF00) >> 8), ((op2 & 0x000000FF)));
      printf("  + ASM INSTR. [%.3d %.3d %.3d %.3d]\n",
             ((op3 & 0xFF000000) >> 24), ((op3 & 0x00FF0000) >> 16),
             ((op3 & 0x0000FF00) >> 8), ((op3 & 0x000000FF)));
      printf("  + REF C CODE [%.3d %.3d %.3d %.3d]\n",
             ((op4 & 0xFF000000) >> 24), ((op4 & 0x00FF0000) >> 16),
             ((op4 & 0x0000FF00) >> 8), ((op4 & 0x000000FF)));
      return 0;
    }
  }
  printf("- TEST OF THE MMX_SUB_8b RESOURCE => OK\n");
  return 1;
}


x86 assembly (clang, -O0):
<MMX_SUB_8b_AUTOTEST>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    1319 <MMX_SUB_8b_AUTOTEST+0x1d9>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x10000,%ecx
cltd
idiv   %ecx
shl    $0x10,%edx
mov    %edx,-0x24(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x10000,%ecx
cltd
idiv   %ecx
mov    -0x24(%rbp),%eax
and    %edx,%eax
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x10000,%ecx
cltd
idiv   %ecx
shl    $0x10,%edx
mov    %edx,-0x20(%rbp)
mov    $0x0,%al
call   1060 <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   1030 <instr_v8sub@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1050 <prog_v8sub@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
je     1306 <MMX_SUB_8b_AUTOTEST+0x1c6>
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%esi
and    $0xff000000,%esi
shr    $0x18,%esi
mov    -0x10(%rbp),%edx
and    $0xff0000,%edx
sar    $0x10,%edx
mov    -0x10(%rbp),%ecx
and    $0xff00,%ecx
sar    $0x8,%ecx
mov    -0x10(%rbp),%r8d
and    $0xff,%r8d
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%esi
and    $0xff000000,%esi
shr    $0x18,%esi
mov    -0x14(%rbp),%edx
and    $0xff0000,%edx
sar    $0x10,%edx
mov    -0x14(%rbp),%ecx
and    $0xff00,%ecx
sar    $0x8,%ecx
mov    -0x14(%rbp),%r8d
and    $0xff,%r8d
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%esi
and    $0xff000000,%esi
shr    $0x18,%esi
mov    -0x18(%rbp),%edx
and    $0xff0000,%edx
sar    $0x10,%edx
mov    -0x18(%rbp),%ecx
and    $0xff00,%ecx
sar    $0x8,%ecx
mov    -0x18(%rbp),%r8d
and    $0xff,%r8d
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%esi
and    $0xff000000,%esi
shr    $0x18,%esi
mov    -0x1c(%rbp),%edx
and    $0xff0000,%edx
sar    $0x10,%edx
mov    -0x1c(%rbp),%ecx
and    $0xff00,%ecx
sar    $0x8,%ecx
mov    -0x1c(%rbp),%r8d
and    $0xff,%r8d
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    132e <MMX_SUB_8b_AUTOTEST+0x1ee>
jmp    130b <MMX_SUB_8b_AUTOTEST+0x1cb>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115d <MMX_SUB_8b_AUTOTEST+0x1d>
lea    0xdfb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MMX_SUB_8b_AUTOTEST>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xf5d(%rip),%rdi
call   1040 <puts@plt>
xor    %r15d,%r15d
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%ebx
shl    $0x10,%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
and    %ebx,%ebp
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%r14d
shl    $0x10,%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
and    %r14d,%ebx
mov    %ebp,%edi
mov    %ebx,%esi
call   1030 <instr_v8sub@plt>
mov    %eax,%r14d
mov    %ebp,%edi
mov    %ebx,%esi
call   1060 <prog_v8sub@plt>
cmp    %eax,%r14d
jne    1200 <MMX_SUB_8b_AUTOTEST+0xb0>
add    $0x1,%r15d
cmp    $0xa,%r15d
jne    1170 <MMX_SUB_8b_AUTOTEST+0x20>
lea    0xefc(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%r14d
jmp    12b5 <MMX_SUB_8b_AUTOTEST+0x165>
mov    %r14d,%r13d
lea    0xf0a(%rip),%rdi
mov    %eax,%r12d
call   1040 <puts@plt>
lea    0xde7(%rip),%rdi
xor    %r14d,%r14d
mov    %r15d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebp,%esi
shr    $0x18,%esi
shr    $0x10,%ebp
movzbl %bpl,%edx
lea    0xdee(%rip),%rdi
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%esi
shr    $0x18,%esi
shr    $0x10,%ebx
movzbl %bl,%edx
lea    0xdf6(%rip),%rdi
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r13d,%ebx
mov    %r13d,%eax
shr    $0x18,%eax
mov    %r13d,%ecx
shr    $0x10,%ecx
movzbl %cl,%edx
movzbl %bh,%ecx
movzbl %bl,%r8d
lea    0xdf0(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12d,%ebx
mov    %r12d,%eax
shr    $0x18,%eax
mov    %r12d,%ecx
shr    $0x10,%ecx
movzbl %cl,%edx
movzbl %bh,%ecx
movzbl %bl,%r8d
lea    0xded(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [46 x i8] c"LAUNCHING THE (MMX_SUB) RESOURCE AUTOTEST...\0A\00"
@.str.1 = [46 x i8] c"- TEST OF THE (MMX_SUB) RESOURCE => FAILED !\0A\00"
@.str.2 = [39 x i8] c" + %d COMPUTATION(s) BEFORE ERROR...\0A\00"
@.str.3 = [38 x i8] c" + OPERANDE 1 [%.3d %.3d %.3d %.3d]\0A\00"
@.str.4 = [38 x i8] c" + OPERANDE 2 [%.3d %.3d %.3d %.3d]\0A\00"
@.str.5 = [38 x i8] c" + ASM INSTR. [%.3d %.3d %.3d %.3d]\0A\00"
@.str.6 = [38 x i8] c" + REF C CODE [%.3d %.3d %.3d %.3d]\0A\00"
@.str.7 = [41 x i8] c"- TEST OF THE MMX_SUB_8b RESOURCE => OK\0A\00"
define i32 @MMX_SUB_8b_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 ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %9
9: ; preds = %87, %0
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 10
br i1 %11, label %12, label %90
12: ; preds = %9
%13 = call i32 (...) @rand()
%14 = srem i32 %13, 65536
%15 = shl i32 %14, 16
%16 = call i32 (...) @rand()
%17 = srem i32 %16, 65536
%18 = and i32 %15, %17
store i32 %18, i32* %4
%19 = call i32 (...) @rand()
%20 = srem i32 %19, 65536
%21 = shl i32 %20, 16
%22 = call i32 (...) @rand()
%23 = srem i32 %22, 65536
%24 = and i32 %21, %23
store i32 %24, i32* %5
%25 = load i32, i32* %4
%26 = load i32, i32* %5
%27 = call i32 @instr_v8sub(i32 %25, i32 %26)
store i32 %27, i32* %6
%28 = load i32, i32* %4
%29 = load i32, i32* %5
%30 = call i32 @prog_v8sub(i32 %28, i32 %29)
store i32 %30, i32* %7
%31 = load i32, i32* %6
%32 = load i32, i32* %7
%33 = icmp ne i32 %31, %32
br i1 %33, label %34, label %86
34: ; preds = %12
%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 ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %36)
%38 = load i32, i32* %4
%39 = and i32 %38, -16777216
%40 = lshr i32 %39, 24
%41 = load i32, i32* %4
%42 = and i32 %41, 16711680
%43 = ashr i32 %42, 16
%44 = load i32, i32* %4
%45 = and i32 %44, 65280
%46 = ashr i32 %45, 8
%47 = load i32, i32* %4
%48 = and i32 %47, 255
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %40, i32 %43, i32 %46, i32 %48)
%50 = load i32, i32* %5
%51 = and i32 %50, -16777216
%52 = lshr i32 %51, 24
%53 = load i32, i32* %5
%54 = and i32 %53, 16711680
%55 = ashr i32 %54, 16
%56 = load i32, i32* %5
%57 = and i32 %56, 65280
%58 = ashr i32 %57, 8
%59 = load i32, i32* %5
%60 = and i32 %59, 255
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0), i32 %52, i32 %55, i32 %58, i32 %60)
%62 = load i32, i32* %6
%63 = and i32 %62, -16777216
%64 = lshr i32 %63, 24
%65 = load i32, i32* %6
%66 = and i32 %65, 16711680
%67 = ashr i32 %66, 16
%68 = load i32, i32* %6
%69 = and i32 %68, 65280
%70 = ashr i32 %69, 8
%71 = load i32, i32* %6
%72 = and i32 %71, 255
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), i32 %64, i32 %67, i32 %70, i32 %72)
%74 = load i32, i32* %7
%75 = and i32 %74, -16777216
%76 = lshr i32 %75, 24
%77 = load i32, i32* %7
%78 = and i32 %77, 16711680
%79 = ashr i32 %78, 16
%80 = load i32, i32* %7
%81 = and i32 %80, 65280
%82 = ashr i32 %81, 8
%83 = load i32, i32* %7
%84 = and i32 %83, 255
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0), i32 %76, i32 %79, i32 %82, i32 %84)
store i32 0, i32* %1
br label %92
86: ; preds = %12
br label %87
87: ; preds = %86
%88 = load i32, i32* %3
%89 = add nsw i32 %88, 1
store i32 %89, i32* %3
br label %9
90: ; preds = %9
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %1
br label %92
92: ; preds = %90, %34
%93 = load i32, i32* %1
ret i32 %93
}

LLVM IR (-O2):
@.str.2 = [39 x i8] c" + %d COMPUTATION(s) BEFORE ERROR...\0A\00"
@.str.3 = [38 x i8] c" + OPERANDE 1 [%.3d %.3d %.3d %.3d]\0A\00"
@.str.4 = [38 x i8] c" + OPERANDE 2 [%.3d %.3d %.3d %.3d]\0A\00"
@.str.5 = [38 x i8] c" + ASM INSTR. [%.3d %.3d %.3d %.3d]\0A\00"
@.str.6 = [38 x i8] c" + REF C CODE [%.3d %.3d %.3d %.3d]\0A\00"
@str = [45 x i8] c"LAUNCHING THE (MMX_SUB) RESOURCE AUTOTEST...\00"
@str.8 = [40 x i8] c"- TEST OF THE MMX_SUB_8b RESOURCE => OK\00"
@str.9 = [45 x i8] c"- TEST OF THE (MMX_SUB) RESOURCE => FAILED !\00"
define i32 @MMX_SUB_8b_AUTOTEST() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str, i64 0, i64 0))
br label %2
2: ; preds = %0, %42
%3 = phi i32 [ 0, %0 ], [ %43, %42 ]
%4 = tail call i32 (...) @rand()
%5 = shl i32 %4, 16
%6 = tail call i32 (...) @rand()
%7 = srem i32 %6, 65536
%8 = and i32 %7, %5
%9 = tail call i32 (...) @rand()
%10 = shl i32 %9, 16
%11 = tail call i32 (...) @rand()
%12 = srem i32 %11, 65536
%13 = and i32 %12, %10
%14 = tail call i32 @instr_v8sub(i32 %8, i32 %13)
%15 = tail call i32 @prog_v8sub(i32 %8, i32 %13)
%16 = icmp eq i32 %14, %15
br i1 %16, label %42, label %17
17: ; preds = %2
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 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 = lshr i32 %8, 24
%21 = lshr exact i32 %8, 16
%22 = and i32 %21, 255
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %20, i32 %22, i32 0, i32 0)
%24 = lshr i32 %13, 24
%25 = lshr exact i32 %13, 16
%26 = and i32 %25, 255
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0), i32 %24, i32 %26, i32 0, i32 0)
%28 = lshr i32 %14, 24
%29 = lshr i32 %14, 16
%30 = and i32 %29, 255
%31 = lshr i32 %14, 8
%32 = and i32 %31, 255
%33 = and i32 %14, 255
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), i32 %28, i32 %30, i32 %32, i32 %33)
%35 = lshr i32 %15, 24
%36 = lshr i32 %15, 16
%37 = and i32 %36, 255
%38 = lshr i32 %15, 8
%39 = and i32 %38, 255
%40 = and i32 %15, 255
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0), i32 %35, i32 %37, i32 %39, i32 %40)
br label %47
42: ; preds = %2
%43 = add nuw nsw i32 %3, 1
%44 = icmp eq i32 %43, 10
br i1 %44, label %45, label %2
45: ; preds = %42
%46 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.8, i64 0, i64 0))
br label %47
47: ; preds = %17, %45
%48 = phi i32 [ 0, %17 ], [ 1, %45 ]
ret i32 %48
}