; 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_f(ptr noundef, ptr noundef, i64 noundef, double noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @vl_svmdataset_accumulate_hom_f(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 float, 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 float, 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 float, ptr %29, i64 %32
  store ptr %33, ptr %11, align 8, !tbaa !5
  br label %34

34:                                               ; preds = %67, %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 %68

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 float, ptr %48, i32 1
  store ptr %49, ptr %9, align 8, !tbaa !5
  %50 = load float, ptr %48, align 4, !tbaa !20
  %51 = fpext float %50 to double
  call void @vl_homogeneouskernelmap_evaluate_f(ptr noundef %44, ptr noundef %47, i64 noundef 1, double noundef %51)
  br label %52

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

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

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

68:                                               ; 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 = !{!21, !21, i64 0}
!21 = !{!"float", !7, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = distinct !{!24, !23}


; 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_f(ptr noundef, ptr noundef, i64 noundef, double noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @vl_svmdataset_accumulate_hom_f(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 float, ptr %6, i64 %9
  %11 = getelementptr inbounds float, 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 float, 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, 2
  %20 = add i64 %19, %17
  %21 = add i64 %20, -4
  %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 %22

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

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

.lr.ph.preheader:                                 ; preds = %22
  %28 = ptrtoint ptr %23 to i64
  %29 = sub i64 %21, %28
  %30 = lshr i64 %29, 2
  %31 = add nuw nsw i64 %30, 1
  %min.iters.check = icmp ult i64 %29, 12
  br i1 %min.iters.check, label %.lr.ph.preheader37, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph.preheader
  %n.vec = and i64 %31, 9223372036854775804
  %32 = shl i64 %n.vec, 2
  %ind.end = getelementptr i8, ptr %23, i64 %32
  %33 = shl i64 %n.vec, 3
  %ind.end28 = getelementptr i8, ptr %.01826, i64 %33
  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, 2
  %next.gep = getelementptr i8, ptr %23, i64 %offset.idx
  %offset.idx31 = shl i64 %index, 3
  %next.gep32 = getelementptr i8, ptr %.01826, i64 %offset.idx31
  %34 = getelementptr i8, ptr %next.gep, i64 8
  %wide.load = load <2 x float>, ptr %next.gep, align 4, !tbaa !18
  %wide.load34 = load <2 x float>, ptr %34, align 4, !tbaa !18
  %35 = fpext <2 x float> %wide.load to <2 x double>
  %36 = fpext <2 x float> %wide.load34 to <2 x double>
  %37 = getelementptr i8, ptr %next.gep32, i64 16
  %wide.load35 = load <2 x double>, ptr %next.gep32, align 8, !tbaa !20
  %wide.load36 = load <2 x double>, ptr %37, align 8, !tbaa !20
  %38 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %35, <2 x double> %broadcast.splat, <2 x double> %wide.load35)
  %39 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %36, <2 x double> %broadcast.splat, <2 x double> %wide.load36)
  store <2 x double> %38, ptr %next.gep32, align 8, !tbaa !20
  store <2 x double> %39, ptr %37, align 8, !tbaa !20
  %index.next = add nuw i64 %index, 4
  %40 = icmp eq i64 %index.next, %n.vec
  br i1 %40, label %middle.block, label %vector.body, !llvm.loop !22

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

.lr.ph.preheader37:                               ; preds = %middle.block, %.lr.ph.preheader
  %.023.ph = phi ptr [ %23, %.lr.ph.preheader ], [ %ind.end, %middle.block ]
  %.122.ph = phi ptr [ %.01826, %.lr.ph.preheader ], [ %ind.end28, %middle.block ]
  br label %.lr.ph

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

._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 = !{!"float", !8, i64 0}
!20 = !{!21, !21, i64 0}
!21 = !{!"double", !8, i64 0}
!22 = distinct !{!22, !16, !23, !24}
!23 = !{!"llvm.loop.isvectorized", i32 1}
!24 = !{!"llvm.loop.unroll.runtime.disable"}
!25 = distinct !{!25, !16, !24, !23}


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