; LLVM IR from ashishzero/karma :: src/modules/core/lin_maths.ll (Z24dynamic_circle_vs_circleRK6CircleS1_4Vec2S2_Pf)

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

%union.Vec2 = type { %struct.anon.1 }
%struct.anon.1 = type { float, float }
%struct.Circle = type { %union.Vec2, float }

; 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) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_Z8vec2_dot4Vec2S_(<2 x float>, <2 x float>) #1

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

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

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

; Function Attrs: nounwind
declare float @sqrtf(float noundef) #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_Zmi4Vec2S_(<2 x float>, <2 x float>) #5

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z24dynamic_circle_vs_circleRK6CircleS1_4Vec2S2_Pf(ptr noundef nonnull align 4 dereferenceable(12) %0, ptr noundef nonnull align 4 dereferenceable(12) %1, <2 x float> %2, <2 x float> %3, ptr noundef %4) #6 {
  %6 = alloca i1, align 1
  %7 = alloca %union.Vec2, align 4
  %8 = alloca %union.Vec2, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca %union.Vec2, align 4
  %13 = alloca %union.Vec2, align 4
  %14 = alloca %union.Vec2, align 4
  %15 = alloca %union.Vec2, align 4
  %16 = alloca %union.Vec2, align 4
  %17 = alloca %union.Vec2, align 4
  %18 = alloca float, align 4
  %19 = alloca float, align 4
  %20 = alloca %union.Vec2, align 4
  %21 = alloca %union.Vec2, align 4
  %22 = alloca i32, align 4
  %23 = alloca float, align 4
  %24 = alloca %union.Vec2, align 4
  %25 = alloca %union.Vec2, align 4
  %26 = alloca float, align 4
  %27 = alloca %union.Vec2, align 4
  %28 = alloca %union.Vec2, align 4
  %29 = alloca float, align 4
  %30 = getelementptr inbounds %union.Vec2, ptr %7, i32 0, i32 0
  store <2 x float> %2, ptr %30, align 4
  %31 = getelementptr inbounds %union.Vec2, ptr %8, i32 0, i32 0
  store <2 x float> %3, ptr %31, align 4
  store ptr %0, ptr %9, align 8, !tbaa !5
  store ptr %1, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  %32 = load ptr, ptr %10, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.Circle, ptr %32, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %13, ptr align 4 %33, i64 8, i1 false), !tbaa.struct !9
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.Circle, ptr %34, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %14, ptr align 4 %35, i64 8, i1 false), !tbaa.struct !9
  %36 = getelementptr inbounds %union.Vec2, ptr %13, i32 0, i32 0
  %37 = load <2 x float>, ptr %36, align 4
  %38 = getelementptr inbounds %union.Vec2, ptr %14, i32 0, i32 0
  %39 = load <2 x float>, ptr %38, align 4
  %40 = call <2 x float> @_Zmi4Vec2S_(<2 x float> %37, <2 x float> %39)
  %41 = getelementptr inbounds %union.Vec2, ptr %12, i32 0, i32 0
  store <2 x float> %40, ptr %41, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %16, ptr align 4 %8, i64 8, i1 false), !tbaa.struct !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %17, ptr align 4 %7, i64 8, i1 false), !tbaa.struct !9
  %42 = getelementptr inbounds %union.Vec2, ptr %16, i32 0, i32 0
  %43 = load <2 x float>, ptr %42, align 4
  %44 = getelementptr inbounds %union.Vec2, ptr %17, i32 0, i32 0
  %45 = load <2 x float>, ptr %44, align 4
  %46 = call <2 x float> @_Zmi4Vec2S_(<2 x float> %43, <2 x float> %45)
  %47 = getelementptr inbounds %union.Vec2, ptr %15, i32 0, i32 0
  store <2 x float> %46, ptr %47, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #7
  %48 = load ptr, ptr %10, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.Circle, ptr %48, i32 0, i32 1
  %50 = load float, ptr %49, align 4, !tbaa !11
  %51 = load ptr, ptr %9, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.Circle, ptr %51, i32 0, i32 1
  %53 = load float, ptr %52, align 4, !tbaa !11
  %54 = fadd float %50, %53
  store float %54, ptr %18, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %20, ptr align 4 %12, i64 8, i1 false), !tbaa.struct !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %21, ptr align 4 %12, i64 8, i1 false), !tbaa.struct !9
  %55 = getelementptr inbounds %union.Vec2, ptr %20, i32 0, i32 0
  %56 = load <2 x float>, ptr %55, align 4
  %57 = getelementptr inbounds %union.Vec2, ptr %21, i32 0, i32 0
  %58 = load <2 x float>, ptr %57, align 4
  %59 = call noundef float @_Z8vec2_dot4Vec2S_(<2 x float> %56, <2 x float> %58)
  %60 = load float, ptr %18, align 4, !tbaa !14
  %61 = load float, ptr %18, align 4, !tbaa !14
  %62 = fneg float %60
  %63 = call float @llvm.fmuladd.f32(float %62, float %61, float %59)
  store float %63, ptr %19, align 4, !tbaa !14
  %64 = load float, ptr %19, align 4, !tbaa !14
  %65 = fcmp olt float %64, 0.000000e+00
  br i1 %65, label %66, label %68

