#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 Verify(float *a_host, float *b_host, float *c_host, int num_elem) {
  bool passed = true;
  for (int i = 0; i < num_elem; ++i) {
    if (fabs(a_host[i] + b_host[i] - c_host[i]) > 1e-5) {
      passed = false;
      break;
    }
  }
  if (passed) {
    fprintf(stderr, "Passed!\n");
  } else {
    fprintf(stderr, "Failed!\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<Verify>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11b2 <Verify+0x92>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
addss  (%rax,%rcx,4),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
subss  (%rax,%rcx,4),%xmm0
call   1030 <fabs@plt>
cvtsi2sd %eax,%xmm0
movsd  0xe77(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    119f <Verify+0x7f>
movl   $0x0,-0x20(%rbp)
jmp    11b2 <Verify+0x92>
jmp    11a4 <Verify+0x84>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1145 <Verify+0x25>
cmpl   $0x0,-0x20(%rbp)
je     11d6 <Verify+0xb6>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
lea    0xe3c(%rip),%rsi
call   1040 <fprintf@plt>
jmp    11eb <Verify+0xcb>
mov    0x2e03(%rip),%rax
mov    (%rax),%edi
lea    0xe2b(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Verify>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xece(%rip),%r14
test   %ecx,%ecx
jle    117e <Verify+0x5e>
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r13
mov    %ecx,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movss  0x0(%r13,%rbp,4),%xmm0
addss  (%r12,%rbp,4),%xmm0
subss  (%r15,%rbp,4),%xmm0
call   1030 <fabs@plt>
test   %eax,%eax
jg     1177 <Verify+0x57>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1150 <Verify+0x30>
jmp    117e <Verify+0x5e>
lea    0xe8b(%rip),%r14
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
mov    %r14,%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x8,%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 @Verify(float* %0, float* %1, float* %2, i32 %3) {
%5 = alloca float*
%6 = alloca float*
%7 = alloca float*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store float* %0, float** %5
store float* %1, float** %6
store float* %2, float** %7
store i32 %3, i32* %8
store i32 1, i32* %9
store i32 0, i32* %10
br label %11
11: ; preds = %38, %4
%12 = load i32, i32* %10
%13 = load i32, i32* %8
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %41
15: ; preds = %11
%16 = load float*, float** %5
%17 = load i32, i32* %10
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds float, float* %16, i64 %18
%20 = load float, float* %19
%21 = load float*, float** %6
%22 = load i32, i32* %10
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds float, float* %21, i64 %23
%25 = load float, float* %24
%26 = fadd float %20, %25
%27 = load float*, float** %7
%28 = load i32, i32* %10
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds float, float* %27, i64 %29
%31 = load float, float* %30
%32 = fsub float %26, %31
%33 = call i32 @fabs(float %32)
%34 = sitofp i32 %33 to double
%35 = fcmp ogt double %34, 1.000000e-05
br i1 %35, label %36, label %37
36: ; preds = %15
store i32 0, i32* %9
br label %41
37: ; preds = %15
br label %38
38: ; preds = %37
%39 = load i32, i32* %10
%40 = add nsw i32 %39, 1
store i32 %40, i32* %10
br label %11
41: ; preds = %36, %11
%42 = load i32, i32* %9
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %41
%45 = load i32, i32* @stderr
%46 = call i32 @fprintf(i32 %45, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
br label %50
47: ; preds = %41
%48 = load i32, i32* @stderr
%49 = call i32 @fprintf(i32 %48, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %50
50: ; preds = %47, %44
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 @Verify(float* nocapture %0, float* nocapture %1, float* nocapture %2, i32 %3) {
%5 = icmp sgt i32 %3, 0
br i1 %5, label %6, label %23
6: ; preds = %4
%7 = zext i32 %3 to i64
br label %10
8: ; preds = %10
%9 = icmp eq i64 %22, %7
br i1 %9, label %23, label %10
10: ; preds = %6, %8
%11 = phi i64 [ 0, %6 ], [ %22, %8 ]
%12 = getelementptr inbounds float, float* %0, i64 %11
%13 = load float, float* %12
%14 = getelementptr inbounds float, float* %1, i64 %11
%15 = load float, float* %14
%16 = fadd float %13, %15
%17 = getelementptr inbounds float, float* %2, i64 %11
%18 = load float, float* %17
%19 = fsub float %16, %18
%20 = tail call i32 @fabs(float %19)
%21 = icmp sgt i32 %20, 0
%22 = add nuw nsw i64 %11, 1
br i1 %21, label %23, label %8
23: ; preds = %10, %8, %4
%24 = phi i8* [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), %4 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), %8 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), %10 ]
%25 = load i32, i32* @stderr
%26 = tail call i32 @fprintf(i32 %25, i8* %24)
ret i32 0
}