; LLVM IR from osmart/hole2 :: src/retired_routines (surface)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@dots = external dso_local global [30000 x [7 x double]], align 16
@in_dots = external dso_local global [30000 x [7 x double]], align 16

; Function Attrs: nounwind uwtable
define dso_local i32 @vec_compare(i32 noundef %0, i32 noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  %6 = load i32, ptr %4, align 4, !tbaa !5
  %7 = sext i32 %6 to i64
  %8 = getelementptr inbounds [30000 x [7 x double]], ptr @in_dots, i64 0, i64 %7
  %9 = getelementptr inbounds [7 x double], ptr %8, i64 0, i64 0
  %10 = load double, ptr %9, align 8, !tbaa !9
  %11 = load i32, ptr %5, align 4, !tbaa !5
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds [30000 x [7 x double]], ptr @dots, i64 0, i64 %12
  %14 = getelementptr inbounds [7 x double], ptr %13, i64 0, i64 0
  %15 = load double, ptr %14, align 8, !tbaa !9
  %16 = fsub double %10, %15
  %17 = call double @llvm.fabs.f64(double %16)
  %18 = fcmp olt double %17, 1.000000e-03
  br i1 %18, label %19, label %48

19:                                               ; preds = %2
  %20 = load i32, ptr %4, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [30000 x [7 x double]], ptr @in_dots, i64 0, i64 %21
  %23 = getelementptr inbounds [7 x double], ptr %22, i64 0, i64 1
  %24 = load double, ptr %23, align 8, !tbaa !9
  %25 = load i32, ptr %5, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [30000 x [7 x double]], ptr @dots, i64 0, i64 %26
  %28 = getelementptr inbounds [7 x double], ptr %27, i64 0, i64 1
  %29 = load double, ptr %28, align 8, !tbaa !9
  %30 = fsub double %24, %29
  %31 = call double @llvm.fabs.f64(double %30)
  %32 = fcmp olt double %31, 1.000000e-03
  br i1 %32, label %33, label %48

33:                                               ; preds = %19
  %34 = load i32, ptr %4, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [30000 x [7 x double]], ptr @in_dots, i64 0, i64 %35
  %37 = getelementptr inbounds [7 x double], ptr %36, i64 0, i64 2
  %38 = load double, ptr %37, align 8, !tbaa !9
  %39 = load i32, ptr %5, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [30000 x [7 x double]], ptr @dots, i64 0, i64 %40
  %42 = getelementptr inbounds [7 x double], ptr %41, i64 0, i64 2
  %43 = load double, ptr %42, align 8, !tbaa !9
  %44 = fsub double %38, %43
  %45 = call double @llvm.fabs.f64(double %44)
  %46 = fcmp olt double %45, 1.000000e-03
  br i1 %46, label %47, label %48

47:                                               ; preds = %33
  store i32 1, ptr %3, align 4
  br label %49

48:                                               ; preds = %33, %19, %2
  store i32 0, ptr %3, align 4
  br label %49

49:                                               ; preds = %48, %47
  %50 = load i32, ptr %3, align 4
  ret i32 %50
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #1

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@dots = external dso_local local_unnamed_addr global [30000 x [7 x double]], align 16
@in_dots = external dso_local local_unnamed_addr global [30000 x [7 x double]], align 16

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: none) uwtable
define dso_local range(i32 0, 2) i32 @vec_compare(i32 noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = sext i32 %0 to i64
  %4 = getelementptr inbounds [30000 x [7 x double]], ptr @in_dots, i64 0, i64 %3
  %5 = load double, ptr %4, align 8, !tbaa !5
  %6 = sext i32 %1 to i64
  %7 = getelementptr inbounds [30000 x [7 x double]], ptr @dots, i64 0, i64 %6
  %8 = load double, ptr %7, align 8, !tbaa !5
  %9 = fsub double %5, %8
  %10 = tail call double @llvm.fabs.f64(double %9)
  %11 = fcmp olt double %10, 1.000000e-03
  br i1 %11, label %12, label %28

12:                                               ; preds = %2
  %13 = getelementptr inbounds i8, ptr %4, i64 8
  %14 = load double, ptr %13, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %7, i64 8
  %16 = load double, ptr %15, align 8, !tbaa !5
  %17 = fsub double %14, %16
  %18 = tail call double @llvm.fabs.f64(double %17)
  %19 = fcmp olt double %18, 1.000000e-03
  br i1 %19, label %20, label %28

20:                                               ; preds = %12
  %21 = getelementptr inbounds i8, ptr %4, i64 16
  %22 = load double, ptr %21, align 8, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %7, i64 16
  %24 = load double, ptr %23, align 8, !tbaa !5
  %25 = fsub double %22, %24
  %26 = tail call double @llvm.fabs.f64(double %25)
  %27 = fcmp olt double %26, 1.000000e-03
  br i1 %27, label %29, label %28

28:                                               ; preds = %20, %12, %2
  br label %29

29:                                               ; preds = %20, %28
  %.0 = phi i32 [ 0, %28 ], [ 1, %20 ]
  ret i32 %.0
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #1

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass