; LLVM IR from QiaoLiuHit/LSOTB-TIR :: vlfeat-0.9.19/vl (svmdataset)

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

%struct.VlSvmDataset_ = type { i32, ptr, i64, i64, ptr, ptr, i64 }

; 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 speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

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

declare void @vl_homogeneouskernelmap_evaluate_d(ptr noundef, ptr noundef, i64 noundef, double noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @vl_svmdataset_accumulate_hom_d(ptr noundef %0, i64 noundef %1, ptr noundef %2, double noundef %3) #3 {
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca double, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  store double %3, ptr %8, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.VlSvmDataset_, ptr %13, i32 0, i32 1
  %15 = load ptr, ptr %14, align 8, !tbaa !13
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.VlSvmDataset_, ptr %16, i32 0, i32 3
  %18 = load i64, ptr %17, align 8, !tbaa !16
  %19 = load i64, ptr %6, align 8, !tbaa !9
  %20 = mul i64 %18, %19
  %21 = getelementptr inbounds double, ptr %15, i64 %20
  store ptr %21, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %22 = load ptr, ptr %9, align 8, !tbaa !5
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.VlSvmDataset_, ptr %23, i32 0, i32 3
  %25 = load i64, ptr %24, align 8, !tbaa !16
  %26 = getelementptr inbounds double, ptr %22, i64 %25
  store ptr %26, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.VlSvmDataset_, ptr %27, i32 0, i32 5
  %29 = load ptr, ptr %28, align 8, !tbaa !17
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.VlSvmDataset_, ptr %30, i32 0, i32 6
  %32 = load i64, ptr %31, align 8, !tbaa !18
  %33 = getelementptr inbounds double, ptr %29, i64 %32
  store ptr %33, ptr %11, align 8, !tbaa !5
  br label %34

34:                                               ; preds = %65, %4
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  %36 = load ptr, ptr %10, align 8, !tbaa !5
  %37 = icmp ne ptr %35, %36
  br i1 %37, label %38, label %66

38:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.VlSvmDataset_, ptr %39, i32 0, i32 5
  %41 = load ptr, ptr %40, align 8, !tbaa !17
  store ptr %41, ptr %12, align 8, !tbaa !5
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.VlSvmDataset_, ptr %42, i32 0, i32 4
  %44 = load ptr, ptr %43, align 8, !tbaa !19
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.VlSvmDataset_, ptr %45, i32 0, i32 5
  %47 = load ptr, ptr %46, align 8, !tbaa !17
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  %49 = getelementptr inbounds double, ptr %48, i32 1
  store ptr %49, ptr %9, align 8, !tbaa !5
  %50 = load double, ptr %48, align 8, !tbaa !11
  call void @vl_homogeneouskernelmap_evaluate_d(ptr noundef %44, ptr noundef %47, i64 noundef 1, double noundef %50)
  br label %51

51:                                               ; preds = %55, %38
  %52 = load ptr, ptr %12, align 8, !tbaa !5
  %53 = load ptr, ptr %11, align 8, !tbaa !5
  %54 = icmp ne ptr %52, %53
  br i1 %54, label %55, label %65

55:                                               ; preds = %51
  %56 = load ptr, ptr %12, align 8, !tbaa !5
  %57 = getelementptr inbounds double, ptr %56, i32 1
  store ptr %57, ptr %12, align 8, !tbaa !5
  %58 = load double, ptr %56, align 8, !tbaa !11
  %59 = load double, ptr %8, align 8, !tbaa !11
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  %61 = load double, ptr %60, align 8, !tbaa !11
  %62 = call double @llvm.fmuladd.f64(double %58, double %59, double %61)
  store double %62, ptr %60, align 8, !tbaa !11
  %63 = load ptr, ptr %7, align 8, !tbaa !5
  %64 = getelementptr inbounds double, ptr %63, i32 1
  store ptr %64, ptr %7, align 8, !tbaa !5
  br label %51, !llvm.loop !20

65:                                               ; preds = %51
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  br label %34, !llvm.loop !22

66:                                               ; preds = %34
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  ret void
}

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

!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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !6, i64 8}
!14 = !{!"VlSvmDataset_", !15, i64 0, !6, i64 8, !10, i64 16, !10, i64 24, !6, i64 32, !6, i64 40, !10, i64 48}
!15 = !{!"int", !7, i64 0}
!16 = !{!14, !10, i64 24}
!17 = !{!14, !6, i64 40}
!18 = !{!14, !10, i64 48}
!19 = !{!14, !6, i64 32}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21}


; 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: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #0

declare void @vl_homogeneouskernelmap_evaluate_d(ptr noundef, ptr noundef, i64 noundef, double noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @vl_svmdataset_accumulate_hom_d(ptr nocapture noundef readonly %0, i64 noundef %1, ptr nocapture noundef %2, double noundef %3) local_unnamed_addr #2 {
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  %8 = load i64, ptr %7, align 8, !tbaa !12
  %9 = mul i64 %8, %1
  %10 = getelementptr inbounds double, ptr %6, i64 %9
  %11 = getelementptr inbounds double, ptr %10, i64 %8
  %12 = getelementptr inbounds i8, ptr %0, i64 40
  %13 = load ptr, ptr %12, align 8, !tbaa !13
  %14 = getelementptr inbounds i8, ptr %0, i64 48
  %15 = load i64, ptr %14, align 8, !tbaa !14
  %16 = getelementptr inbounds double, ptr %13, i64 %15
  %.not24 = icmp eq i64 %8, 0
  br i1 %.not24, label %._crit_edge, label %.lr.ph27

.lr.ph27:                                         ; preds = %4
  %17 = ptrtoint ptr %13 to i64
  %18 = getelementptr inbounds i8, ptr %0, i64 32
  %19 = shl i64 %15, 3
  %20 = add i64 %19, %17
  %21 = add i64 %20, -8
  %22 = add i64 %19, %17
  %23 = add i64 %22, -8
  %broadcast.splatinsert = insertelement <2 x double> poison, double %3, i64 0
  %broadcast.splat = shufflevector <2 x double> %broadcast.splatinsert, <2 x double> poison, <2 x i32> zeroinitializer
  br label %24

.loopexit:                                        ; preds = %.lr.ph, %middle.block, %24
  %.1.lcssa = phi ptr [ %.01826, %24 ], [ %ind.end31, %middle.block ], [ %46, %.lr.ph ]
  %.not = icmp eq ptr %28, %11
  br i1 %.not, label %._crit_edge, label %24, !llvm.loop !15

24:                                               ; preds = %.lr.ph27, %.loopexit
  %.01826 = phi ptr [ %2, %.lr.ph27 ], [ %.1.lcssa, %.loopexit ]
  %.01925 = phi ptr [ %10, %.lr.ph27 ], [ %28, %.loopexit ]
  %25 = load ptr, ptr %12, align 8, !tbaa !13
  %26 = ptrtoint ptr %25 to i64
  %27 = load ptr, ptr %18, align 8, !tbaa !17
  %28 = getelementptr inbounds i8, ptr %.01925, i64 8
  %29 = load double, ptr %.01925, align 8, !tbaa !18
  tail call void @vl_homogeneouskernelmap_evaluate_d(ptr noundef %27, ptr noundef %25, i64 noundef 1, double noundef %29) #4
  %.not2021 = icmp eq ptr %25, %16
  br i1 %.not2021, label %.loopexit, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %24
  %30 = sub i64 %23, %26
  %31 = lshr i64 %30, 3
  %32 = add nuw nsw i64 %31, 1
  %min.iters.check = icmp ult i64 %30, 24
  br i1 %min.iters.check, label %.lr.ph.preheader40, label %vector.memcheck

vector.memcheck:                                  ; preds = %.lr.ph.preheader
  %scevgep = getelementptr i8, ptr %.01826, i64 8
  %33 = sub i64 %21, %26
  %34 = and i64 %33, -8
  %scevgep28 = getelementptr i8, ptr %scevgep, i64 %34
  %scevgep29 = getelementptr i8, ptr %25, i64 8
  %scevgep30 = getelementptr i8, ptr %scevgep29, i64 %34
  %bound0 = icmp ult ptr %.01826, %scevgep30
  %bound1 = icmp ult ptr %25, %scevgep28
  %found.conflict = and i1 %bound0, %bound1
  br i1 %found.conflict, label %.lr.ph.preheader40, label %vector.ph

vector.ph:                                        ; preds = %vector.memcheck
  %n.vec = and i64 %32, 4611686018427387900
  %35 = shl i64 %n.vec, 3
  %ind.end = getelementptr i8, ptr %25, i64 %35
  %36 = shl i64 %n.vec, 3
  %ind.end31 = getelementptr i8, ptr %.01826, i64 %36
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %offset.idx = shl i64 %index, 3
  %next.gep = getelementptr i8, ptr %25, i64 %offset.idx
  %offset.idx34 = shl i64 %index, 3
  %next.gep35 = getelementptr i8, ptr %.01826, i64 %offset.idx34
  %37 = getelementptr i8, ptr %next.gep, i64 16
  %wide.load = load <2 x double>, ptr %next.gep, align 8, !tbaa !18, !alias.scope !20
  %wide.load37 = load <2 x double>, ptr %37, align 8, !tbaa !18, !alias.scope !20
  %38 = getelementptr i8, ptr %next.gep35, i64 16
  %wide.load38 = load <2 x double>, ptr %next.gep35, align 8, !tbaa !18, !alias.scope !23, !noalias !20
  %wide.load39 = load <2 x double>, ptr %38, align 8, !tbaa !18, !alias.scope !23, !noalias !20
  %39 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %wide.load, <2 x double> %broadcast.splat, <2 x double> %wide.load38)
  %40 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %wide.load37, <2 x double> %broadcast.splat, <2 x double> %wide.load39)
  store <2 x double> %39, ptr %next.gep35, align 8, !tbaa !18, !alias.scope !23, !noalias !20
  store <2 x double> %40, ptr %38, align 8, !tbaa !18, !alias.scope !23, !noalias !20
  %index.next = add nuw i64 %index, 4
  %41 = icmp eq i64 %index.next, %n.vec
  br i1 %41, label %middle.block, label %vector.body, !llvm.loop !25

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %32, %n.vec
  br i1 %cmp.n, label %.loopexit, label %.lr.ph.preheader40

.lr.ph.preheader40:                               ; preds = %middle.block, %vector.memcheck, %.lr.ph.preheader
  %.023.ph = phi ptr [ %25, %vector.memcheck ], [ %25, %.lr.ph.preheader ], [ %ind.end, %middle.block ]
  %.122.ph = phi ptr [ %.01826, %vector.memcheck ], [ %.01826, %.lr.ph.preheader ], [ %ind.end31, %middle.block ]
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader40, %.lr.ph
  %.023 = phi ptr [ %42, %.lr.ph ], [ %.023.ph, %.lr.ph.preheader40 ]
  %.122 = phi ptr [ %46, %.lr.ph ], [ %.122.ph, %.lr.ph.preheader40 ]
  %42 = getelementptr inbounds i8, ptr %.023, i64 8
  %43 = load double, ptr %.023, align 8, !tbaa !18
  %44 = load double, ptr %.122, align 8, !tbaa !18
  %45 = tail call double @llvm.fmuladd.f64(double %43, double %3, double %44)
  store double %45, ptr %.122, align 8, !tbaa !18
  %46 = getelementptr inbounds i8, ptr %.122, i64 8
  %.not20 = icmp eq ptr %42, %16
  br i1 %.not20, label %.loopexit, label %.lr.ph, !llvm.loop !28

._crit_edge:                                      ; preds = %.loopexit, %4
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { "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 = { 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nounwind }

!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 8}
!6 = !{!"VlSvmDataset_", !7, i64 0, !10, i64 8, !11, i64 16, !11, i64 24, !10, i64 32, !10, i64 40, !11, i64 48}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"long long", !8, i64 0}
!12 = !{!6, !11, i64 24}
!13 = !{!6, !10, i64 40}
!14 = !{!6, !11, i64 48}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!6, !10, i64 32}
!18 = !{!19, !19, i64 0}
!19 = !{!"double", !8, i64 0}
!20 = !{!21}
!21 = distinct !{!21, !22}
!22 = distinct !{!22, !"LVerDomain"}
!23 = !{!24}
!24 = distinct !{!24, !22}
!25 = distinct !{!25, !16, !26, !27}
!26 = !{!"llvm.loop.isvectorized", i32 1}
!27 = !{!"llvm.loop.unroll.runtime.disable"}
!28 = distinct !{!28, !16, !26}


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