; LLVM IR from ox-vgg/vise :: src/search_engine/relja_retrival/external/KMCode_relja/stats (stats)

; 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"

%class.GaussMixture = type { ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i32, float, float, float, i32 }

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #1

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef float @_ZN12GaussMixture9distMahalEPfi(ptr noundef nonnull align 8 dereferenceable(88), ptr noundef, i32 noundef) #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef float @_ZN12GaussMixture9distMahalEPf(ptr noundef nonnull align 8 dereferenceable(88) %0, ptr noundef %1) #3 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca float, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %9 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %10 = getelementptr inbounds %class.GaussMixture, ptr %9, i32 0, i32 5
  %11 = load i32, ptr %10, align 8, !tbaa !9
  %12 = sext i32 %11 to i64
  %13 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %12, i64 4)
  %14 = extractvalue { i64, i1 } %13, 1
  %15 = extractvalue { i64, i1 } %13, 0
  %16 = select i1 %14, i64 -1, i64 %15
  %17 = call noalias noundef nonnull ptr @_Znam(i64 noundef %16) #5
  store ptr %17, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !13
  br label %18

18:                                               ; preds = %32, %2
  %19 = load i32, ptr %6, align 4, !tbaa !13
  %20 = getelementptr inbounds %class.GaussMixture, ptr %9, i32 0, i32 5
  %21 = load i32, ptr %20, align 8, !tbaa !9
  %22 = icmp slt i32 %19, %21
  br i1 %22, label %24, label %23

23:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %35

24:                                               ; preds = %18
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = load i32, ptr %6, align 4, !tbaa !13
  %27 = call noundef float @_ZN12GaussMixture9distMahalEPfi(ptr noundef nonnull align 8 dereferenceable(88) %9, ptr noundef %25, i32 noundef %26)
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = load i32, ptr %6, align 4, !tbaa !13
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds float, ptr %28, i64 %30
  store float %27, ptr %31, align 4, !tbaa !14
  br label %32

32:                                               ; preds = %24
  %33 = load i32, ptr %6, align 4, !tbaa !13
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %6, align 4, !tbaa !13
  br label %18, !llvm.loop !15

35:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store float 1.000000e+04, ptr %7, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !13
  br label %36

36:                                               ; preds = %59, %35
  %37 = load i32, ptr %8, align 4, !tbaa !13
  %38 = getelementptr inbounds %class.GaussMixture, ptr %9, i32 0, i32 5
  %39 = load i32, ptr %38, align 8, !tbaa !9
  %40 = icmp slt i32 %37, %39
  br i1 %40, label %42, label %41

41:                                               ; preds = %36
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %62

42:                                               ; preds = %36
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = load i32, ptr %8, align 4, !tbaa !13
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds float, ptr %43, i64 %45
  %47 = load float, ptr %46, align 4, !tbaa !14
  %48 = load float, ptr %7, align 4, !tbaa !14
  %49 = fcmp olt float %47, %48
  br i1 %49, label %50, label %58

50:                                               ; preds = %42
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = load i32, ptr %8, align 4, !tbaa !13
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds float, ptr %51, i64 %53
  %55 = load float, ptr %54, align 4, !tbaa !14
  store float %55, ptr %7, align 4, !tbaa !14
  %56 = load i32, ptr %8, align 4, !tbaa !13
  %57 = getelementptr inbounds %class.GaussMixture, ptr %9, i32 0, i32 16
  store i32 %56, ptr %57, align 4, !tbaa !17
  br label %58

58:                                               ; preds = %50, %42
  br label %59

59:                                               ; preds = %58
  %60 = load i32, ptr %8, align 4, !tbaa !13
  %61 = add nsw i32 %60, 1
  store i32 %61, ptr %8, align 4, !tbaa !13
  br label %36, !llvm.loop !18