66:                                               ; preds = %5
  %67 = load ptr, ptr %11, align 8, !tbaa !5
  store float 0.000000e+00, ptr %67, align 4, !tbaa !14
  store i1 true, ptr %6, align 1
  store i32 1, ptr %22, align 4
  br label %109

68:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %24, ptr align 4 %15, i64 8, i1 false), !tbaa.struct !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %25, ptr align 4 %15, i64 8, i1 false), !tbaa.struct !9
  %69 = getelementptr inbounds %union.Vec2, ptr %24, i32 0, i32 0
  %70 = load <2 x float>, ptr %69, align 4
  %71 = getelementptr inbounds %union.Vec2, ptr %25, i32 0, i32 0
  %72 = load <2 x float>, ptr %71, align 4
  %73 = call noundef float @_Z8vec2_dot4Vec2S_(<2 x float> %70, <2 x float> %72)
  store float %73, ptr %23, align 4, !tbaa !14
  %74 = load float, ptr %23, align 4, !tbaa !14
  %75 = fcmp olt float %74, 0x3E80000000000000
  br i1 %75, label %76, label %77

76:                                               ; preds = %68
  store i1 false, ptr %6, align 1
  store i32 1, ptr %22, align 4
  br label %108

77:                                               ; preds = %68
  call void @llvm.lifetime.start.p0(i64 4, ptr %26) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %27, ptr align 4 %15, i64 8, i1 false), !tbaa.struct !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %28, ptr align 4 %12, i64 8, i1 false), !tbaa.struct !9
  %78 = getelementptr inbounds %union.Vec2, ptr %27, i32 0, i32 0
  %79 = load <2 x float>, ptr %78, align 4
  %80 = getelementptr inbounds %union.Vec2, ptr %28, i32 0, i32 0
  %81 = load <2 x float>, ptr %80, align 4
  %82 = call noundef float @_Z8vec2_dot4Vec2S_(<2 x float> %79, <2 x float> %81)
  store float %82, ptr %26, align 4, !tbaa !14
  %83 = load float, ptr %26, align 4, !tbaa !14
  %84 = fcmp oge float %83, 0.000000e+00
  br i1 %84, label %85, label %86

85:                                               ; preds = %77
  store i1 false, ptr %6, align 1
  store i32 1, ptr %22, align 4
  br label %107

86:                                               ; preds = %77
  call void @llvm.lifetime.start.p0(i64 4, ptr %29) #7
  %87 = load float, ptr %26, align 4, !tbaa !14
  %88 = load float, ptr %26, align 4, !tbaa !14
  %89 = load float, ptr %23, align 4, !tbaa !14
  %90 = load float, ptr %19, align 4, !tbaa !14
  %91 = fmul float %89, %90
  %92 = fneg float %91
  %93 = call float @llvm.fmuladd.f32(float %87, float %88, float %92)
  store float %93, ptr %29, align 4, !tbaa !14
  %94 = load float, ptr %29, align 4, !tbaa !14
  %95 = fcmp olt float %94, 0.000000e+00
  br i1 %95, label %96, label %97

96:                                               ; preds = %86
  store i1 false, ptr %6, align 1
  store i32 1, ptr %22, align 4
  br label %106

