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

; 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

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

33:                                               ; preds = %63, %3
  %34 = load ptr, ptr %8, align 8, !tbaa !5
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  %36 = icmp ne ptr %34, %35
  br i1 %36, label %37, label %64

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

50:                                               ; preds = %54, %37
  %51 = load ptr, ptr %11, align 8, !tbaa !5
  %52 = load ptr, ptr %10, align 8, !tbaa !5
  %53 = icmp ne ptr %51, %52
  br i1 %53, label %54, label %63

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

63:                                               ; preds = %50
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %33, !llvm.loop !22

64:                                               ; preds = %33
  %65 = load double, ptr %7, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret double %65
}

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

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

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

.lr.ph32:                                         ; preds = %3
  %16 = getelementptr inbounds i8, ptr %0, i64 32
  br label %17

.loopexit:                                        ; preds = %.lr.ph, %17
  %.120.lcssa = phi double [ %.01930, %17 ], [ %26, %.lr.ph ]
  %.1.lcssa = phi ptr [ %.01831, %17 ], [ %24, %.lr.ph ]
  %.not = icmp eq ptr %20, %10
  br i1 %.not, label %._crit_edge, label %17, !llvm.loop !15

17:                                               ; preds = %.lr.ph32, %.loopexit
  %.01831 = phi ptr [ %2, %.lr.ph32 ], [ %.1.lcssa, %.loopexit ]
  %.01930 = phi double [ 0.000000e+00, %.lr.ph32 ], [ %.120.lcssa, %.loopexit ]
  %.02129 = phi ptr [ %9, %.lr.ph32 ], [ %20, %.loopexit ]
  %18 = load ptr, ptr %11, align 8, !tbaa !13
  %19 = load ptr, ptr %16, align 8, !tbaa !17
  %20 = getelementptr inbounds i8, ptr %.02129, i64 8
  %21 = load double, ptr %.02129, align 8, !tbaa !18
  tail call void @vl_homogeneouskernelmap_evaluate_d(ptr noundef %19, ptr noundef %18, i64 noundef 1, double noundef %21) #3
  %.not2223 = icmp eq ptr %18, %15
  br i1 %.not2223, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %17, %.lr.ph
  %.026 = phi ptr [ %22, %.lr.ph ], [ %18, %17 ]
  %.125 = phi ptr [ %24, %.lr.ph ], [ %.01831, %17 ]
  %.12024 = phi double [ %26, %.lr.ph ], [ %.01930, %17 ]
  %22 = getelementptr inbounds i8, ptr %.026, i64 8
  %23 = load double, ptr %.026, align 8, !tbaa !18
  %24 = getelementptr inbounds i8, ptr %.125, i64 8
  %25 = load double, ptr %.125, align 8, !tbaa !18
  %26 = tail call double @llvm.fmuladd.f64(double %23, double %25, double %.12024)
  %.not22 = icmp eq ptr %22, %15
  br i1 %.not22, label %.loopexit, label %.lr.ph, !llvm.loop !20

._crit_edge:                                      ; preds = %.loopexit, %3
  %.019.lcssa = phi double [ 0.000000e+00, %3 ], [ %.120.lcssa, %.loopexit ]
  ret double %.019.lcssa
}

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

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

!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 = distinct !{!20, !16}


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