62:                                               ; preds = %41
  %63 = load float, ptr %7, align 4, !tbaa !14
  %64 = getelementptr inbounds %class.GaussMixture, ptr %9, i32 0, i32 14
  store float %63, ptr %64, align 4, !tbaa !19
  %65 = load float, ptr %7, align 4, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret float %65
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { nobuiltin allocsize(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 #3 = { mustprogress 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 #4 = { nounwind }
attributes #5 = { builtin allocsize(0) }

!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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 40}
!10 = !{!"_ZTS12GaussMixture", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !11, i64 40, !11, i64 44, !11, i64 48, !11, i64 52, !11, i64 56, !11, i64 60, !11, i64 64, !11, i64 68, !12, i64 72, !12, i64 76, !12, i64 80, !11, i64 84}
!11 = !{!"int", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!11, !11, i64 0}
!14 = !{!12, !12, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!10, !11, i64 84}
!18 = distinct !{!18, !16}
!19 = !{!10, !12, i64 76}


; 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"

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef float @_ZN12GaussMixture9distMahalEPfi(ptr noundef nonnull align 8 dereferenceable(88), ptr noundef, i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef float @_ZN12GaussMixture9distMahalEPf(ptr noundef nonnull align 8 dereferenceable(88) %0, ptr noundef %1) local_unnamed_addr #1 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 40
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = sext i32 %4 to i64
  %6 = icmp slt i32 %4, 0
  %7 = shl nsw i64 %5, 2
  %8 = select i1 %6, i64 -1, i64 %7
  %9 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %8) #2
  %10 = icmp sgt i32 %4, 0
  br i1 %10, label %.lr.ph, label %._crit_edge

.preheader:                                       ; preds = %.lr.ph
  %11 = icmp sgt i32 %17, 0
  br i1 %11, label %.lr.ph22, label %._crit_edge

.lr.ph22:                                         ; preds = %.preheader
  %12 = getelementptr inbounds i8, ptr %0, i64 84
  %wide.trip.count = zext nneg i32 %17 to i64
  %xtraiter = and i64 %wide.trip.count, 3
  %13 = icmp ult i32 %17, 4
  br i1 %13, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph22.new

.lr.ph22.new:                                     ; preds = %.lr.ph22
  %unroll_iter = and i64 %wide.trip.count, 2147483644
  br label %27

.lr.ph:                                           ; preds = %2, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %2 ]
  %14 = trunc nuw nsw i64 %indvars.iv to i32
  %15 = tail call noundef float @_ZN12GaussMixture9distMahalEPfi(ptr noundef nonnull align 8 dereferenceable(88) %0, ptr noundef %1, i32 noundef %14)
  %16 = getelementptr inbounds float, ptr %9, i64 %indvars.iv
  store float %15, ptr %16, align 4, !tbaa !12
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %17 = load i32, ptr %3, align 8, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = icmp slt i64 %indvars.iv.next, %18
  br i1 %19, label %.lr.ph, label %.preheader, !llvm.loop !13

