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

; 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

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

24:                                               ; preds = %3
  %25 = getelementptr inbounds %class.l2r_erm_fun, ptr %10, i32 0, i32 1
  %26 = load ptr, ptr %25, align 8, !tbaa !18
  %27 = load i32, ptr %6, align 4, !tbaa !9
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds double, ptr %26, i64 %28
  %30 = load double, ptr %29, align 8, !tbaa !11
  %31 = load double, ptr %8, align 8, !tbaa !11
  %32 = fmul double %30, %31
  %33 = load double, ptr %8, align 8, !tbaa !11
  %34 = fmul double %32, %33
  store double %34, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %36

35:                                               ; preds = %3
  store double 0.000000e+00, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %36

36:                                               ; preds = %35, %24
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  %37 = load double, ptr %4, align 8
  ret double %37
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { mustprogress 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !6, i64 16}
!14 = !{!"_ZTS11l2r_erm_fun", !15, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !12, i64 40, !10, i64 48}
!15 = !{!"_ZTS8function"}
!16 = !{!17, !6, i64 8}
!17 = !{!"_ZTS7problem", !10, i64 0, !10, i64 4, !6, i64 8, !6, i64 16, !12, i64 24}
!18 = !{!14, !6, i64 8}


; 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: mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) uwtable
define dso_local noundef double @_ZN14l2r_l2_svc_fun12C_times_lossEid(ptr nocapture noundef nonnull readonly align 8 dereferenceable(68) %0, i32 noundef %1, double noundef %2) unnamed_addr #1 align 2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %5, i64 8
  %7 = load ptr, ptr %6, align 8, !tbaa !13
  %8 = sext i32 %1 to i64
  %9 = getelementptr inbounds double, ptr %7, i64 %8
  %10 = load double, ptr %9, align 8, !tbaa !15
  %11 = fneg double %10
  %12 = tail call double @llvm.fmuladd.f64(double %11, double %2, double 1.000000e+00)
  %13 = fcmp ogt double %12, 0.000000e+00
  br i1 %13, label %14, label %21

14:                                               ; preds = %3
  %15 = getelementptr inbounds i8, ptr %0, i64 8
  %16 = load ptr, ptr %15, align 8, !tbaa !16
  %17 = getelementptr inbounds double, ptr %16, i64 %8
  %18 = load double, ptr %17, align 8, !tbaa !15
  %19 = fmul double %12, %18
  %20 = fmul double %12, %19
  br label %21

21:                                               ; preds = %3, %14
  %.0 = phi double [ %20, %14 ], [ 0.000000e+00, %3 ]
  ret double %.0
}

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

!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, !8, i64 8}
!14 = !{!"_ZTS7problem", !12, i64 0, !12, i64 4, !8, i64 8, !8, i64 16, !11, i64 24}
!15 = !{!11, !11, i64 0}
!16 = !{!6, !8, i64 8}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass