; LLVM IR from softmin/ReHLine-SVM :: liblinear/linear.ll (ZN11l2r_erm_fun3funEPd)

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

%class.l2r_erm_fun = type <{ %class.function, ptr, ptr, ptr, ptr, double, i32, [4 x i8] }>
%class.function = type { ptr }
%struct.problem = type { i32, i32, ptr, ptr, double }

; 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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZN11l2r_erm_fun3funEPd(ptr noundef nonnull align 8 dereferenceable(52) %0, ptr noundef %1) unnamed_addr #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca double, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %9 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store double 0.000000e+00, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %10 = getelementptr inbounds %class.l2r_erm_fun, ptr %9, i32 0, i32 2
  %11 = load ptr, ptr %10, align 8, !tbaa !11
  %12 = getelementptr inbounds %struct.problem, ptr %11, i32 0, i32 0
  %13 = load i32, ptr %12, align 8, !tbaa !15
  store i32 %13, ptr %7, align 4, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %14 = load ptr, ptr %9, align 8, !tbaa !18
  %15 = getelementptr inbounds ptr, ptr %14, i64 3
  %16 = load ptr, ptr %15, align 8
  %17 = call noundef i32 %16(ptr noundef nonnull align 8 dereferenceable(52) %9)
  store i32 %17, ptr %8, align 4, !tbaa !17
  %18 = getelementptr inbounds %class.l2r_erm_fun, ptr %9, i32 0, i32 5
  store double 0.000000e+00, ptr %18, align 8, !tbaa !20
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %class.l2r_erm_fun, ptr %9, i32 0, i32 3
  %21 = load ptr, ptr %20, align 8, !tbaa !21
  call void @_ZN11l2r_erm_fun2XvEPdS0_(ptr noundef nonnull align 8 dereferenceable(52) %9, ptr noundef %19, ptr noundef %21)
  store i32 0, ptr %5, align 4, !tbaa !17
  br label %22

22:                                               ; preds = %40, %2
  %23 = load i32, ptr %5, align 4, !tbaa !17
  %24 = load i32, ptr %8, align 4, !tbaa !17
  %25 = icmp slt i32 %23, %24
  br i1 %25, label %26, label %43

26:                                               ; preds = %22
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = load i32, ptr %5, align 4, !tbaa !17
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds double, ptr %27, i64 %29
  %31 = load double, ptr %30, align 8, !tbaa !9
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = load i32, ptr %5, align 4, !tbaa !17
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds double, ptr %32, i64 %34
  %36 = load double, ptr %35, align 8, !tbaa !9
  %37 = getelementptr inbounds %class.l2r_erm_fun, ptr %9, i32 0, i32 5
  %38 = load double, ptr %37, align 8, !tbaa !20
  %39 = call double @llvm.fmuladd.f64(double %31, double %36, double %38)
  store double %39, ptr %37, align 8, !tbaa !20
  br label %40

40:                                               ; preds = %26
  %41 = load i32, ptr %5, align 4, !tbaa !17
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %5, align 4, !tbaa !17
  br label %22, !llvm.loop !22

43:                                               ; preds = %22
  %44 = getelementptr inbounds %class.l2r_erm_fun, ptr %9, i32 0, i32 6
  %45 = load i32, ptr %44, align 8, !tbaa !24
  %46 = icmp eq i32 %45, 0
  br i1 %46, label %47, label %64

47:                                               ; preds = %43
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = load i32, ptr %8, align 4, !tbaa !17
  %50 = sub nsw i32 %49, 1
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds double, ptr %48, i64 %51
  %53 = load double, ptr %52, align 8, !tbaa !9
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = load i32, ptr %8, align 4, !tbaa !17
  %56 = sub nsw i32 %55, 1
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds double, ptr %54, i64 %57
  %59 = load double, ptr %58, align 8, !tbaa !9
  %60 = getelementptr inbounds %class.l2r_erm_fun, ptr %9, i32 0, i32 5
  %61 = load double, ptr %60, align 8, !tbaa !20
  %62 = fneg double %53
  %63 = call double @llvm.fmuladd.f64(double %62, double %59, double %61)
  store double %63, ptr %60, align 8, !tbaa !20
  br label %64

64:                                               ; preds = %47, %43
  store i32 0, ptr %5, align 4, !tbaa !17
  br label %65

65:                                               ; preds = %83, %64
  %66 = load i32, ptr %5, align 4, !tbaa !17
  %67 = load i32, ptr %7, align 4, !tbaa !17
  %68 = icmp slt i32 %66, %67
  br i1 %68, label %69, label %86

69:                                               ; preds = %65
  %70 = load i32, ptr %5, align 4, !tbaa !17
  %71 = getelementptr inbounds %class.l2r_erm_fun, ptr %9, i32 0, i32 3
  %72 = load ptr, ptr %71, align 8, !tbaa !21
  %73 = load i32, ptr %5, align 4, !tbaa !17
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds double, ptr %72, i64 %74
  %76 = load double, ptr %75, align 8, !tbaa !9
  %77 = load ptr, ptr %9, align 8, !tbaa !18
  %78 = getelementptr inbounds ptr, ptr %77, i64 8
  %79 = load ptr, ptr %78, align 8
  %80 = call noundef double %79(ptr noundef nonnull align 8 dereferenceable(52) %9, i32 noundef %70, double noundef %76)
  %81 = load double, ptr %6, align 8, !tbaa !9
  %82 = fadd double %81, %80
  store double %82, ptr %6, align 8, !tbaa !9
  br label %83

83:                                               ; preds = %69
  %84 = load i32, ptr %5, align 4, !tbaa !17
  %85 = add nsw i32 %84, 1
  store i32 %85, ptr %5, align 4, !tbaa !17
  br label %65, !llvm.loop !25

86:                                               ; preds = %65
  %87 = load double, ptr %6, align 8, !tbaa !9
  %88 = getelementptr inbounds %class.l2r_erm_fun, ptr %9, i32 0, i32 5
  %89 = load double, ptr %88, align 8, !tbaa !20
  %90 = call double @llvm.fmuladd.f64(double 5.000000e-01, double %89, double %87)
  store double %90, ptr %6, align 8, !tbaa !9
  %91 = load double, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret double %91
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11l2r_erm_fun2XvEPdS0_(ptr noundef nonnull align 8 dereferenceable(52), ptr noundef, ptr noundef) #1 align 2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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) }
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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !6, i64 16}
!12 = !{!"_ZTS11l2r_erm_fun", !13, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !10, i64 40, !14, i64 48}
!13 = !{!"_ZTS8function"}
!14 = !{!"int", !7, i64 0}
!15 = !{!16, !14, i64 0}
!16 = !{!"_ZTS7problem", !14, i64 0, !14, i64 4, !6, i64 8, !6, i64 16, !10, i64 24}
!17 = !{!14, !14, i64 0}
!18 = !{!19, !19, i64 0}
!19 = !{!"vtable pointer", !8, i64 0}
!20 = !{!12, !10, i64 40}
!21 = !{!12, !6, i64 24}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = !{!12, !14, i64 48}
!25 = distinct !{!25, !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 uwtable
define dso_local noundef double @_ZN11l2r_erm_fun3funEPd(ptr noundef nonnull align 8 dereferenceable(52) %0, ptr noundef %1) unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 16
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = load i32, ptr %4, align 8, !tbaa !13
  %6 = load ptr, ptr %0, align 8, !tbaa !15
  %7 = getelementptr inbounds i8, ptr %6, i64 24
  %8 = load ptr, ptr %7, align 8
  %9 = tail call noundef i32 %8(ptr noundef nonnull align 8 dereferenceable(52) %0)
  %10 = getelementptr inbounds i8, ptr %0, i64 40
  store double 0.000000e+00, ptr %10, align 8, !tbaa !17
  %11 = getelementptr inbounds i8, ptr %0, i64 24
  %12 = load ptr, ptr %11, align 8, !tbaa !18
  tail call void @_ZN11l2r_erm_fun2XvEPdS0_(ptr noundef nonnull align 8 dereferenceable(52) %0, ptr noundef %1, ptr noundef %12)
  %.promoted = load double, ptr %10, align 8, !tbaa !17
  %13 = icmp sgt i32 %9, 0
  br i1 %13, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %2
  %wide.trip.count = zext nneg i32 %9 to i64
  %xtraiter = and i64 %wide.trip.count, 3
  %14 = icmp ult i32 %9, 4
  br i1 %14, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %wide.trip.count, 2147483644
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader.new ], [ %indvars.iv.next.3, %.lr.ph ]
  %15 = phi double [ %.promoted, %.lr.ph.preheader.new ], [ %27, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.3, %.lr.ph ]
  %16 = getelementptr inbounds double, ptr %1, i64 %indvars.iv
  %17 = load double, ptr %16, align 8, !tbaa !19
  %18 = tail call double @llvm.fmuladd.f64(double %17, double %17, double %15)
  store double %18, ptr %10, align 8, !tbaa !17
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %19 = getelementptr inbounds double, ptr %1, i64 %indvars.iv.next
  %20 = load double, ptr %19, align 8, !tbaa !19
  %21 = tail call double @llvm.fmuladd.f64(double %20, double %20, double %18)
  store double %21, ptr %10, align 8, !tbaa !17
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %22 = getelementptr inbounds double, ptr %1, i64 %indvars.iv.next.1
  %23 = load double, ptr %22, align 8, !tbaa !19
  %24 = tail call double @llvm.fmuladd.f64(double %23, double %23, double %21)
  store double %24, ptr %10, align 8, !tbaa !17
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %25 = getelementptr inbounds double, ptr %1, i64 %indvars.iv.next.2
  %26 = load double, ptr %25, align 8, !tbaa !19
  %27 = tail call double @llvm.fmuladd.f64(double %26, double %26, double %24)
  store double %27, ptr %10, align 8, !tbaa !17
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !20

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.lr.ph, %.lr.ph.preheader
  %.lcssa36.ph = phi double [ poison, %.lr.ph.preheader ], [ %27, %.lr.ph ]
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next.3, %.lr.ph ]
  %.unr = phi double [ %.promoted, %.lr.ph.preheader ], [ %27, %.lr.ph ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.epil
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.lr.ph.epil ], [ %indvars.iv.unr, %._crit_edge.loopexit.unr-lcssa ]
  %28 = phi double [ %31, %.lr.ph.epil ], [ %.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %29 = getelementptr inbounds double, ptr %1, i64 %indvars.iv.epil
  %30 = load double, ptr %29, align 8, !tbaa !19
  %31 = tail call double @llvm.fmuladd.f64(double %30, double %30, double %28)
  store double %31, ptr %10, align 8, !tbaa !17
  %indvars.iv.next.epil = add nuw nsw i64 %indvars.iv.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.lr.ph.epil, !llvm.loop !22

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.epil, %2
  %32 = phi double [ %.promoted, %2 ], [ %.lcssa36.ph, %._crit_edge.loopexit.unr-lcssa ], [ %31, %.lr.ph.epil ]
  %33 = getelementptr inbounds i8, ptr %0, i64 48
  %34 = load i32, ptr %33, align 8, !tbaa !24
  %35 = icmp eq i32 %34, 0
  br i1 %35, label %36, label %43

36:                                               ; preds = %._crit_edge
  %37 = sext i32 %9 to i64
  %38 = getelementptr double, ptr %1, i64 %37
  %39 = getelementptr i8, ptr %38, i64 -8
  %40 = load double, ptr %39, align 8, !tbaa !19
  %41 = fneg double %40
  %42 = tail call double @llvm.fmuladd.f64(double %41, double %40, double %32)
  store double %42, ptr %10, align 8, !tbaa !17
  br label %43

43:                                               ; preds = %36, %._crit_edge
  %44 = phi double [ %42, %36 ], [ %32, %._crit_edge ]
  %45 = icmp sgt i32 %5, 0
  br i1 %45, label %.lr.ph26.preheader, label %._crit_edge27

.lr.ph26.preheader:                               ; preds = %43
  %wide.trip.count32 = zext nneg i32 %5 to i64
  br label %.lr.ph26

.lr.ph26:                                         ; preds = %.lr.ph26.preheader, %.lr.ph26
  %indvars.iv29 = phi i64 [ 0, %.lr.ph26.preheader ], [ %indvars.iv.next30, %.lr.ph26 ]
  %.02023 = phi double [ 0.000000e+00, %.lr.ph26.preheader ], [ %54, %.lr.ph26 ]
  %46 = load ptr, ptr %11, align 8, !tbaa !18
  %47 = getelementptr inbounds double, ptr %46, i64 %indvars.iv29
  %48 = load double, ptr %47, align 8, !tbaa !19
  %49 = load ptr, ptr %0, align 8, !tbaa !15
  %50 = getelementptr inbounds i8, ptr %49, i64 64
  %51 = load ptr, ptr %50, align 8
  %52 = trunc nuw nsw i64 %indvars.iv29 to i32
  %53 = tail call noundef double %51(ptr noundef nonnull align 8 dereferenceable(52) %0, i32 noundef %52, double noundef %48)
  %54 = fadd double %.02023, %53
  %indvars.iv.next30 = add nuw nsw i64 %indvars.iv29, 1
  %exitcond33.not = icmp eq i64 %indvars.iv.next30, %wide.trip.count32
  br i1 %exitcond33.not, label %._crit_edge27.loopexit, label %.lr.ph26, !llvm.loop !25

._crit_edge27.loopexit:                           ; preds = %.lr.ph26
  %.pre = load double, ptr %10, align 8, !tbaa !17
  br label %._crit_edge27

._crit_edge27:                                    ; preds = %._crit_edge27.loopexit, %43
  %55 = phi double [ %44, %43 ], [ %.pre, %._crit_edge27.loopexit ]
  %.020.lcssa = phi double [ 0.000000e+00, %43 ], [ %54, %._crit_edge27.loopexit ]
  %56 = tail call double @llvm.fmuladd.f64(double %55, double 5.000000e-01, double %.020.lcssa)
  ret double %56
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11l2r_erm_fun2XvEPdS0_(ptr noundef nonnull align 8 dereferenceable(52), ptr noundef, ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

attributes #0 = { mustprogress 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 #1 = { mustprogress 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, !8, i64 16}
!6 = !{!"_ZTS11l2r_erm_fun", !7, i64 0, !8, i64 8, !8, i64 16, !8, i64 24, !8, i64 32, !11, i64 40, !12, i64 48}
!7 = !{!"_ZTS8function"}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"double", !9, i64 0}
!12 = !{!"int", !9, i64 0}
!13 = !{!14, !12, i64 0}
!14 = !{!"_ZTS7problem", !12, i64 0, !12, i64 4, !8, i64 8, !8, i64 16, !11, i64 24}
!15 = !{!16, !16, i64 0}
!16 = !{!"vtable pointer", !10, i64 0}
!17 = !{!6, !11, i64 40}
!18 = !{!6, !8, i64 24}
!19 = !{!11, !11, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.unroll.disable"}
!24 = !{!6, !12, i64 48}
!25 = distinct !{!25, !21}


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