; 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

; Function Attrs: nounwind uwtable
define dso_local void @vl_svmdataset_accumulate_f(ptr noundef %0, i64 noundef %1, ptr noundef %2, double noundef %3) #2 {
  %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
  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) #3
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.VlSvmDataset_, ptr %11, i32 0, i32 1
  %13 = load ptr, ptr %12, align 8, !tbaa !13
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.VlSvmDataset_, ptr %14, i32 0, i32 3
  %16 = load i64, ptr %15, align 8, !tbaa !16
  %17 = load i64, ptr %6, align 8, !tbaa !9
  %18 = mul i64 %16, %17
  %19 = getelementptr inbounds float, ptr %13, i64 %18
  store ptr %19, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %20 = load ptr, ptr %9, align 8, !tbaa !5
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.VlSvmDataset_, ptr %21, i32 0, i32 3
  %23 = load i64, ptr %22, align 8, !tbaa !16
  %24 = getelementptr inbounds float, ptr %20, i64 %23
  store ptr %24, ptr %10, align 8, !tbaa !5
  br label %25

25:                                               ; preds = %29, %4
  %26 = load ptr, ptr %9, align 8, !tbaa !5
  %27 = load ptr, ptr %10, align 8, !tbaa !5
  %28 = icmp ne ptr %26, %27
  br i1 %28, label %29, label %40

29:                                               ; preds = %25
  %30 = load ptr, ptr %9, align 8, !tbaa !5
  %31 = getelementptr inbounds float, ptr %30, i32 1
  store ptr %31, ptr %9, align 8, !tbaa !5
  %32 = load float, ptr %30, align 4, !tbaa !17
  %33 = fpext float %32 to double
  %34 = load double, ptr %8, align 8, !tbaa !11
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = load double, ptr %35, align 8, !tbaa !11
  %37 = call double @llvm.fmuladd.f64(double %33, double %34, double %36)
  store double %37, ptr %35, align 8, !tbaa !11
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = getelementptr inbounds double, ptr %38, i32 1
  store ptr %39, ptr %7, align 8, !tbaa !5
  br label %25, !llvm.loop !19

40:                                               ; preds = %25
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  ret void
}

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 = { 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 = !{!18, !18, i64 0}
!18 = !{!"float", !7, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}


; 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: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @vl_svmdataset_accumulate_f(ptr nocapture noundef readonly %0, i64 noundef %1, ptr nocapture noundef %2, double noundef %3) local_unnamed_addr #1 {
  %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
  %.not11 = icmp eq i64 %8, 0
  br i1 %.not11, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %4
  %12 = add i64 %8, 4611686018427387903
  %13 = and i64 %12, 4611686018427387903
  %14 = add nuw nsw i64 %13, 1
  %min.iters.check = icmp ult i64 %13, 3
  br i1 %min.iters.check, label %.lr.ph.preheader23, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph.preheader
  %n.vec = and i64 %14, 9223372036854775804
  %15 = shl i64 %n.vec, 3
  %ind.end = getelementptr i8, ptr %2, i64 %15
  %16 = shl i64 %n.vec, 2
  %ind.end14 = getelementptr i8, ptr %10, i64 %16
  %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 %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 %2, i64 %offset.idx
  %offset.idx17 = shl i64 %index, 2
  %next.gep18 = getelementptr i8, ptr %10, i64 %offset.idx17
  %17 = getelementptr i8, ptr %next.gep18, i64 8
  %wide.load = load <2 x float>, ptr %next.gep18, align 4, !tbaa !13
  %wide.load20 = load <2 x float>, ptr %17, align 4, !tbaa !13
  %18 = fpext <2 x float> %wide.load to <2 x double>
  %19 = fpext <2 x float> %wide.load20 to <2 x double>
  %20 = getelementptr i8, ptr %next.gep, i64 16
  %wide.load21 = load <2 x double>, ptr %next.gep, align 8, !tbaa !15
  %wide.load22 = load <2 x double>, ptr %20, align 8, !tbaa !15
  %21 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %18, <2 x double> %broadcast.splat, <2 x double> %wide.load21)
  %22 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %19, <2 x double> %broadcast.splat, <2 x double> %wide.load22)
  store <2 x double> %21, ptr %next.gep, align 8, !tbaa !15
  store <2 x double> %22, ptr %20, align 8, !tbaa !15
  %index.next = add nuw i64 %index, 4
  %23 = icmp eq i64 %index.next, %n.vec
  br i1 %23, label %middle.block, label %vector.body, !llvm.loop !17

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %14, %n.vec
  br i1 %cmp.n, label %._crit_edge, label %.lr.ph.preheader23

.lr.ph.preheader23:                               ; preds = %middle.block, %.lr.ph.preheader
  %.013.ph = phi ptr [ %2, %.lr.ph.preheader ], [ %ind.end, %middle.block ]
  %.01012.ph = phi ptr [ %10, %.lr.ph.preheader ], [ %ind.end14, %middle.block ]
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader23, %.lr.ph
  %.013 = phi ptr [ %29, %.lr.ph ], [ %.013.ph, %.lr.ph.preheader23 ]
  %.01012 = phi ptr [ %24, %.lr.ph ], [ %.01012.ph, %.lr.ph.preheader23 ]
  %24 = getelementptr inbounds i8, ptr %.01012, i64 4
  %25 = load float, ptr %.01012, align 4, !tbaa !13
  %26 = fpext float %25 to double
  %27 = load double, ptr %.013, align 8, !tbaa !15
  %28 = tail call double @llvm.fmuladd.f64(double %26, double %3, double %27)
  store double %28, ptr %.013, align 8, !tbaa !15
  %29 = getelementptr inbounds i8, ptr %.013, i64 8
  %.not = icmp eq ptr %24, %11
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !21

._crit_edge:                                      ; preds = %.lr.ph, %middle.block, %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>) #2

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

!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 = !{!14, !14, i64 0}
!14 = !{!"float", !8, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"double", !8, i64 0}
!17 = distinct !{!17, !18, !19, !20}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!"llvm.loop.isvectorized", i32 1}
!20 = !{!"llvm.loop.unroll.runtime.disable"}
!21 = distinct !{!21, !18, !20, !19}


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