97:                                               ; preds = %86
  %98 = load float, ptr %26, align 4, !tbaa !14
  %99 = fneg float %98
  %100 = load float, ptr %29, align 4, !tbaa !14
  %101 = call float @sqrtf(float noundef %100) #7
  %102 = fsub float %99, %101
  %103 = load float, ptr %23, align 4, !tbaa !14
  %104 = fdiv float %102, %103
  %105 = load ptr, ptr %11, align 8, !tbaa !5
  store float %104, ptr %105, align 4, !tbaa !14
  store i1 true, ptr %6, align 1
  store i32 1, ptr %22, align 4
  br label %106

106:                                              ; preds = %97, %96
  call void @llvm.lifetime.end.p0(i64 4, ptr %29) #7
  br label %107

107:                                              ; preds = %106, %85
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #7
  br label %108

108:                                              ; preds = %107, %76
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #7
  br label %109

109:                                              ; preds = %108, %66
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  %110 = load i1, ptr %6, align 1
  ret i1 %110
}

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nounwind 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nounwind "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 = { 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 #6 = { 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 #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 = !{i64 0, i64 8, !10}
!10 = !{!7, !7, i64 0}
!11 = !{!12, !13, i64 8}
!12 = !{!"_ZTS6Circle", !7, i64 0, !13, i64 8}
!13 = !{!"float", !7, i64 0}
!14 = !{!13, !13, 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 nounwind uwtable
declare dso_local noundef float @_Z8vec2_dot4Vec2S_(<2 x float>, <2 x float>) local_unnamed_addr #0

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @sqrtf(float noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_Zmi4Vec2S_(<2 x float>, <2 x float>) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z24dynamic_circle_vs_circleRK6CircleS1_4Vec2S2_Pf(ptr nocapture noundef nonnull readonly align 4 dereferenceable(12) %0, ptr nocapture noundef nonnull readonly align 4 dereferenceable(12) %1, <2 x float> %2, <2 x float> %3, ptr nocapture noundef writeonly %4) local_unnamed_addr #4 {
  %.sroa.024.0.copyload = load <2 x float>, ptr %1, align 4, !tbaa !5
  %.sroa.023.0.copyload = load <2 x float>, ptr %0, align 4, !tbaa !5
  %6 = tail call <2 x float> @_Zmi4Vec2S_(<2 x float> %.sroa.024.0.copyload, <2 x float> %.sroa.023.0.copyload)
  %7 = tail call <2 x float> @_Zmi4Vec2S_(<2 x float> %3, <2 x float> %2)
  %8 = getelementptr inbounds i8, ptr %1, i64 8
  %9 = load float, ptr %8, align 4, !tbaa !8
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load float, ptr %10, align 4, !tbaa !8
  %12 = fadd float %9, %11
  %13 = tail call noundef float @_Z8vec2_dot4Vec2S_(<2 x float> %6, <2 x float> %6)
  %14 = fneg float %12
  %15 = tail call float @llvm.fmuladd.f32(float %14, float %12, float %13)
  %16 = fcmp olt float %15, 0.000000e+00
  br i1 %16, label %.sink.split, label %17

17:                                               ; preds = %5
  %18 = tail call noundef float @_Z8vec2_dot4Vec2S_(<2 x float> %7, <2 x float> %7)
  %19 = fcmp olt float %18, 0x3E80000000000000
  br i1 %19, label %33, label %20

20:                                               ; preds = %17
  %21 = tail call noundef float @_Z8vec2_dot4Vec2S_(<2 x float> %7, <2 x float> %6)
  %22 = fcmp ult float %21, 0.000000e+00
  br i1 %22, label %23, label %33

23:                                               ; preds = %20
  %24 = fneg float %18
  %25 = fmul float %15, %24
  %26 = tail call float @llvm.fmuladd.f32(float %21, float %21, float %25)
  %27 = fcmp uge float %26, 0.000000e+00
  br i1 %27, label %28, label %33

28:                                               ; preds = %23
  %29 = fneg float %21
  %30 = tail call float @sqrtf(float noundef %26) #5
  %31 = fsub float %29, %30
  %32 = fdiv float %31, %18
  br label %.sink.split

.sink.split:                                      ; preds = %5, %28
  %.sink = phi float [ %32, %28 ], [ 0.000000e+00, %5 ]
  store float %.sink, ptr %4, align 4, !tbaa !11
  br label %33

33:                                               ; preds = %.sink.split, %17, %23, %20
  %.3 = phi i1 [ false, %17 ], [ false, %20 ], [ false, %23 ], [ true, %.sink.split ]
  ret i1 %.3
}

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


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