; LLVM IR from Samson-Mano/EM_Propogation_simulation :: EM_Propogation_simulation/src/ImGui/imgui.ll (Z18ImLineClosestPointRK6ImVec2S1_S1_)

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

%struct.ImVec2 = type { float, float }

; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

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

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

; Function Attrs: mustprogress uwtable
define dso_local <2 x float> @_Z18ImLineClosestPointRK6ImVec2S1_S1_(ptr noundef nonnull align 4 dereferenceable(8) %0, ptr noundef nonnull align 4 dereferenceable(8) %1, ptr noundef nonnull align 4 dereferenceable(8) %2) #3 {
  %4 = alloca %struct.ImVec2, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca %struct.ImVec2, align 4
  %9 = alloca %struct.ImVec2, align 4
  %10 = alloca float, align 4
  %11 = alloca i32, align 4
  %12 = alloca float, align 4
  %13 = alloca %struct.ImVec2, align 4
  %14 = alloca %struct.ImVec2, 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
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = call <2 x float> @_ZmiRK6ImVec2S1_(ptr noundef nonnull align 4 dereferenceable(8) %15, ptr noundef nonnull align 4 dereferenceable(8) %16)
  store <2 x float> %17, ptr %8, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = call <2 x float> @_ZmiRK6ImVec2S1_(ptr noundef nonnull align 4 dereferenceable(8) %18, ptr noundef nonnull align 4 dereferenceable(8) %19)
  store <2 x float> %20, ptr %9, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %21 = getelementptr inbounds %struct.ImVec2, ptr %8, i32 0, i32 0
  %22 = load float, ptr %21, align 4, !tbaa !9
  %23 = getelementptr inbounds %struct.ImVec2, ptr %9, i32 0, i32 0
  %24 = load float, ptr %23, align 4, !tbaa !9
  %25 = getelementptr inbounds %struct.ImVec2, ptr %8, i32 0, i32 1
  %26 = load float, ptr %25, align 4, !tbaa !12
  %27 = getelementptr inbounds %struct.ImVec2, ptr %9, i32 0, i32 1
  %28 = load float, ptr %27, align 4, !tbaa !12
  %29 = fmul float %26, %28
  %30 = call float @llvm.fmuladd.f32(float %22, float %24, float %29)
  store float %30, ptr %10, align 4, !tbaa !13
  %31 = load float, ptr %10, align 4, !tbaa !13
  %32 = fcmp olt float %31, 0.000000e+00
  br i1 %32, label %33, label %35

33:                                               ; preds = %3
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %4, ptr align 4 %34, i64 8, i1 false), !tbaa.struct !14
  store i32 1, ptr %11, align 4
  br label %59

35:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %36 = getelementptr inbounds %struct.ImVec2, ptr %9, i32 0, i32 0
  %37 = load float, ptr %36, align 4, !tbaa !9
  %38 = getelementptr inbounds %struct.ImVec2, ptr %9, i32 0, i32 0
  %39 = load float, ptr %38, align 4, !tbaa !9
  %40 = getelementptr inbounds %struct.ImVec2, ptr %9, i32 0, i32 1
  %41 = load float, ptr %40, align 4, !tbaa !12
  %42 = getelementptr inbounds %struct.ImVec2, ptr %9, i32 0, i32 1
  %43 = load float, ptr %42, align 4, !tbaa !12
  %44 = fmul float %41, %43
  %45 = call float @llvm.fmuladd.f32(float %37, float %39, float %44)
  store float %45, ptr %12, align 4, !tbaa !13
  %46 = load float, ptr %10, align 4, !tbaa !13
  %47 = load float, ptr %12, align 4, !tbaa !13
  %48 = fcmp ogt float %46, %47
  br i1 %48, label %49, label %51

49:                                               ; preds = %35
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %4, ptr align 4 %50, i64 8, i1 false), !tbaa.struct !14
  store i32 1, ptr %11, align 4
  br label %58

51:                                               ; preds = %35
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %53 = load float, ptr %10, align 4, !tbaa !13
  %54 = call <2 x float> @_ZmlRK6ImVec2f(ptr noundef nonnull align 4 dereferenceable(8) %9, float noundef %53)
  store <2 x float> %54, ptr %14, align 4
  %55 = load float, ptr %12, align 4, !tbaa !13
  %56 = call <2 x float> @_ZdvRK6ImVec2f(ptr noundef nonnull align 4 dereferenceable(8) %14, float noundef %55)
  store <2 x float> %56, ptr %13, align 4
  %57 = call <2 x float> @_ZplRK6ImVec2S1_(ptr noundef nonnull align 4 dereferenceable(8) %52, ptr noundef nonnull align 4 dereferenceable(8) %13)
  store <2 x float> %57, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  store i32 1, ptr %11, align 4
  br label %58

58:                                               ; preds = %51, %49
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  br label %59

59:                                               ; preds = %58, %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  %60 = load <2 x float>, ptr %4, align 4
  ret <2 x float> %60
}

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

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

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint 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 #3 = { 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 #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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, !11, i64 0}
!10 = !{!"_ZTS6ImVec2", !11, i64 0, !11, i64 4}
!11 = !{!"float", !7, i64 0}
!12 = !{!10, !11, i64 4}
!13 = !{!11, !11, i64 0}
!14 = !{i64 0, i64 4, !13, i64 4, i64 4, !13}


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

%struct.ImVec2 = type { float, float }

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare hidden <2 x float> @_ZmlRK6ImVec2f(ptr noundef nonnull align 4 dereferenceable(8), float noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local <2 x float> @_Z18ImLineClosestPointRK6ImVec2S1_S1_(ptr noundef nonnull align 4 dereferenceable(8) %0, ptr noundef nonnull align 4 dereferenceable(8) %1, ptr noundef nonnull align 4 dereferenceable(8) %2) local_unnamed_addr #2 {
  %4 = alloca %struct.ImVec2, align 8
  %5 = alloca %struct.ImVec2, align 8
  %6 = alloca %struct.ImVec2, align 8
  %7 = tail call <2 x float> @_ZmiRK6ImVec2S1_(ptr noundef nonnull align 4 dereferenceable(8) %2, ptr noundef nonnull align 4 dereferenceable(8) %0)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  %8 = tail call <2 x float> @_ZmiRK6ImVec2S1_(ptr noundef nonnull align 4 dereferenceable(8) %1, ptr noundef nonnull align 4 dereferenceable(8) %0)
  store <2 x float> %8, ptr %4, align 8
  %.sroa.0.0.vec.extract = extractelement <2 x float> %7, i64 0
  %9 = extractelement <2 x float> %8, i64 0
  %10 = fmul <2 x float> %7, %8
  %11 = extractelement <2 x float> %10, i64 1
  %12 = tail call float @llvm.fmuladd.f32(float %.sroa.0.0.vec.extract, float %9, float %11)
  %13 = fcmp olt float %12, 0.000000e+00
  br i1 %13, label %14, label %15

14:                                               ; preds = %3
  %.sroa.012.0.copyload = load <2 x float>, ptr %0, align 4
  br label %25

15:                                               ; preds = %3
  %16 = extractelement <2 x float> %8, i64 1
  %17 = fmul float %16, %16
  %18 = tail call float @llvm.fmuladd.f32(float %9, float %9, float %17)
  %19 = fcmp ogt float %12, %18
  br i1 %19, label %20, label %21

20:                                               ; preds = %15
  %.sroa.012.0.copyload13 = load <2 x float>, ptr %1, align 4
  br label %25

21:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #4
  %22 = call <2 x float> @_ZmlRK6ImVec2f(ptr noundef nonnull align 4 dereferenceable(8) %4, float noundef %12)
  store <2 x float> %22, ptr %6, align 8
  %23 = call <2 x float> @_ZdvRK6ImVec2f(ptr noundef nonnull align 4 dereferenceable(8) %6, float noundef %18)
  store <2 x float> %23, ptr %5, align 8
  %24 = call <2 x float> @_ZplRK6ImVec2S1_(ptr noundef nonnull align 4 dereferenceable(8) %0, ptr noundef nonnull align 4 dereferenceable(8) %5)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  br label %25

25:                                               ; preds = %20, %21, %14
  %.sroa.012.1 = phi <2 x float> [ %.sroa.012.0.copyload, %14 ], [ %.sroa.012.0.copyload13, %20 ], [ %24, %21 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  ret <2 x float> %.sroa.012.1
}

; Function Attrs: inlinehint mustprogress uwtable
declare hidden <2 x float> @_ZmiRK6ImVec2S1_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #1

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

; Function Attrs: inlinehint mustprogress uwtable
declare hidden <2 x float> @_ZplRK6ImVec2S1_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress uwtable
declare hidden <2 x float> @_ZdvRK6ImVec2f(ptr noundef nonnull align 4 dereferenceable(8), float noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 #2 = { 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 #3 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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)"}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass,VectorCombinePass