#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 */
float fabs(float);
int /*<<< orphan*/ printf(char *, int, ...);
void printDiff(float data1[2000][2000], float data2[2000][2000], int width,
               int height, int iListLength, float fListTol) {
  printf("Listing first %d.", iListLength);
  printf(" Differences > %.6f...\n", fListTol);
  int i, j;
  int error_count = 0;
  for (j = 0; j < height; j++) {
    for (i = 0; i < width; i++) {
      float fDiff = fabs(data1[i][j] - data2[i][j]);
      if (fDiff > fListTol) {
        if (error_count < iListLength) {
          printf("    Loc(%d,%d)\tCPU=%.5f\tGPU=%.5f\tDiff=%.6f\n", i, j,
                 data1[i][j], data2[i][j], fDiff);
        }
        error_count++;
      }
    }
  }
  printf(" \n  Total Errors = %d of %d\n\n", error_count, 2000 * 2000);
}


x86 assembly (clang, -O0):
<printDiff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
movss  %xmm0,-0x20(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cvttss2si -0x20(%rbp),%esi
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1275 <printDiff+0x155>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1262 <printDiff+0x142>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   $0x1f40,%rcx,%rcx
add    %rcx,%rax
movslq -0x28(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   $0x1f40,%rcx,%rcx
add    %rcx,%rax
movslq -0x28(%rbp),%rcx
subss  (%rax,%rcx,4),%xmm0
call   1040 <fabs@plt>
movss  %xmm0,-0x30(%rbp)
movss  -0x30(%rbp),%xmm0
ucomiss -0x20(%rbp),%xmm0
jbe    124f <printDiff+0x12f>
mov    -0x2c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1246 <printDiff+0x126>
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   $0x1f40,%rcx,%rcx
add    %rcx,%rax
movslq -0x28(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   $0x1f40,%rcx,%rcx
add    %rcx,%rax
movslq -0x28(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x30(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xdeb(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1254 <printDiff+0x134>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1184 <printDiff+0x64>
jmp    1267 <printDiff+0x147>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1171 <printDiff+0x51>
mov    -0x2c(%rbp),%esi
lea    0xdd7(%rip),%rdi
mov    $0x3d0900,%edx
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printDiff>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movss  %xmm0,0x8(%rsp)
mov    %ecx,%r14d
mov    %edx,0xc(%rsp)
mov    %rsi,%r12
mov    %rdi,%rbx
lea    0xed8(%rip),%rdi
xor    %ebp,%ebp
mov    %r8d,0x1c(%rsp)
mov    %r8d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
cvttss2si 0x8(%rsp),%esi
lea    0xecc(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movss  0x8(%rsp),%xmm3
test   %r14d,%r14d
jle    1235 <printDiff+0x125>
mov    %r14d,%eax
mov    %rax,0x20(%rsp)
mov    0xc(%rsp),%eax
imul   $0x1f40,%rax,%r15
xor    %eax,%eax
mov    %rax,0x10(%rsp)
movaps 0xe73(%rip),%xmm4
xor    %ebp,%ebp
jmp    11c0 <printDiff+0xb0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp),%rcx
add    $0x1,%rcx
add    $0x4,%rbx
add    $0x4,%r12
mov    %rcx,%rax
mov    %rcx,0x10(%rsp)
cmp    0x20(%rsp),%rcx
je     1235 <printDiff+0x125>
cmpl   $0x0,0xc(%rsp)
jle    11a0 <printDiff+0x90>
xor    %r13d,%r13d
xor    %r14d,%r14d
jmp    11e3 <printDiff+0xd3>
nop
add    $0x1,%ebp
add    $0x1,%r14d
add    $0x1f40,%r13
cmp    %r13,%r15
je     11a0 <printDiff+0x90>
movss  (%rbx,%r13,1),%xmm0
movss  (%r12,%r13,1),%xmm1
movaps %xmm0,%xmm2
subss  %xmm1,%xmm2
andps  %xmm4,%xmm2
ucomiss %xmm3,%xmm2
jbe    11d3 <printDiff+0xc3>
cmp    0x1c(%rsp),%ebp
jge    11d0 <printDiff+0xc0>
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm1,%xmm1
cvtss2sd %xmm2,%xmm2
lea    0xe23(%rip),%rdi
mov    %r14d,%esi
mov    0x10(%rsp),%rdx
mov    $0x3,%al
call   1030 <printf@plt>
movaps 0xdd3(%rip),%xmm4
movss  0x8(%rsp),%xmm3
jmp    11d0 <printDiff+0xc0>
lea    0xe2a(%rip),%rdi
mov    %ebp,%esi
mov    $0x3d0900,%edx
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"Listing first %d.\00"
@.str.1 = [24 x i8] c" Differences > %.6f...\0A\00"
@.str.2 = [44 x i8] c" Loc(%d,%d)\09CPU=%.5f\09GPU=%.5f\09Diff=%.6f\0A\00"
@.str.3 = [30 x i8] c" \0A Total Errors = %d of %d\0A\0A\00"
define void @printDiff([2000 x float]* %0, [2000 x float]* %1, i32 %2, i32 %3, i32 %4, float %5) {
%7 = alloca [2000 x float]*
%8 = alloca [2000 x float]*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca float
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca float
store [2000 x float]* %0, [2000 x float]** %7
store [2000 x float]* %1, [2000 x float]** %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store float %5, float* %12
%17 = load i32, i32* %11
%18 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = load float, float* %12
%20 = fptosi float %19 to i32
%21 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %20)
store i32 0, i32* %15
store i32 0, i32* %14
br label %22
22: ; preds = %89, %6
%23 = load i32, i32* %14
%24 = load i32, i32* %10
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %92
26: ; preds = %22
store i32 0, i32* %13
br label %27
27: ; preds = %85, %26
%28 = load i32, i32* %13
%29 = load i32, i32* %9
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %88
31: ; preds = %27
%32 = load [2000 x float]*, [2000 x float]** %7
%33 = load i32, i32* %13
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [2000 x float], [2000 x float]* %32, i64 %34
%36 = load i32, i32* %14
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [2000 x float], [2000 x float]* %35, i64 0, i64 %37
%39 = load float, float* %38
%40 = load [2000 x float]*, [2000 x float]** %8
%41 = load i32, i32* %13
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [2000 x float], [2000 x float]* %40, i64 %42
%44 = load i32, i32* %14
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [2000 x float], [2000 x float]* %43, i64 0, i64 %45
%47 = load float, float* %46
%48 = fsub float %39, %47
%49 = call float @fabs(float %48)
store float %49, float* %16
%50 = load float, float* %16
%51 = load float, float* %12
%52 = fcmp ogt float %50, %51
br i1 %52, label %53, label %84
53: ; preds = %31
%54 = load i32, i32* %15
%55 = load i32, i32* %11
%56 = icmp slt i32 %54, %55
br i1 %56, label %57, label %81
57: ; preds = %53
%58 = load i32, i32* %13
%59 = load i32, i32* %14
%60 = load [2000 x float]*, [2000 x float]** %7
%61 = load i32, i32* %13
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [2000 x float], [2000 x float]* %60, i64 %62
%64 = load i32, i32* %14
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [2000 x float], [2000 x float]* %63, i64 0, i64 %65
%67 = load float, float* %66
%68 = fpext float %67 to double
%69 = load [2000 x float]*, [2000 x float]** %8
%70 = load i32, i32* %13
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [2000 x float], [2000 x float]* %69, i64 %71
%73 = load i32, i32* %14
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds [2000 x float], [2000 x float]* %72, i64 0, i64 %74
%76 = load float, float* %75
%77 = fpext float %76 to double
%78 = load float, float* %16
%79 = fpext float %78 to double
%80 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i32 %58, i32 %59, double %68, double %77, double %79)
br label %81
81: ; preds = %57, %53
%82 = load i32, i32* %15
%83 = add nsw i32 %82, 1
store i32 %83, i32* %15
br label %84
84: ; preds = %81, %31
br label %85
85: ; preds = %84
%86 = load i32, i32* %13
%87 = add nsw i32 %86, 1
store i32 %87, i32* %13
br label %27
88: ; preds = %27
br label %89
89: ; preds = %88
%90 = load i32, i32* %14
%91 = add nsw i32 %90, 1
store i32 %91, i32* %14
br label %22
92: ; preds = %22
%93 = load i32, i32* %15
%94 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i32 %93, i32 4000000)
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"Listing first %d.\00"
@.str.1 = [24 x i8] c" Differences > %.6f...\0A\00"
@.str.2 = [44 x i8] c" Loc(%d,%d)\09CPU=%.5f\09GPU=%.5f\09Diff=%.6f\0A\00"
@.str.3 = [30 x i8] c" \0A Total Errors = %d of %d\0A\0A\00"
define void @printDiff([2000 x float]* nocapture %0, [2000 x float]* nocapture %1, i32 %2, i32 %3, i32 %4, float %5) {
%7 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %4)
%8 = fptosi float %5 to i32
%9 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = icmp sgt i32 %3, 0
br i1 %10, label %11, label %48
11: ; preds = %6
%12 = icmp sgt i32 %2, 0
%13 = zext i32 %3 to i64
%14 = zext i32 %2 to i64
br label %15
15: ; preds = %11, %44
%16 = phi i64 [ 0, %11 ], [ %46, %44 ]
%17 = phi i32 [ 0, %11 ], [ %45, %44 ]
br i1 %12, label %18, label %44
18: ; preds = %15
%19 = trunc i64 %16 to i32
br label %20
20: ; preds = %18, %40
%21 = phi i64 [ 0, %18 ], [ %42, %40 ]
%22 = phi i32 [ %17, %18 ], [ %41, %40 ]
%23 = getelementptr inbounds [2000 x float], [2000 x float]* %0, i64 %21, i64 %16
%24 = load float, float* %23
%25 = getelementptr inbounds [2000 x float], [2000 x float]* %1, i64 %21, i64 %16
%26 = load float, float* %25
%27 = fsub float %24, %26
%28 = tail call float @llvm.fabs.f32(float %27)
%29 = fcmp ogt float %28, %5
br i1 %29, label %30, label %40
30: ; preds = %20
%31 = icmp slt i32 %22, %4
br i1 %31, label %32, label %38
32: ; preds = %30
%33 = fpext float %24 to double
%34 = fpext float %26 to double
%35 = fpext float %28 to double
%36 = trunc i64 %21 to i32
%37 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i32 %36, i32 %19, double %33, double %34, double %35)
br label %38
38: ; preds = %32, %30
%39 = add nsw i32 %22, 1
br label %40
40: ; preds = %38, %20
%41 = phi i32 [ %39, %38 ], [ %22, %20 ]
%42 = add nuw nsw i64 %21, 1
%43 = icmp eq i64 %42, %14
br i1 %43, label %44, label %20
44: ; preds = %40, %15
%45 = phi i32 [ %17, %15 ], [ %41, %40 ]
%46 = add nuw nsw i64 %16, 1
%47 = icmp eq i64 %46, %13
br i1 %47, label %48, label %15
48: ; preds = %44, %6
%49 = phi i32 [ 0, %6 ], [ %45, %44 ]
%50 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i32 %49, i32 4000000)
ret void
}