#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_v8sum(int, int);
int /*<<< orphan*/ printf(char *, ...);
int prog_v8sum(int, int);
int rand();
int MMX_SUM_8b_AUTOTEST() {
  int i, j;
  printf("LAUNCHING THE (MMX_SUM) RESOURCE AUTOTEST...\n");
  for (j = 0; j < 10; j++) {
    int op1 = ((rand() % 65536) << 16) & (rand() % 65536);
    int op2 = ((rand() % 65536) << 16) & (rand() % 65536);
    int op3 = instr_v8sum(op1, op2);
    int op4 = prog_v8sum(op1, op2);
    if (op3 != op4) {
      printf("TEST OF THE MMX_SUM_8b 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. [%d]\n", op3);
      printf("- REF C CODE [%d]\n", op4);
      return 0;
    }
  }
  printf("- TEST OF THE (MMX_SUM) RESOURCE => OK\n");
  return 1;
}


x86 assembly (clang, -O0):
<MMX_SUM_8b_AUTOTEST>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    12c1 <MMX_SUM_8b_AUTOTEST+0x181>
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   1040 <instr_v8sum@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1050 <prog_v8sum@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
je     12ae <MMX_SUM_8b_AUTOTEST+0x16e>
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1030 <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    0xe44(%rip),%rdi
mov    $0x0,%al
call   1030 <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    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12d6 <MMX_SUM_8b_AUTOTEST+0x196>
jmp    12b3 <MMX_SUM_8b_AUTOTEST+0x173>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115d <MMX_SUM_8b_AUTOTEST+0x1d>
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MMX_SUM_8b_AUTOTEST>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xf31(%rip),%rdi
call   1030 <puts@plt>
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%ebp
shl    $0x10,%ebp
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    %ebp,%ebx
xor    %eax,%eax
call   1070 <rand@plt>
mov    %eax,%r15d
shl    $0x10,%r15d
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    %r15d,%ebp
mov    %ebx,%edi
mov    %ebp,%esi
call   1050 <instr_v8sum@plt>
mov    %eax,%r12d
mov    %ebx,%edi
mov    %ebp,%esi
call   1060 <prog_v8sum@plt>
cmp    %eax,%r12d
jne    1200 <MMX_SUM_8b_AUTOTEST+0xb0>
add    $0x1,%r14d
cmp    $0xa,%r14d
jne    1170 <MMX_SUM_8b_AUTOTEST+0x20>
lea    0xed0(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%r13d
jmp    1282 <MMX_SUM_8b_AUTOTEST+0x132>
mov    %eax,%r15d
lea    0xedd(%rip),%rdi
call   1030 <puts@plt>
lea    0xdea(%rip),%rdi
xor    %r13d,%r13d
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%esi
shr    $0x18,%esi
shr    $0x10,%ebx
movzbl %bl,%edx
lea    0xdf0(%rip),%rdi
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%esi
shr    $0x18,%esi
shr    $0x10,%ebp
movzbl %bpl,%edx
lea    0xdf5(%rip),%rdi
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe06(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe08(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13d,%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_SUM) RESOURCE AUTOTEST...\0A\00"
@.str.1 = [45 x i8] c"TEST OF THE MMX_SUM_8b RESOURCE => FAILED !\0A\00"
@.str.2 = [37 x i8] c"- %d COMPUTATION(s) BEFORE ERROR...\0A\00"
@.str.3 = [36 x i8] c"- OPERANDE 1 [%.3d %.3d %.3d %.3d]\0A\00"
@.str.4 = [36 x i8] c"- OPERANDE 2 [%.3d %.3d %.3d %.3d]\0A\00"
@.str.5 = [19 x i8] c"- ASM INSTR. [%d]\0A\00"
@.str.6 = [19 x i8] c"- REF C CODE [%d]\0A\00"
@.str.7 = [40 x i8] c"- TEST OF THE (MMX_SUM) RESOURCE => OK\0A\00"
define i32 @MMX_SUM_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 = %67, %0
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 10
br i1 %11, label %12, label %70
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_v8sum(i32 %25, i32 %26)
store i32 %27, i32* %6
%28 = load i32, i32* %4
%29 = load i32, i32* %5
%30 = call i32 @prog_v8sum(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 %66
34: ; preds = %12
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0))
%36 = load i32, i32* %3
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 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 ([36 x i8], [36 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 ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0), i32 %52, i32 %55, i32 %58, i32 %60)
%62 = load i32, i32* %6
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %62)
%64 = load i32, i32* %7
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i32 %64)
store i32 0, i32* %1
br label %72
66: ; preds = %12
br label %67
67: ; preds = %66
%68 = load i32, i32* %3
%69 = add nsw i32 %68, 1
store i32 %69, i32* %3
br label %9
70: ; preds = %9
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %1
br label %72
72: ; preds = %70, %34
%73 = load i32, i32* %1
ret i32 %73
}

LLVM IR (-O2):
@.str.2 = [37 x i8] c"- %d COMPUTATION(s) BEFORE ERROR...\0A\00"
@.str.3 = [36 x i8] c"- OPERANDE 1 [%.3d %.3d %.3d %.3d]\0A\00"
@.str.4 = [36 x i8] c"- OPERANDE 2 [%.3d %.3d %.3d %.3d]\0A\00"
@.str.5 = [19 x i8] c"- ASM INSTR. [%d]\0A\00"
@.str.6 = [19 x i8] c"- REF C CODE [%d]\0A\00"
@str = [45 x i8] c"LAUNCHING THE (MMX_SUM) RESOURCE AUTOTEST...\00"
@str.8 = [39 x i8] c"- TEST OF THE (MMX_SUM) RESOURCE => OK\00"
@str.9 = [44 x i8] c"TEST OF THE MMX_SUM_8b RESOURCE => FAILED !\00"
define i32 @MMX_SUM_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, %30
%3 = phi i32 [ 0, %0 ], [ %31, %30 ]
%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_v8sum(i32 %8, i32 %13)
%15 = tail call i32 @prog_v8sum(i32 %8, i32 %13)
%16 = icmp eq i32 %14, %15
br i1 %16, label %30, label %17
17: ; preds = %2
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.9, i64 0, i64 0))
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 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 ([36 x i8], [36 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 ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0), i32 %24, i32 %26, i32 0, i32 0)
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %14)
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i32 %15)
br label %35
30: ; preds = %2
%31 = add nuw nsw i32 %3, 1
%32 = icmp eq i32 %31, 10
br i1 %32, label %33, label %2
33: ; preds = %30
%34 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.8, i64 0, i64 0))
br label %35
35: ; preds = %17, %33
%36 = phi i32 [ 0, %17 ], [ 1, %33 ]
ret i32 %36
}