; LLVM IR from softmin/ReHLine-SVM :: liblinear/blas (dnrm2)

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

; Function Attrs: nounwind uwtable
define dso_local double @dnrm2_(ptr noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = load i32, ptr %15, align 4, !tbaa !9
  %17 = sext i32 %16 to i64
  store i64 %17, ptr %8, align 8, !tbaa !11
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = load i32, ptr %18, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  store i64 %20, ptr %9, align 8, !tbaa !11
  %21 = load i64, ptr %8, align 8, !tbaa !11
  %22 = icmp sgt i64 %21, 0
  br i1 %22, label %23, label %87

23:                                               ; preds = %3
  %24 = load i64, ptr %9, align 8, !tbaa !11
  %25 = icmp sgt i64 %24, 0
  br i1 %25, label %26, label %87

26:                                               ; preds = %23
  %27 = load i64, ptr %8, align 8, !tbaa !11
  %28 = icmp eq i64 %27, 1
  br i1 %28, label %29, label %34

29:                                               ; preds = %26
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds double, ptr %30, i64 0
  %32 = load double, ptr %31, align 8, !tbaa !13
  %33 = call double @llvm.fabs.f64(double %32)
  store double %33, ptr %10, align 8, !tbaa !13
  br label %86

34:                                               ; preds = %26
  store double 0.000000e+00, ptr %11, align 8, !tbaa !13
  store double 1.000000e+00, ptr %13, align 8, !tbaa !13
  %35 = load i64, ptr %8, align 8, !tbaa !11
  %36 = sub nsw i64 %35, 1
  %37 = load i64, ptr %9, align 8, !tbaa !11
  %38 = mul nsw i64 %36, %37
  store i64 %38, ptr %7, align 8, !tbaa !11
  br label %39

39:                                               ; preds = %77, %34
  %40 = load i64, ptr %7, align 8, !tbaa !11
  %41 = icmp sge i64 %40, 0
  br i1 %41, label %42, label %81

42:                                               ; preds = %39
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = load i64, ptr %7, align 8, !tbaa !11
  %45 = getelementptr inbounds double, ptr %43, i64 %44
  %46 = load double, ptr %45, align 8, !tbaa !13
  %47 = fcmp une double %46, 0.000000e+00
  br i1 %47, label %48, label %76

48:                                               ; preds = %42
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = load i64, ptr %7, align 8, !tbaa !11
  %51 = getelementptr inbounds double, ptr %49, i64 %50
  %52 = load double, ptr %51, align 8, !tbaa !13
  %53 = call double @llvm.fabs.f64(double %52)
  store double %53, ptr %12, align 8, !tbaa !13
  %54 = load double, ptr %11, align 8, !tbaa !13
  %55 = load double, ptr %12, align 8, !tbaa !13
  %56 = fcmp olt double %54, %55
  br i1 %56, label %57, label %67

57:                                               ; preds = %48
  %58 = load double, ptr %11, align 8, !tbaa !13
  %59 = load double, ptr %12, align 8, !tbaa !13
  %60 = fdiv double %58, %59
  store double %60, ptr %14, align 8, !tbaa !13
  %61 = load double, ptr %13, align 8, !tbaa !13
  %62 = load double, ptr %14, align 8, !tbaa !13
  %63 = load double, ptr %14, align 8, !tbaa !13
  %64 = fmul double %62, %63
  %65 = call double @llvm.fmuladd.f64(double %61, double %64, double 1.000000e+00)
  store double %65, ptr %13, align 8, !tbaa !13
  %66 = load double, ptr %12, align 8, !tbaa !13
  store double %66, ptr %11, align 8, !tbaa !13
  br label %75

67:                                               ; preds = %48
  %68 = load double, ptr %12, align 8, !tbaa !13
  %69 = load double, ptr %11, align 8, !tbaa !13
  %70 = fdiv double %68, %69
  store double %70, ptr %14, align 8, !tbaa !13
  %71 = load double, ptr %14, align 8, !tbaa !13
  %72 = load double, ptr %14, align 8, !tbaa !13
  %73 = load double, ptr %13, align 8, !tbaa !13
  %74 = call double @llvm.fmuladd.f64(double %71, double %72, double %73)
  store double %74, ptr %13, align 8, !tbaa !13
  br label %75

75:                                               ; preds = %67, %57
  br label %76

76:                                               ; preds = %75, %42
  br label %77

77:                                               ; preds = %76
  %78 = load i64, ptr %9, align 8, !tbaa !11
  %79 = load i64, ptr %7, align 8, !tbaa !11
  %80 = sub nsw i64 %79, %78
  store i64 %80, ptr %7, align 8, !tbaa !11
  br label %39, !llvm.loop !15

81:                                               ; preds = %39
  %82 = load double, ptr %11, align 8, !tbaa !13
  %83 = load double, ptr %13, align 8, !tbaa !13
  %84 = call double @sqrt(double noundef %83) #4
  %85 = fmul double %82, %84
  store double %85, ptr %10, align 8, !tbaa !13
  br label %86

86:                                               ; preds = %81, %29
  br label %88

87:                                               ; preds = %23, %3
  store double 0.000000e+00, ptr %10, align 8, !tbaa !13
  br label %88

88:                                               ; preds = %87, %86
  %89 = load double, ptr %10, align 8, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  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
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret double %89
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

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

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

; Function Attrs: nounwind
declare double @sqrt(double noundef) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nounwind "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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"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: nofree nounwind memory(write, argmem: readwrite) uwtable
define dso_local double @dnrm2_(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2) local_unnamed_addr #0 {
  %4 = load i32, ptr %0, align 4, !tbaa !5
  %5 = load i32, ptr %2, align 4, !tbaa !5
  %6 = sext i32 %5 to i64
  %7 = icmp sgt i32 %4, 0
  %8 = icmp sgt i32 %5, 0
  %or.cond = select i1 %7, i1 %8, i1 false
  br i1 %or.cond, label %9, label %36

9:                                                ; preds = %3
  %10 = icmp eq i32 %4, 1
  br i1 %10, label %11, label %14

11:                                               ; preds = %9
  %12 = load double, ptr %1, align 8, !tbaa !9
  %13 = tail call double @llvm.fabs.f64(double %12)
  br label %36

14:                                               ; preds = %9
  %narrow = add nsw i32 %4, -1
  %15 = zext nneg i32 %narrow to i64
  %16 = mul nuw nsw i64 %15, %6
  %17 = icmp sgt i64 %16, -1
  br i1 %17, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %14, %31
  %.042 = phi double [ %.1, %31 ], [ 1.000000e+00, %14 ]
  %.03141 = phi i64 [ %32, %31 ], [ %16, %14 ]
  %.03240 = phi double [ %.133, %31 ], [ 0.000000e+00, %14 ]
  %18 = getelementptr inbounds double, ptr %1, i64 %.03141
  %19 = load double, ptr %18, align 8, !tbaa !9
  %20 = fcmp une double %19, 0.000000e+00
  br i1 %20, label %21, label %31

21:                                               ; preds = %.lr.ph
  %22 = tail call double @llvm.fabs.f64(double %19)
  %23 = fcmp olt double %.03240, %22
  br i1 %23, label %24, label %28

24:                                               ; preds = %21
  %25 = fdiv double %.03240, %22
  %26 = fmul double %25, %25
  %27 = tail call double @llvm.fmuladd.f64(double %.042, double %26, double 1.000000e+00)
  br label %31

28:                                               ; preds = %21
  %29 = fdiv double %22, %.03240
  %30 = tail call double @llvm.fmuladd.f64(double %29, double %29, double %.042)
  br label %31

31:                                               ; preds = %.lr.ph, %28, %24
  %.133 = phi double [ %22, %24 ], [ %.03240, %28 ], [ %.03240, %.lr.ph ]
  %.1 = phi double [ %27, %24 ], [ %30, %28 ], [ %.042, %.lr.ph ]
  %32 = sub nsw i64 %.03141, %6
  %33 = icmp sgt i64 %32, -1
  br i1 %33, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge:                                      ; preds = %31, %14
  %.032.lcssa = phi double [ 0.000000e+00, %14 ], [ %.133, %31 ]
  %.0.lcssa = phi double [ 1.000000e+00, %14 ], [ %.1, %31 ]
  %34 = tail call double @sqrt(double noundef %.0.lcssa) #3
  %35 = fmul double %.032.lcssa, %34
  br label %36

36:                                               ; preds = %3, %11, %._crit_edge
  %.034 = phi double [ %13, %11 ], [ %35, %._crit_edge ], [ 0.000000e+00, %3 ]
  ret double %.034
}

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

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sqrt(double noundef) local_unnamed_addr #2

attributes #0 = { nofree nounwind memory(write, argmem: readwrite) 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) }
attributes #2 = { mustprogress nofree nounwind willreturn memory(write) "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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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