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

; 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_f(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 float, 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 float, 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 float, ptr %28, i64 %31
  store ptr %32, ptr %10, align 8, !tbaa !5
  br label %33

33:                                               ; preds = %65, %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 %66

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

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

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

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

66:                                               ; preds = %33
  %67 = 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 %67
}

declare void @vl_homogeneouskernelmap_evaluate_f(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 = !{!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

; Function Attrs: nounwind uwtable
define dso_local double @_vl_svmdataset_inner_product_hom_f(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 float, ptr %5, i64 %8
  %10 = getelementptr inbounds float, 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 float, 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 ], [ %28, %.lr.ph ]
  %.1.lcssa = phi ptr [ %.01831, %17 ], [ %26, %.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 4
  %21 = load float, ptr %.02129, align 4, !tbaa !18
  %22 = fpext float %21 to double
  tail call void @vl_homogeneouskernelmap_evaluate_f(ptr noundef %19, ptr noundef %18, i64 noundef 1, double noundef %22) #3
  %.not2223 = icmp eq ptr %18, %15
  br i1 %.not2223, label %.loopexit, label %.lr.ph

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

._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_f(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 = !{!"float", !8, i64 0}
!20 = !{!21, !21, i64 0}
!21 = !{!"double", !8, i64 0}
!22 = distinct !{!22, !16}


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