; LLVM IR from dtecta/motion-toolkit :: jointlimits/Ellipse.ll (ZNK2ik7Ellipse5clampERfS1_i)

; 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.mt::Dual" = type { float, float }
%"class.ik::Ellipse" = type { float, float }

@_ZN2ik7Ellipse10sToleranceE = external dso_local global float, align 4

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK2ik7Ellipse5clampERfS1_i(ptr noundef nonnull align 4 dereferenceable(8) %0, ptr noundef nonnull align 4 dereferenceable(4) %1, ptr noundef nonnull align 4 dereferenceable(4) %2, i32 noundef %3) #0 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca float, align 4
  %10 = alloca %"class.mt::Dual", align 4
  %11 = alloca %"class.mt::Dual", align 4
  %12 = alloca %"class.mt::Dual", align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store i32 %3, ptr %8, align 4, !tbaa !9
  %13 = load ptr, ptr %5, align 8
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = load float, ptr %14, align 4, !tbaa !11
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = load float, ptr %16, align 4, !tbaa !11
  %18 = call noundef float @_ZNK2ik7Ellipse4evalEff(ptr noundef nonnull align 4 dereferenceable(8) %13, float noundef %15, float noundef %17)
  %19 = call noundef zeroext i1 @_ZN2mt10ispositiveEf(float noundef %18)
  br i1 %19, label %20, label %76

20:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  store float 0.000000e+00, ptr %9, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  call void @_ZN2mt4DualIfEC2Eff(ptr noundef nonnull align 4 dereferenceable(8) %10, float noundef 0.000000e+00, float noundef 0.000000e+00)
  br label %21

21:                                               ; preds = %37, %20
  %22 = load i32, ptr %8, align 4, !tbaa !9
  %23 = icmp ne i32 %22, 0
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  br i1 %23, label %24, label %35

24:                                               ; preds = %21
  %25 = load float, ptr %9, align 4, !tbaa !11
  call void @_ZN2mt4DualIfEC2Eff(ptr noundef nonnull align 4 dereferenceable(8) %12, float noundef %25, float noundef 1.000000e+00)
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = load float, ptr %26, align 4, !tbaa !11
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = load float, ptr %28, align 4, !tbaa !11
  %30 = load <2 x float>, ptr %12, align 4
  %31 = call <2 x float> @_ZNK2ik7Ellipse7genFuncIN2mt4DualIfEEEET_S5_ff(ptr noundef nonnull align 4 dereferenceable(8) %13, <2 x float> %30, float noundef %27, float noundef %29)
  store <2 x float> %31, ptr %11, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %10, ptr align 4 %11, i64 8, i1 false), !tbaa.struct !13
  %32 = call noundef float @_ZN2mt4realIfEET_RKNS_4DualIS1_EE(ptr noundef nonnull align 4 dereferenceable(8) %10)
  %33 = load float, ptr @_ZN2ik7Ellipse10sToleranceE, align 4, !tbaa !11
  %34 = fcmp ogt float %32, %33
  br label %35

35:                                               ; preds = %24, %21
  %36 = phi i1 [ false, %21 ], [ %34, %24 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  br i1 %36, label %37, label %45

37:                                               ; preds = %35
  %38 = call noundef float @_ZN2mt4realIfEET_RKNS_4DualIS1_EE(ptr noundef nonnull align 4 dereferenceable(8) %10)
  %39 = call noundef float @_ZN2mt4dualIfEET_RKNS_4DualIS1_EE(ptr noundef nonnull align 4 dereferenceable(8) %10)
  %40 = fdiv float %38, %39
  %41 = load float, ptr %9, align 4, !tbaa !11
  %42 = fsub float %41, %40
  store float %42, ptr %9, align 4, !tbaa !11
  %43 = load i32, ptr %8, align 4, !tbaa !9
  %44 = add nsw i32 %43, -1
  store i32 %44, ptr %8, align 4, !tbaa !9
  br label %21, !llvm.loop !14

45:                                               ; preds = %35
  %46 = getelementptr inbounds %"class.ik::Ellipse", ptr %13, i32 0, i32 0
  %47 = load float, ptr %46, align 4, !tbaa !16
  %48 = getelementptr inbounds %"class.ik::Ellipse", ptr %13, i32 0, i32 0
  %49 = load float, ptr %48, align 4, !tbaa !16
  %50 = fmul float %47, %49
  %51 = getelementptr inbounds %"class.ik::Ellipse", ptr %13, i32 0, i32 0
  %52 = load float, ptr %51, align 4, !tbaa !16
  %53 = getelementptr inbounds %"class.ik::Ellipse", ptr %13, i32 0, i32 0
  %54 = load float, ptr %53, align 4, !tbaa !16
  %55 = load float, ptr %9, align 4, !tbaa !11
  %56 = call float @llvm.fmuladd.f32(float %52, float %54, float %55)
  %57 = fdiv float %50, %56
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = load float, ptr %58, align 4, !tbaa !11
  %60 = fmul float %59, %57
  store float %60, ptr %58, align 4, !tbaa !11
  %61 = getelementptr inbounds %"class.ik::Ellipse", ptr %13, i32 0, i32 1
  %62 = load float, ptr %61, align 4, !tbaa !18
  %63 = getelementptr inbounds %"class.ik::Ellipse", ptr %13, i32 0, i32 1
  %64 = load float, ptr %63, align 4, !tbaa !18
  %65 = fmul float %62, %64
  %66 = getelementptr inbounds %"class.ik::Ellipse", ptr %13, i32 0, i32 1
  %67 = load float, ptr %66, align 4, !tbaa !18
  %68 = getelementptr inbounds %"class.ik::Ellipse", ptr %13, i32 0, i32 1
  %69 = load float, ptr %68, align 4, !tbaa !18
  %70 = load float, ptr %9, align 4, !tbaa !11
  %71 = call float @llvm.fmuladd.f32(float %67, float %69, float %70)
  %72 = fdiv float %65, %71
  %73 = load ptr, ptr %7, align 8, !tbaa !5
  %74 = load float, ptr %73, align 4, !tbaa !11
  %75 = fmul float %74, %72
  store float %75, ptr %73, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  br label %76

76:                                               ; preds = %45, %4
  ret void
}

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN2mt10ispositiveEf(float noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef float @_ZNK2ik7Ellipse4evalEff(ptr noundef nonnull align 4 dereferenceable(8), float noundef, float noundef) #2 align 2

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

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local void @_ZN2mt4DualIfEC2Eff(ptr noundef nonnull align 4 dereferenceable(8), float noundef, float noundef) unnamed_addr #4 align 2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef float @_ZN2mt4realIfEET_RKNS_4DualIS1_EE(ptr noundef nonnull align 4 dereferenceable(8)) #4

; Function Attrs: mustprogress uwtable
declare dso_local <2 x float> @_ZNK2ik7Ellipse7genFuncIN2mt4DualIfEEEET_S5_ff(ptr noundef nonnull align 4 dereferenceable(8), <2 x float>, float noundef, float noundef) #0 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

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

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef float @_ZN2mt4dualIfEET_RKNS_4DualIS1_EE(ptr noundef nonnull align 4 dereferenceable(8)) #4

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #6

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="64" "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 = { alwaysinline 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 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { alwaysinline 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 #5 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #7 = { 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 = !{!"float", !7, i64 0}
!13 = !{i64 0, i64 4, !11, i64 4, i64 4, !11}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!17, !12, i64 0}
!17 = !{!"_ZTSN2ik7EllipseE", !12, i64 0, !12, i64 4}
!18 = !{!17, !12, i64 4}


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

%"class.mt::Dual" = type { float, float }

@_ZN2ik7Ellipse10sToleranceE = external dso_local local_unnamed_addr global float, align 4

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK2ik7Ellipse5clampERfS1_i(ptr noundef nonnull align 4 dereferenceable(8) %0, ptr nocapture noundef nonnull align 4 dereferenceable(4) %1, ptr nocapture noundef nonnull align 4 dereferenceable(4) %2, i32 noundef %3) local_unnamed_addr #0 align 2 {
  %5 = alloca %"class.mt::Dual", align 8
  %6 = alloca %"class.mt::Dual", align 8
  %7 = load float, ptr %1, align 4, !tbaa !5
  %8 = load float, ptr %2, align 4, !tbaa !5
  %9 = tail call noundef float @_ZNK2ik7Ellipse4evalEff(ptr noundef nonnull align 4 dereferenceable(8) %0, float noundef %7, float noundef %8)
  %10 = tail call noundef zeroext i1 @_ZN2mt10ispositiveEf(float noundef %9)
  br i1 %10, label %11, label %38

11:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  call void @_ZN2mt4DualIfEC2Eff(ptr noundef nonnull align 4 dereferenceable(8) %5, float noundef 0.000000e+00, float noundef 0.000000e+00)
  %.not13 = icmp eq i32 %3, 0
  br i1 %.not13, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %11, %19
  %.015 = phi i32 [ %24, %19 ], [ %3, %11 ]
  %.01214 = phi float [ %23, %19 ], [ 0.000000e+00, %11 ]
  call void @_ZN2mt4DualIfEC2Eff(ptr noundef nonnull align 4 dereferenceable(8) %6, float noundef %.01214, float noundef 1.000000e+00)
  %12 = load float, ptr %1, align 4, !tbaa !5
  %13 = load float, ptr %2, align 4, !tbaa !5
  %14 = load <2 x float>, ptr %6, align 8
  %15 = call <2 x float> @_ZNK2ik7Ellipse7genFuncIN2mt4DualIfEEEET_S5_ff(ptr noundef nonnull align 4 dereferenceable(8) %0, <2 x float> %14, float noundef %12, float noundef %13)
  store <2 x float> %15, ptr %5, align 8
  %16 = call noundef float @_ZN2mt4realIfEET_RKNS_4DualIS1_EE(ptr noundef nonnull align 4 dereferenceable(8) %5)
  %17 = load float, ptr @_ZN2ik7Ellipse10sToleranceE, align 4, !tbaa !5
  %18 = fcmp ogt float %16, %17
  br i1 %18, label %19, label %.critedge

19:                                               ; preds = %.lr.ph
  %20 = call noundef float @_ZN2mt4realIfEET_RKNS_4DualIS1_EE(ptr noundef nonnull align 4 dereferenceable(8) %5)
  %21 = call noundef float @_ZN2mt4dualIfEET_RKNS_4DualIS1_EE(ptr noundef nonnull align 4 dereferenceable(8) %5)
  %22 = fdiv float %20, %21
  %23 = fsub float %.01214, %22
  %24 = add nsw i32 %.015, -1
  %.not = icmp eq i32 %24, 0
  br i1 %.not, label %.critedge, label %.lr.ph, !llvm.loop !9

.critedge:                                        ; preds = %.lr.ph, %19, %11
  %.012.lcssa = phi float [ 0.000000e+00, %11 ], [ %23, %19 ], [ %.01214, %.lr.ph ]
  %25 = load float, ptr %0, align 4, !tbaa !11
  %26 = fmul float %25, %25
  %27 = call float @llvm.fmuladd.f32(float %25, float %25, float %.012.lcssa)
  %28 = fdiv float %26, %27
  %29 = load float, ptr %1, align 4, !tbaa !5
  %30 = fmul float %29, %28
  store float %30, ptr %1, align 4, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %0, i64 4
  %32 = load float, ptr %31, align 4, !tbaa !13
  %33 = fmul float %32, %32
  %34 = call float @llvm.fmuladd.f32(float %32, float %32, float %.012.lcssa)
  %35 = fdiv float %33, %34
  %36 = load float, ptr %2, align 4, !tbaa !5
  %37 = fmul float %36, %35
  store float %37, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  br label %38

38:                                               ; preds = %.critedge, %4
  ret void
}

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN2mt10ispositiveEf(float noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef float @_ZNK2ik7Ellipse4evalEff(ptr noundef nonnull align 4 dereferenceable(8), float noundef, float noundef) local_unnamed_addr #2 align 2

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

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local void @_ZN2mt4DualIfEC2Eff(ptr noundef nonnull align 4 dereferenceable(8), float noundef, float noundef) unnamed_addr #4 align 2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef float @_ZN2mt4realIfEET_RKNS_4DualIS1_EE(ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
declare dso_local <2 x float> @_ZNK2ik7Ellipse7genFuncIN2mt4DualIfEEEET_S5_ff(ptr noundef nonnull align 4 dereferenceable(8), <2 x float>, float noundef, float noundef) local_unnamed_addr #0 align 2

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

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef float @_ZN2mt4dualIfEET_RKNS_4DualIS1_EE(ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #4

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #5

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="64" "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 = { alwaysinline 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 = { 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { alwaysinline 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 #5 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTSN2ik7EllipseE", !6, i64 0, !6, i64 4}
!13 = !{!12, !6, i64 4}


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