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

; 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: 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 float @llvm.fmuladd.f32(float, float, float) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5ImGui20ColorConvertRGBtoHSVEfffRfS0_S0_(float noundef %0, float noundef %1, float noundef %2, ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %5) #2 {
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  store float %0, ptr %7, align 4, !tbaa !5
  store float %1, ptr %8, align 4, !tbaa !5
  store float %2, ptr %9, align 4, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !9
  store ptr %4, ptr %11, align 8, !tbaa !9
  store ptr %5, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  store float 0.000000e+00, ptr %13, align 4, !tbaa !5
  %15 = load float, ptr %8, align 4, !tbaa !5
  %16 = load float, ptr %9, align 4, !tbaa !5
  %17 = fcmp olt float %15, %16
  br i1 %17, label %18, label %19

18:                                               ; preds = %6
  call void @_ZL6ImSwapIfEvRT_S1_(ptr noundef nonnull align 4 dereferenceable(4) %8, ptr noundef nonnull align 4 dereferenceable(4) %9)
  store float -1.000000e+00, ptr %13, align 4, !tbaa !5
  br label %19

19:                                               ; preds = %18, %6
  %20 = load float, ptr %7, align 4, !tbaa !5
  %21 = load float, ptr %8, align 4, !tbaa !5
  %22 = fcmp olt float %20, %21
  br i1 %22, label %23, label %26

23:                                               ; preds = %19
  call void @_ZL6ImSwapIfEvRT_S1_(ptr noundef nonnull align 4 dereferenceable(4) %7, ptr noundef nonnull align 4 dereferenceable(4) %8)
  %24 = load float, ptr %13, align 4, !tbaa !5
  %25 = fsub float 0xBFD5555560000000, %24
  store float %25, ptr %13, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %23, %19
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %27 = load float, ptr %7, align 4, !tbaa !5
  %28 = load float, ptr %8, align 4, !tbaa !5
  %29 = load float, ptr %9, align 4, !tbaa !5
  %30 = fcmp olt float %28, %29
  br i1 %30, label %31, label %33

31:                                               ; preds = %26
  %32 = load float, ptr %8, align 4, !tbaa !5
  br label %35

33:                                               ; preds = %26
  %34 = load float, ptr %9, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %33, %31
  %36 = phi float [ %32, %31 ], [ %34, %33 ]
  %37 = fsub float %27, %36
  store float %37, ptr %14, align 4, !tbaa !5
  %38 = load float, ptr %13, align 4, !tbaa !5
  %39 = load float, ptr %8, align 4, !tbaa !5
  %40 = load float, ptr %9, align 4, !tbaa !5
  %41 = fsub float %39, %40
  %42 = load float, ptr %14, align 4, !tbaa !5
  %43 = call float @llvm.fmuladd.f32(float 6.000000e+00, float %42, float 0x3BC79CA100000000)
  %44 = fdiv float %41, %43
  %45 = fadd float %38, %44
  %46 = call float @llvm.fabs.f32(float %45)
  %47 = load ptr, ptr %10, align 8, !tbaa !9
  store float %46, ptr %47, align 4, !tbaa !5
  %48 = load float, ptr %14, align 4, !tbaa !5
  %49 = load float, ptr %7, align 4, !tbaa !5
  %50 = fadd float %49, 0x3BC79CA100000000
  %51 = fdiv float %48, %50
  %52 = load ptr, ptr %11, align 8, !tbaa !9
  store float %51, ptr %52, align 4, !tbaa !5
  %53 = load float, ptr %7, align 4, !tbaa !5
  %54 = load ptr, ptr %12, align 8, !tbaa !9
  store float %53, ptr %54, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden void @_ZL6ImSwapIfEvRT_S1_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #3

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}


; 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 float @llvm.fmuladd.f32(float, float, float) #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN5ImGui20ColorConvertRGBtoHSVEfffRfS0_S0_(float noundef %0, float noundef %1, float noundef %2, ptr nocapture noundef nonnull writeonly align 4 dereferenceable(4) %3, ptr nocapture noundef nonnull writeonly align 4 dereferenceable(4) %4, ptr nocapture noundef nonnull writeonly align 4 dereferenceable(4) %5) local_unnamed_addr #1 {
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  store float %0, ptr %7, align 4, !tbaa !5
  store float %1, ptr %8, align 4, !tbaa !5
  store float %2, ptr %9, align 4, !tbaa !5
  %10 = fcmp olt float %1, %2
  br i1 %10, label %11, label %12

11:                                               ; preds = %6
  call void @_ZL6ImSwapIfEvRT_S1_(ptr noundef nonnull align 4 dereferenceable(4) %8, ptr noundef nonnull align 4 dereferenceable(4) %9)
  %.pre = load float, ptr %8, align 4
  br label %12

12:                                               ; preds = %11, %6
  %13 = phi float [ %.pre, %11 ], [ %1, %6 ]
  %.0 = phi float [ -1.000000e+00, %11 ], [ 0.000000e+00, %6 ]
  %14 = fcmp ogt float %13, %0
  br i1 %14, label %15, label %17

15:                                               ; preds = %12
  call void @_ZL6ImSwapIfEvRT_S1_(ptr noundef nonnull align 4 dereferenceable(4) %7, ptr noundef nonnull align 4 dereferenceable(4) %8)
  %16 = fsub float 0xBFD5555560000000, %.0
  %.pre7 = load float, ptr %7, align 4, !tbaa !5
  %.pre8 = load float, ptr %8, align 4
  br label %17

17:                                               ; preds = %15, %12
  %18 = phi float [ %.pre8, %15 ], [ %13, %12 ]
  %19 = phi float [ %.pre7, %15 ], [ %0, %12 ]
  %.1 = phi float [ %16, %15 ], [ %.0, %12 ]
  %20 = load float, ptr %9, align 4
  %21 = fcmp olt float %18, %20
  %22 = select i1 %21, float %18, float %20
  %23 = fsub float %19, %22
  %24 = fsub float %18, %20
  %25 = call float @llvm.fmuladd.f32(float %23, float 6.000000e+00, float 0x3BC79CA100000000)
  %26 = fdiv float %24, %25
  %27 = fadd float %.1, %26
  %28 = call float @llvm.fabs.f32(float %27)
  store float %28, ptr %3, align 4, !tbaa !5
  %29 = fadd float %19, 0x3BC79CA100000000
  %30 = fdiv float %23, %29
  store float %30, ptr %4, align 4, !tbaa !5
  store float %19, ptr %5, align 4, !tbaa !5
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden void @_ZL6ImSwapIfEvRT_S1_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { 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, !6, i64 0}
!6 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


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