._crit_edge.loopexit.unr-lcssa:                   ; preds = %51, %.lr.ph22
  %.1.lcssa.ph = phi float [ poison, %.lr.ph22 ], [ %.1.3, %51 ]
  %indvars.iv26.unr = phi i64 [ 0, %.lr.ph22 ], [ %indvars.iv.next27.3, %51 ]
  %.01620.unr = phi float [ 1.000000e+04, %.lr.ph22 ], [ %.1.3, %51 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge.loopexit.unr-lcssa, %25
  %indvars.iv26.epil = phi i64 [ %indvars.iv.next27.epil, %25 ], [ %indvars.iv26.unr, %._crit_edge.loopexit.unr-lcssa ]
  %.01620.epil = phi float [ %.1.epil, %25 ], [ %.01620.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %25 ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %20 = getelementptr inbounds float, ptr %9, i64 %indvars.iv26.epil
  %21 = load float, ptr %20, align 4, !tbaa !12
  %22 = fcmp olt float %21, %.01620.epil
  br i1 %22, label %23, label %25

23:                                               ; preds = %.epil.preheader
  %24 = trunc nuw nsw i64 %indvars.iv26.epil to i32
  store i32 %24, ptr %12, align 4, !tbaa !15
  br label %25

25:                                               ; preds = %23, %.epil.preheader
  %.1.epil = phi float [ %21, %23 ], [ %.01620.epil, %.epil.preheader ]
  %indvars.iv.next27.epil = add nuw nsw i64 %indvars.iv26.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.epil.preheader, !llvm.loop !16

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %25, %2, %.preheader
  %.016.lcssa = phi float [ 1.000000e+04, %.preheader ], [ 1.000000e+04, %2 ], [ %.1.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %.1.epil, %25 ]
  %26 = getelementptr inbounds i8, ptr %0, i64 76
  store float %.016.lcssa, ptr %26, align 4, !tbaa !18
  ret float %.016.lcssa

27:                                               ; preds = %51, %.lr.ph22.new
  %indvars.iv26 = phi i64 [ 0, %.lr.ph22.new ], [ %indvars.iv.next27.3, %51 ]
  %.01620 = phi float [ 1.000000e+04, %.lr.ph22.new ], [ %.1.3, %51 ]
  %niter = phi i64 [ 0, %.lr.ph22.new ], [ %niter.next.3, %51 ]
  %28 = getelementptr inbounds float, ptr %9, i64 %indvars.iv26
  %29 = load float, ptr %28, align 4, !tbaa !12
  %30 = fcmp olt float %29, %.01620
  br i1 %30, label %31, label %33

31:                                               ; preds = %27
  %32 = trunc nuw nsw i64 %indvars.iv26 to i32
  store i32 %32, ptr %12, align 4, !tbaa !15
  br label %33

33:                                               ; preds = %27, %31
  %.1 = phi float [ %29, %31 ], [ %.01620, %27 ]
  %indvars.iv.next27 = or disjoint i64 %indvars.iv26, 1
  %34 = getelementptr inbounds float, ptr %9, i64 %indvars.iv.next27
  %35 = load float, ptr %34, align 4, !tbaa !12
  %36 = fcmp olt float %35, %.1
  br i1 %36, label %37, label %39

37:                                               ; preds = %33
  %38 = trunc nuw nsw i64 %indvars.iv.next27 to i32
  store i32 %38, ptr %12, align 4, !tbaa !15
  br label %39

39:                                               ; preds = %37, %33
  %.1.1 = phi float [ %35, %37 ], [ %.1, %33 ]
  %indvars.iv.next27.1 = or disjoint i64 %indvars.iv26, 2
  %40 = getelementptr inbounds float, ptr %9, i64 %indvars.iv.next27.1
  %41 = load float, ptr %40, align 4, !tbaa !12
  %42 = fcmp olt float %41, %.1.1
  br i1 %42, label %43, label %45

43:                                               ; preds = %39
  %44 = trunc nuw nsw i64 %indvars.iv.next27.1 to i32
  store i32 %44, ptr %12, align 4, !tbaa !15
  br label %45

45:                                               ; preds = %43, %39
  %.1.2 = phi float [ %41, %43 ], [ %.1.1, %39 ]
  %indvars.iv.next27.2 = or disjoint i64 %indvars.iv26, 3
  %46 = getelementptr inbounds float, ptr %9, i64 %indvars.iv.next27.2
  %47 = load float, ptr %46, align 4, !tbaa !12
  %48 = fcmp olt float %47, %.1.2
  br i1 %48, label %49, label %51

49:                                               ; preds = %45
  %50 = trunc nuw nsw i64 %indvars.iv.next27.2 to i32
  store i32 %50, ptr %12, align 4, !tbaa !15
  br label %51

51:                                               ; preds = %49, %45
  %.1.3 = phi float [ %47, %49 ], [ %.1.2, %45 ]
  %indvars.iv.next27.3 = add nuw nsw i64 %indvars.iv26, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.loopexit.unr-lcssa, label %27, !llvm.loop !19
}

attributes #0 = { nobuiltin allocsize(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 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 #2 = { builtin allocsize(0) }

!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, !10, i64 40}
!6 = !{!"_ZTS12GaussMixture", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !11, i64 72, !11, i64 76, !11, i64 80, !10, i64 84}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"float", !8, i64 0}
!12 = !{!11, !11, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!6, !10, i64 84}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.unroll.disable"}
!18 = !{!6, !11, i64 76}
!19 = distinct !{!19, !14}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass