; LLVM IR from robotic-vision-lab/Cloud-Object-Recognition-Engine :: 3rdparty/libsvm/svm.ll (ZN6Solver13calculate_rhoEv)

; 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.Solver = type <{ ptr, i32, [4 x i8], ptr, ptr, ptr, ptr, ptr, ptr, double, double, double, ptr, ptr, ptr, i32, i8, [3 x i8] }>

; 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 nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN6Solver14is_lower_boundEi(ptr noundef nonnull align 8 dereferenceable(117), i32 noundef) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN6Solver14is_upper_boundEi(ptr noundef nonnull align 8 dereferenceable(117), i32 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZN6Solver13calculate_rhoEv(ptr noundef nonnull align 8 dereferenceable(117) %0) unnamed_addr #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca double, align 8
  %4 = alloca i32, align 4
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca i32, align 4
  %9 = alloca double, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %10 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  store double 0x7FF0000000000000, ptr %5, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  store double 0xFFF0000000000000, ptr %6, align 8, !tbaa !11
  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 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %11

11:                                               ; preds = %82, %1
  %12 = load i32, ptr %8, align 4, !tbaa !9
  %13 = getelementptr inbounds %class.Solver, ptr %10, i32 0, i32 1
  %14 = load i32, ptr %13, align 8, !tbaa !13
  %15 = icmp slt i32 %12, %14
  br i1 %15, label %17, label %16

16:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %85

17:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %18 = getelementptr inbounds %class.Solver, ptr %10, i32 0, i32 3
  %19 = load ptr, ptr %18, align 8, !tbaa !16
  %20 = load i32, ptr %8, align 4, !tbaa !9
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds i8, ptr %19, i64 %21
  %23 = load i8, ptr %22, align 1, !tbaa !17
  %24 = sext i8 %23 to i32
  %25 = sitofp i32 %24 to double
  %26 = getelementptr inbounds %class.Solver, ptr %10, i32 0, i32 4
  %27 = load ptr, ptr %26, align 8, !tbaa !18
  %28 = load i32, ptr %8, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds double, ptr %27, i64 %29
  %31 = load double, ptr %30, align 8, !tbaa !11
  %32 = fmul double %25, %31
  store double %32, ptr %9, align 8, !tbaa !11
  %33 = load i32, ptr %8, align 4, !tbaa !9
  %34 = call noundef zeroext i1 @_ZN6Solver14is_upper_boundEi(ptr noundef nonnull align 8 dereferenceable(117) %10, i32 noundef %33)
  br i1 %34, label %35, label %53

35:                                               ; preds = %17
  %36 = getelementptr inbounds %class.Solver, ptr %10, i32 0, i32 3
  %37 = load ptr, ptr %36, align 8, !tbaa !16
  %38 = load i32, ptr %8, align 4, !tbaa !9
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds i8, ptr %37, i64 %39
  %41 = load i8, ptr %40, align 1, !tbaa !17
  %42 = sext i8 %41 to i32
  %43 = icmp eq i32 %42, -1
  br i1 %43, label %44, label %48

44:                                               ; preds = %35
  %45 = load double, ptr %5, align 8, !tbaa !11
  %46 = load double, ptr %9, align 8, !tbaa !11
  %47 = call noundef double @_ZL3minIdET_S0_S0_(double noundef %45, double noundef %46)
  store double %47, ptr %5, align 8, !tbaa !11
  br label %52

48:                                               ; preds = %35
  %49 = load double, ptr %6, align 8, !tbaa !11
  %50 = load double, ptr %9, align 8, !tbaa !11
  %51 = call noundef double @_ZL3maxIdET_S0_S0_(double noundef %49, double noundef %50)
  store double %51, ptr %6, align 8, !tbaa !11
  br label %52

52:                                               ; preds = %48, %44
  br label %81

53:                                               ; preds = %17
  %54 = load i32, ptr %8, align 4, !tbaa !9
  %55 = call noundef zeroext i1 @_ZN6Solver14is_lower_boundEi(ptr noundef nonnull align 8 dereferenceable(117) %10, i32 noundef %54)
  br i1 %55, label %56, label %74

56:                                               ; preds = %53
  %57 = getelementptr inbounds %class.Solver, ptr %10, i32 0, i32 3
  %58 = load ptr, ptr %57, align 8, !tbaa !16
  %59 = load i32, ptr %8, align 4, !tbaa !9
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds i8, ptr %58, i64 %60
  %62 = load i8, ptr %61, align 1, !tbaa !17
  %63 = sext i8 %62 to i32
  %64 = icmp eq i32 %63, 1
  br i1 %64, label %65, label %69

65:                                               ; preds = %56
  %66 = load double, ptr %5, align 8, !tbaa !11
  %67 = load double, ptr %9, align 8, !tbaa !11
  %68 = call noundef double @_ZL3minIdET_S0_S0_(double noundef %66, double noundef %67)
  store double %68, ptr %5, align 8, !tbaa !11
  br label %73

69:                                               ; preds = %56
  %70 = load double, ptr %6, align 8, !tbaa !11
  %71 = load double, ptr %9, align 8, !tbaa !11
  %72 = call noundef double @_ZL3maxIdET_S0_S0_(double noundef %70, double noundef %71)
  store double %72, ptr %6, align 8, !tbaa !11
  br label %73

73:                                               ; preds = %69, %65
  br label %80

74:                                               ; preds = %53
  %75 = load i32, ptr %4, align 4, !tbaa !9
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr %4, align 4, !tbaa !9
  %77 = load double, ptr %9, align 8, !tbaa !11
  %78 = load double, ptr %7, align 8, !tbaa !11
  %79 = fadd double %78, %77
  store double %79, ptr %7, align 8, !tbaa !11
  br label %80

80:                                               ; preds = %74, %73
  br label %81

81:                                               ; preds = %80, %52
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  br label %82

82:                                               ; preds = %81
  %83 = load i32, ptr %8, align 4, !tbaa !9
  %84 = add nsw i32 %83, 1
  store i32 %84, ptr %8, align 4, !tbaa !9
  br label %11, !llvm.loop !19

85:                                               ; preds = %16
  %86 = load i32, ptr %4, align 4, !tbaa !9
  %87 = icmp sgt i32 %86, 0
  br i1 %87, label %88, label %93

88:                                               ; preds = %85
  %89 = load double, ptr %7, align 8, !tbaa !11
  %90 = load i32, ptr %4, align 4, !tbaa !9
  %91 = sitofp i32 %90 to double
  %92 = fdiv double %89, %91
  store double %92, ptr %3, align 8, !tbaa !11
  br label %98

93:                                               ; preds = %85
  %94 = load double, ptr %5, align 8, !tbaa !11
  %95 = load double, ptr %6, align 8, !tbaa !11
  %96 = fadd double %94, %95
  %97 = fdiv double %96, 2.000000e+00
  store double %97, ptr %3, align 8, !tbaa !11
  br label %98

98:                                               ; preds = %93, %88
  %99 = load double, ptr %3, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  ret double %99
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef double @_ZL3minIdET_S0_S0_(double noundef, double noundef) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef double @_ZL3maxIdET_S0_S0_(double noundef, double noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { inlinehint 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 #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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !10, i64 8}
!14 = !{!"_ZTS6Solver", !10, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !12, i64 64, !12, i64 72, !12, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !10, i64 112, !15, i64 116}
!15 = !{!"bool", !7, i64 0}
!16 = !{!14, !6, i64 16}
!17 = !{!7, !7, i64 0}
!18 = !{!14, !6, i64 24}
!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 nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN6Solver14is_lower_boundEi(ptr noundef nonnull align 8 dereferenceable(117), i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN6Solver14is_upper_boundEi(ptr noundef nonnull align 8 dereferenceable(117), i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZN6Solver13calculate_rhoEv(ptr noundef nonnull align 8 dereferenceable(117) %0) unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %4 = icmp sgt i32 %3, 0
  br i1 %4, label %.lr.ph, label %._crit_edge.thread

.lr.ph:                                           ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  br label %14

._crit_edge:                                      ; preds = %48
  %7 = fadd double %.130, %.128
  %8 = fmul double %7, 5.000000e-01
  %9 = icmp sgt i32 %.132.fr, 0
  br i1 %9, label %10, label %._crit_edge.thread

10:                                               ; preds = %._crit_edge
  %11 = uitofp nneg i32 %.132.fr to double
  %12 = fdiv double %.1, %11
  br label %._crit_edge.thread

._crit_edge.thread:                               ; preds = %1, %._crit_edge, %10
  %13 = phi double [ %12, %10 ], [ %8, %._crit_edge ], [ 0x7FF8000000000000, %1 ]
  ret double %13

14:                                               ; preds = %.lr.ph, %48
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %48 ]
  %.02636 = phi double [ 0.000000e+00, %.lr.ph ], [ %.1, %48 ]
  %.02735 = phi double [ 0xFFF0000000000000, %.lr.ph ], [ %.128, %48 ]
  %.02934 = phi double [ 0x7FF0000000000000, %.lr.ph ], [ %.130, %48 ]
  %.03133 = phi i32 [ 0, %.lr.ph ], [ %.132.fr, %48 ]
  %15 = load ptr, ptr %5, align 8, !tbaa !13
  %16 = getelementptr inbounds i8, ptr %15, i64 %indvars.iv
  %17 = load i8, ptr %16, align 1, !tbaa !14
  %18 = sitofp i8 %17 to double
  %19 = load ptr, ptr %6, align 8, !tbaa !15
  %20 = getelementptr inbounds double, ptr %19, i64 %indvars.iv
  %21 = load double, ptr %20, align 8, !tbaa !16
  %22 = fmul double %21, %18
  %23 = trunc nuw nsw i64 %indvars.iv to i32
  %24 = tail call noundef zeroext i1 @_ZN6Solver14is_upper_boundEi(ptr noundef nonnull align 8 dereferenceable(117) %0, i32 noundef %23)
  br i1 %24, label %25, label %34

25:                                               ; preds = %14
  %26 = load ptr, ptr %5, align 8, !tbaa !13
  %27 = getelementptr inbounds i8, ptr %26, i64 %indvars.iv
  %28 = load i8, ptr %27, align 1, !tbaa !14
  %29 = icmp eq i8 %28, -1
  br i1 %29, label %30, label %32

30:                                               ; preds = %25
  %31 = tail call noundef double @_ZL3minIdET_S0_S0_(double noundef %.02934, double noundef %22)
  br label %48

32:                                               ; preds = %25
  %33 = tail call noundef double @_ZL3maxIdET_S0_S0_(double noundef %.02735, double noundef %22)
  br label %48

34:                                               ; preds = %14
  %35 = tail call noundef zeroext i1 @_ZN6Solver14is_lower_boundEi(ptr noundef nonnull align 8 dereferenceable(117) %0, i32 noundef %23)
  br i1 %35, label %36, label %45

36:                                               ; preds = %34
  %37 = load ptr, ptr %5, align 8, !tbaa !13
  %38 = getelementptr inbounds i8, ptr %37, i64 %indvars.iv
  %39 = load i8, ptr %38, align 1, !tbaa !14
  %40 = icmp eq i8 %39, 1
  br i1 %40, label %41, label %43

41:                                               ; preds = %36
  %42 = tail call noundef double @_ZL3minIdET_S0_S0_(double noundef %.02934, double noundef %22)
  br label %48

43:                                               ; preds = %36
  %44 = tail call noundef double @_ZL3maxIdET_S0_S0_(double noundef %.02735, double noundef %22)
  br label %48

45:                                               ; preds = %34
  %46 = add nsw i32 %.03133, 1
  %47 = fadd double %.02636, %22
  br label %48

48:                                               ; preds = %45, %43, %41, %30, %32
  %.132 = phi i32 [ %.03133, %30 ], [ %.03133, %32 ], [ %.03133, %41 ], [ %.03133, %43 ], [ %46, %45 ]
  %.130 = phi double [ %31, %30 ], [ %.02934, %32 ], [ %42, %41 ], [ %.02934, %43 ], [ %.02934, %45 ]
  %.128 = phi double [ %.02735, %30 ], [ %33, %32 ], [ %.02735, %41 ], [ %44, %43 ], [ %.02735, %45 ]
  %.1 = phi double [ %.02636, %30 ], [ %.02636, %32 ], [ %.02636, %41 ], [ %.02636, %43 ], [ %47, %45 ]
  %.132.fr = freeze i32 %.132
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %49 = load i32, ptr %2, align 8, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = icmp slt i64 %indvars.iv.next, %50
  br i1 %51, label %14, label %._crit_edge, !llvm.loop !17
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef double @_ZL3minIdET_S0_S0_(double noundef, double noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef double @_ZL3maxIdET_S0_S0_(double noundef, double noundef) local_unnamed_addr #1

attributes #0 = { 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 #1 = { inlinehint 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" }

!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, !7, i64 8}
!6 = !{!"_ZTS6Solver", !7, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !10, i64 88, !10, i64 96, !10, i64 104, !7, i64 112, !12, i64 116}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"double", !8, i64 0}
!12 = !{!"bool", !8, i64 0}
!13 = !{!6, !10, i64 16}
!14 = !{!8, !8, i64 0}
!15 = !{!6, !10, i64 24}
!16 = !{!11, !11, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


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