#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 fabs(float);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int Check(float *a_host, float *a_ref, int hA, int wA) {
  bool passed = true;
  int i, j;
  for (i = 0; i < hA; ++i) {
    for (j = 0; j < wA; ++j) {
      if (fabs(a_host[i * wA + j] - a_ref[i * wA + j]) > 1e-5) {
        passed = false;
        break;
      }
    }
  }
  if (passed) {
    fprintf(stderr, "Passed!\n");
  } else {
    fprintf(stderr, "Failed!\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<Check>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11dc <Check+0xbc>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11c9 <Check+0xa9>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%ecx
imul   -0x18(%rbp),%ecx
add    -0x24(%rbp),%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
imul   -0x18(%rbp),%ecx
add    -0x24(%rbp),%ecx
movslq %ecx,%rcx
subss  (%rax,%rcx,4),%xmm0
call   1030 <fabs@plt>
cvtsi2sd %eax,%xmm0
movsd  0xe60(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11b6 <Check+0x96>
movl   $0x0,-0x1c(%rbp)
jmp    11c9 <Check+0xa9>
jmp    11bb <Check+0x9b>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1157 <Check+0x37>
jmp    11ce <Check+0xae>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1144 <Check+0x24>
cmpl   $0x0,-0x1c(%rbp)
je     1200 <Check+0xe0>
mov    0x2df3(%rip),%rax
mov    (%rax),%edi
lea    0xe12(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1215 <Check+0xf5>
mov    0x2dd9(%rip),%rax
mov    (%rax),%edi
lea    0xe01(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Check>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %edx,%edx
jle    11da <Check+0xba>
mov    %ecx,%r15d
mov    %rsi,%rbx
mov    %rdi,%rbp
movslq %ecx,%rax
mov    %edx,%edx
mov    %rdx,0x8(%rsp)
mov    %eax,%r13d
shl    $0x2,%rax
mov    %rax,0x10(%rsp)
movl   $0x1,0x4(%rsp)
xor    %r14d,%r14d
jmp    118e <Check+0x6e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movl   $0x0,0x4(%rsp)
add    $0x1,%r14
mov    0x10(%rsp),%rax
add    %rax,%rbp
add    %rax,%rbx
cmp    0x8(%rsp),%r14
je     11c1 <Check+0xa1>
test   %r15d,%r15d
jle    1178 <Check+0x58>
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
movss  0x0(%rbp,%r12,4),%xmm0
subss  (%rbx,%r12,4),%xmm0
call   1030 <fabs@plt>
test   %eax,%eax
jg     1170 <Check+0x50>
add    $0x1,%r12
cmp    %r12,%r13
jne    11a0 <Check+0x80>
jmp    1178 <Check+0x58>
cmpl   $0x0,0x4(%rsp)
lea    0xe3c(%rip),%rax
lea    0xe2c(%rip),%rsi
cmove  %rax,%rsi
jmp    11e1 <Check+0xc1>
lea    0xe1f(%rip),%rsi
mov    0x2df8(%rip),%rax
mov    (%rax),%edi
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [9 x i8] c"Passed!\0A\00"
@.str.1 = [9 x i8] c"Failed!\0A\00"
define i32 @Check(float* %0, float* %1, i32 %2, i32 %3) {
%5 = alloca float*
%6 = alloca float*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store float* %0, float** %5
store float* %1, float** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 1, i32* %9
store i32 0, i32* %10
br label %12
12: ; preds = %50, %4
%13 = load i32, i32* %10
%14 = load i32, i32* %7
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %53
16: ; preds = %12
store i32 0, i32* %11
br label %17
17: ; preds = %46, %16
%18 = load i32, i32* %11
%19 = load i32, i32* %8
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %49
21: ; preds = %17
%22 = load float*, float** %5
%23 = load i32, i32* %10
%24 = load i32, i32* %8
%25 = mul nsw i32 %23, %24
%26 = load i32, i32* %11
%27 = add nsw i32 %25, %26
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds float, float* %22, i64 %28
%30 = load float, float* %29
%31 = load float*, float** %6
%32 = load i32, i32* %10
%33 = load i32, i32* %8
%34 = mul nsw i32 %32, %33
%35 = load i32, i32* %11
%36 = add nsw i32 %34, %35
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds float, float* %31, i64 %37
%39 = load float, float* %38
%40 = fsub float %30, %39
%41 = call i32 @fabs(float %40)
%42 = sitofp i32 %41 to double
%43 = fcmp ogt double %42, 1.000000e-05
br i1 %43, label %44, label %45
44: ; preds = %21
store i32 0, i32* %9
br label %49
45: ; preds = %21
br label %46
46: ; preds = %45
%47 = load i32, i32* %11
%48 = add nsw i32 %47, 1
store i32 %48, i32* %11
br label %17
49: ; preds = %44, %17
br label %50
50: ; preds = %49
%51 = load i32, i32* %10
%52 = add nsw i32 %51, 1
store i32 %52, i32* %10
br label %12
53: ; preds = %12
%54 = load i32, i32* %9
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %59
56: ; preds = %53
%57 = load i32, i32* @stderr
%58 = call i32 @fprintf(i32 %57, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
br label %62
59: ; preds = %53
%60 = load i32, i32* @stderr
%61 = call i32 @fprintf(i32 %60, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %62
62: ; preds = %59, %56
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [9 x i8] c"Passed!\0A\00"
@.str.1 = [9 x i8] c"Failed!\0A\00"
define i32 @Check(float* nocapture %0, float* nocapture %1, i32 %2, i32 %3) {
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %35
6: ; preds = %4
%7 = icmp sgt i32 %3, 0
%8 = sext i32 %3 to i64
%9 = zext i32 %2 to i64
%10 = zext i32 %3 to i64
br label %11
11: ; preds = %6, %28
%12 = phi i64 [ 0, %6 ], [ %30, %28 ]
%13 = phi i32 [ 1, %6 ], [ %29, %28 ]
%14 = mul nsw i64 %12, %8
br i1 %7, label %17, label %28
15: ; preds = %17
%16 = icmp eq i64 %27, %10
br i1 %16, label %28, label %17
17: ; preds = %11, %15
%18 = phi i64 [ %27, %15 ], [ 0, %11 ]
%19 = add nsw i64 %18, %14
%20 = getelementptr inbounds float, float* %0, i64 %19
%21 = load float, float* %20
%22 = getelementptr inbounds float, float* %1, i64 %19
%23 = load float, float* %22
%24 = fsub float %21, %23
%25 = tail call i32 @fabs(float %24)
%26 = icmp sgt i32 %25, 0
%27 = add nuw nsw i64 %18, 1
br i1 %26, label %28, label %15
28: ; preds = %15, %17, %11
%29 = phi i32 [ %13, %11 ], [ 0, %17 ], [ %13, %15 ]
%30 = add nuw nsw i64 %12, 1
%31 = icmp eq i64 %30, %9
br i1 %31, label %32, label %11
32: ; preds = %28
%33 = icmp eq i32 %29, 0
%34 = select i1 %33, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0)
br label %35
35: ; preds = %32, %4
%36 = phi i8* [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), %4 ], [ %34, %32 ]
%37 = load i32, i32* @stderr
%38 = tail call i32 @fprintf(i32 %37, i8* %36)
ret i32 0
}